Skip to content

Instantly share code, notes, and snippets.

@takahashim
Last active July 5, 2016 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save takahashim/150faec504955ef7b0f7 to your computer and use it in GitHub Desktop.
Save takahashim/150faec504955ef7b0f7 to your computer and use it in GitHub Desktop.
PEG.js用MicroMark文法
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