refactor farkup a bit, fix bug w/ paragraphs and code
parent
ae6e3ee47c
commit
7e5af60cbc
|
@ -135,3 +135,9 @@ link-no-follow? off
|
|||
|
||||
[ "<hr/>" ] [ "___" convert-farkup ] unit-test
|
||||
[ "<hr/>\n" ] [ "___\n" convert-farkup ] unit-test
|
||||
|
||||
[ "<p>before:\n<pre><span class='OPERATOR'>{</span> <span class='DIGIT'>1</span> <span class='DIGIT'>2</span> <span class='DIGIT'>3</span> <span class='OPERATOR'>}</span> <span class='DIGIT'>1</span> tail\n</pre></p>" ]
|
||||
[ "before:\n[factor{{ 1 2 3 } 1 tail}]" convert-farkup ] unit-test
|
||||
|
||||
[ "<a href='Factor'>Factor</a>-rific!" ]
|
||||
[ "[[Factor]]-rific" convert-farkup ] unit-test
|
||||
|
|
|
@ -40,6 +40,7 @@ EBNF: parse-farkup
|
|||
nl = ("\r\n" | "\r" | "\n") => [[ drop "\n" ]]
|
||||
2nl = nl nl
|
||||
|
||||
|
||||
heading1 = "=" (!("=" | nl).)+ "="
|
||||
=> [[ second >string heading1 boa ]]
|
||||
|
||||
|
@ -52,6 +53,10 @@ heading3 = "===" (!("=" | nl).)+ "==="
|
|||
heading4 = "====" (!("=" | nl).)+ "===="
|
||||
=> [[ second >string heading4 boa ]]
|
||||
|
||||
heading = heading4 | heading3 | heading2 | heading1
|
||||
|
||||
|
||||
|
||||
strong = "*" (!("*" | nl).)+ "*"
|
||||
=> [[ second >string strong boa ]]
|
||||
|
||||
|
@ -67,8 +72,6 @@ subscript = "~" (!("~" | nl).)+ "~"
|
|||
inline-code = "%" (!("%" | nl).)+ "%"
|
||||
=> [[ second >string inline-code boa ]]
|
||||
|
||||
escaped-char = "\" . => [[ second 1string ]]
|
||||
|
||||
link-content = (!("|"|"]").)+
|
||||
|
||||
image-link = "[[image:" link-content "|" link-content "]]"
|
||||
|
@ -84,11 +87,13 @@ labelled-link = "[[" link-content "|" link-content "]]"
|
|||
|
||||
link = image-link | labelled-link | simple-link
|
||||
|
||||
heading = heading4 | heading3 | heading2 | heading1
|
||||
escaped-char = "\" . => [[ second 1string ]]
|
||||
|
||||
inline-tag = strong | emphasis | superscript | subscript | inline-code
|
||||
| link | escaped-char
|
||||
|
||||
|
||||
|
||||
inline-delimiter = '*' | '_' | '^' | '~' | '%' | '\' | '['
|
||||
|
||||
cell = (!(inline-delimiter | '|' | nl).)+
|
||||
|
@ -104,12 +109,13 @@ table = ((table-row nl => [[ first ]] )+ table-row? | table-row)
|
|||
text = (!(nl | code | heading | inline-delimiter | table ).)+
|
||||
=> [[ >string ]]
|
||||
|
||||
paragraph-item = (table | list | text | inline-tag | inline-delimiter)+
|
||||
paragraph-item = (table | list | code | text | inline-tag | inline-delimiter)+
|
||||
paragraph = ((paragraph-item nl => [[ first ]])+ nl+ => [[ first ]]
|
||||
| (paragraph-item nl)+ paragraph-item?
|
||||
| paragraph-item)
|
||||
=> [[ paragraph boa ]]
|
||||
|
||||
|
||||
list-item = (cell | inline-tag)*
|
||||
|
||||
ordered-list-item = '#' list-item
|
||||
|
@ -124,18 +130,23 @@ unordered-list = ((unordered-list-item nl)+ unordered-list-item? | unordered-lis
|
|||
|
||||
list = ordered-list | unordered-list
|
||||
|
||||
|
||||
line = '___'
|
||||
=> [[ drop line new ]]
|
||||
|
||||
code = '[' (!('{' | nl | '[').)+ '{' (!("}]").)+ "}]"
|
||||
|
||||
named-code = '[' (!('{' | nl | '[').)+ '{' (!("}]").)+ "}]"
|
||||
=> [[ [ second >string ] [ fourth >string ] bi code boa ]]
|
||||
|
||||
simple-code
|
||||
= "[{" (!("}]").)+ "}]"
|
||||
=> [[ second f swap code boa ]]
|
||||
|
||||
code = named-code | simple-code
|
||||
|
||||
|
||||
stand-alone
|
||||
= (line | code | simple-code | heading | list | table | paragraph | nl)*
|
||||
= (line | code | heading | list | table | paragraph | nl)*
|
||||
;EBNF
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue