#107 Fantext

john Tue 22 Aug 2006

Fantext is a plain text markup syntax based on the same concepts as Markdown but with some additional fan-specific benefits. Here's the basic grammar:

<doc>        ::= {<paragraph> | <codeBlock> | <list> | <heading>}
<paragraph>  ::= <pItem> {<pItem>}<nl><nl>
<pItem>      ::= <word> | <hyperlink> | <inlineCode> | <emphasis>
<word>       ::= a-z{<notEnd> | <notSpace>}
<hyperlink>  ::= ["["<pItem> {<pItem>}"]"]"`"<uri>"`"
<inlineCode> ::= "'"<text>"'"
<emphasis>   ::= "*"<pItem> {<pItem>}"*"
<codeBlock>  ::= <codeLine>{<codeLine>}
<codeLine>   ::= <codeIndent><text><nl>
<codeIndent> ::= 2 spaces or 1 tab
<nl>         ::= \n
<text>       ::= any sequence of characters other than \n
<list>       ::= <listItem>{<listItem>}
<listItem>   ::= (<ordinal> | <bullet>) <pItem> {<pItem>}<nl>
<ordinal>    ::= <number>"."
<bullet>     ::= "-"
<heading>    ::= "#"(1-4 times) <pItem>{<pItem>}{"#"}<nl>

The goal is to have a plain text format that is readable as is but can be easily parsed, rendered, and styled for other output formats. The most common output format will be XHTML. Here are some examples with the resulting XHTML.

This is a paragraph with a couple of lines in it

<p> This is a paragraph with a couple of lines in it </p>

[This]`http://fandev.org` is a hyperlink to fandev.org.

<a href="http://fandev.org">This</a> is a hyperlink to fandev.org.

Here's some sample code:
  list := ["one", "two", "three"]
  list.each |Str s|
  {
    echo(s.upper)
  }
<p>
Here's some sample code:
</p>
<pre><code>
list := ["one", "two", "three"]
  list.each |Str s|
  {
    echo(s.upper)
  }

</code></pre>

Login or Signup to reply.