Created
October 13, 2014 12:56
-
-
Save ando-takahiro/179d4f5a09f22c9085d8 to your computer and use it in GitHub Desktop.
this shows how to implement a ruby feature ( http://conv.denshochan.com/markdown#ruby ). tested on node 0.10.30 & markdown-js 0.5.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Markdown = require('markdown').markdown.Markdown; | |
| var MyDialect = Markdown.subclassDialect(Markdown.dialects.Gruber); | |
| MyDialect.inline['{'] = function inline_ruby(text, matches, out) { | |
| var m = text.match(/^\{(.+)\|(.+)\}/); | |
| if (m) { | |
| return [m[0].length, ['ruby', m[2], m[1]]]; | |
| } else { | |
| // no match | |
| return [1, '{']; | |
| } | |
| }; | |
| Markdown.buildBlockOrder(MyDialect.block); | |
| Markdown.buildInlinePatterns(MyDialect.inline); | |
| var parser = new Markdown(MyDialect); | |
| console.log(parser.toTree('{hello|world}')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment