A collection of experiments with Jevko and text markup. Translating Jevko to HTML/XML.
parse
parse is a parser for the following ABNF grammar:
Value = Subvalues Suffix Subvalue = Prefix "[" Value "]" Subvalues = *Subvalue Suffix = *Char Prefix = *Char Char = Escape / %x0-5a / %x5c / %x5e-5f / %x61-10ffff Escape = "`" ("`" / "[" / "]")
which is equivalent to the Jevko grammar.
The shape of the trees returned by parse fairly closely matches the grammar, e.g.:
{
"subvalues": [
{
"prefix": "key ",
"value": {
"subvalues": [],
"suffix": "value"
}
}
],
"suffix": ""
}is the syntax tree of the string:
key [value]
astToHtml
astToHtml converts a parse tree returned by parse into HTML/XML string, effectively translating a compact Jevko-based encoding of XML to XML itself. For example the following Jevko string:
[html][
[head][
[meta /]
]
[body][
[p title[explanation] disabled][
[b][click] on this [a href[#]][link][br/]
]
]
]
can be translated to the following XML string:
<html> <head> <meta /> </head> <body> <p title="explanation" disabled> <b>click</b> on this <a href="#">link</a><br/> </p> </body> </html>
astToXml
" <