Created
July 14, 2017 06:26
-
-
Save akkijp/7d4fd11e66878e516f78222fa15a5c1b to your computer and use it in GitHub Desktop.
💩 markdownパーサ
This file contains 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 | |
/ paragraph | |
headline = prefix:("#" / "##" / "###" / "####" / "#####" / "######") textline:TEXT_LINE EOS { | |
return `<h${prefix.length}>${textline}</h${prefix.length}>` | |
} | |
paragraph = textline:TEXT_LINE+ { | |
return `<p>${textline.join("<br />")}</p>` | |
} | |
TEXT_LINE = ch:[^\n]+ EOS { return ch.join(""); } | |
BLANK_LINE = [\n] | |
EOS | |
= EOL | |
/ EOF | |
EOL | |
= "\n" | |
EOF | |
= !. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment