Created
March 17, 2015 06:40
-
-
Save hayeah/108a636a8ec547dee2b9 to your computer and use it in GitHub Desktop.
extensible 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
# tags | |
A tag is a line that starts with a "#". Here a tag called foo: | |
#foo("arg1" "arg2" opt1="a" opts2="b") | |
content of foo | |
can have | |
many text blocks | |
The tag block ends on outdent. | |
As long as arguments don't contain space, the quotation marks "" can be omitted: | |
#bar(arg1 arg2 opts=a opts2b) | |
bar has the same arguments as foo | |
Tag arguments are optional: | |
#tag | |
this is a tag without argument | |
#tag() | |
this is another tag without argument | |
#tag2 | |
this is a nested tag | |
#tag3 another nested tag | |
#tag this tag has only one line of content | |
#<>#anything-up-to-space-is-tag-name#<> | |
tag name can be pretty liberal. These chars are illegal: "()`" | |
### escaping | |
\# this is a line of normal text, starting with # | |
\this is another line of normal text. | |
## heredoc | |
``` | |
any thing here is not interpreted. it ends with ` on its own line. | |
``` | |
Can combine with tag like this: | |
#tag``` | |
this is a tag with here doc | |
it should indent | |
``` | |
Give a unique HERE name: | |
#tag```HERE | |
between HERE, nothing escapes, except `HERE on its own line. | |
```HERE | |
# Inline Tag | |
There are some builtin inline tags: | |
+ *bold* text | |
+ _italic_ text | |
+ `code quote` | |
+ ``\`text quote\``` | |
For extensible tags in inline-text, we borrow markdown's link syntax and add a twist to it. A generic inline tag looks like: | |
``` | |
[tag arg1 arg2 opts1=1 opts2=2](arbitrary inline text) | |
``` | |
The inline tag's content can have inline tags nested in it: | |
``` | |
[tag](arbitrary inline text with embedded tag: [tag2](tag2 is here)) | |
``` | |
A link is like: | |
``` | |
[> http://foo.com](come visit *foo!*) | |
``` | |
An image is like: | |
``` | |
[! http://foo.com](come visit *foo!*) | |
``` | |
The "builtin" special syntax are just shortcuts: | |
+ `*bold*` is `[*](bold)` | |
+ `_bold_` is `[_](bold)` | |
# inline quote | |
Finally, text between backticks (`\``) are treated as code escape. The inline-tag syntax isn't active inside backticks. | |
Sometimes you don't want code quotes. Double backticks are escaped normal text: | |
``` | |
``[*][text]`` | |
``` | |
# AST | |
``` | |
Node | |
tag | |
children | |
args | |
opts | |
String | |
``` | |
A block of text is implicitly wrapped in a `p` node. The following two are the same: | |
``` | |
A block of text | |
that is *splitted* in 2 lines | |
#p | |
A block of text | |
that is *splitted* in 2 lines | |
``` | |
Is represented by this JSON: | |
``` | |
{ | |
tag: "p" | |
, children: [ | |
"A block of text that is" | |
, { | |
tag: "*" | |
, children: ["splitted"] | |
} | |
, "in 2 lines"]} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment