Last active
July 5, 2016 15:44
-
-
Save takahashim/150faec504955ef7b0f7 to your computer and use it in GitHub Desktop.
PEG.js用MicroMark文法
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
start = doc | |
doc = block:block+ { return "<body>"+block.join("")+"</body>"; } | |
block = headline / blankline / paragraph | |
headline = prefix:"#"+ " " textline:textline | |
{ return "<h" + prefix.length + ">" + textline + "</h" + prefix.length+">"; } | |
paragraph = textline:textline+ blankline { return "<p>" + textline.join("") +"</p>"; } | |
textline = !headline inline:inline+ "\n" { return inline.join(""); } | |
inline = char | |
char = ch:[^\n] { return ch; } | |
blankline = "\n" { return ""; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment