Re: A quick experiment with markdown

I did a little more work on it.
THE IXML

html: head, body.
head: title.
title: +"Markdown".
body: section++(-#a+).
-section: (h1; h2; h3; h4; h5; h6; p; blockquote; ol; ul; pre; hr).

h1: -"# " , text, -#a.
h2: -"## ", text, -#a.
h3: -"### ", text, -#a.
h4: -"#### ", text, -#a.
h5: -"##### ", text, -#a.
h6: -"###### ", text, -#a.
-text: c+.
-c: ~["<*_`"; #a]; embedded-html; strong; em; code.

strong: -"**", cstrong1+ , -"**";
 -"__", cstrong2+ , -"__".
em: -"*", ~["*"], cstrong1+, ~["*"], -"*".
code: -"`", ccode+, -"`".

-cstrong1: ~["*"; #a]. 
-cstrong2: ~["_"; #a]. 
-ccode: ~["`"; #a]. 
-embedded-html: "<", tag, ">", c+, "</", id, ">";
       "<", tag, "/>".
-tag: id, (s, attr)*, s?.
-id: [L]+.
-attr: id, "=", value.
-value: '"', ~['"']*, '"';
        "'", ~['"']*, "'".
-s: " "+.

p: (nonstarter, c+)++br, -#a.
br: -#a.
-nonstarter: ~["#>-*`+"; Nd; #a].
blockquote: ">", c+.
ol: (oli, -#a)+.
-oli: d+, -'. ', li.
li: c+.
-d: -[Nd].

ul: (uli, -#a)+.
-uli: -["*-+"], -" ", li.

hr: -"-"+, -#a.

pre: "$" . {to do }#

THE INPUT

# A Test

This a <b class="red">paragraph</b>.
Which extends over lines.

---

## Header 2

Another para <hr/>.

A **strong** word.

Another __strong__ word.

An *italic* word. Some `text is in code`.

1. A list
2. More
3. Yet more


* An unordered list
* And more
* Yet more


The end

THE RESULT

<html>
   <head>
      <title>Markdown</title>
   </head>
   <body>
      <h1>A Test</h1>
      <p>This a &lt;b class="red">paragraph&lt;/b>.
         <br/>Which extends over lines.</p>
      <hr/>
      <h2>Header 2</h2>
      <p>Another para &lt;hr/>.</p>
      <p>A 
         <strong>strong</strong> word.</p>
      <p>Another 
         <strong>strong</strong> word.</p>
      <p>An 
         <em>italic</em> word. Some 
         <code>text is in code</code>.</p>
      <ol>
         <li>A list</li>
         <li>More</li>
         <li>Yet more</li>
      </ol>
      <ul>
         <li>An unordered list</li>
         <li>And more</li>
         <li>Yet more</li>
      </ul>
      <p>The end</p>
   </body>
</html>

Received on Sunday, 23 October 2022 20:45:58 UTC