Skip to content

Instantly share code, notes, and snippets.

@sebs
Last active August 29, 2015 13:59
Show Gist options
  • Save sebs/10973680 to your computer and use it in GitHub Desktop.
Save sebs/10973680 to your computer and use it in GitHub Desktop.
A x-tag component to parse Markdown to html in a page.
{
"name": "xtags",
"version": "0.0.0",
"authors": [
"Sebastian Schürmann <[email protected]>"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"markdown": "~0.5.0"
}
}
<html>
<head>
<script type="application/javascript" src="http://x-tags.org/js/x-tag-components.min.js"></script>
<script type="application/javascript" src="bower_components/markdown/lib/markdown.js"></script>
<link rel="import" href="custom-elements.html" />
<script>
xtag.register('x-markdown', {
lifecycle: {
ready: function(){
// var md = markdown.toHTML(this.innerHTML);
this.setAttribute('markdown', this.innerHTML);
this.innerHTML = markdown.toHTML(this.innerHTML);
}
},
accessors: {
markdown: {
set: function(params){
this.innerHTML = markdown.toHTML(params);
}
}
},
events: {
}
});
</script>
</head>
<body>
<x-markdown id="foo">
# Heading
Text
## Subheading
* One
* Two
* Three
</x-markdown>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment