Re: A quick experiment with markdown

More work.
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), -#a.

h1: -"# ", ~["#"], ~["#"], ~["#"], ~["#"], ~["#"], text.
h2: -"## ", ~["#"], ~["#"], ~["#"], ~["#"], text.
h3: -"### ", ~["#"], ~["#"], ~["#"], text.
h4: -"#### ", ~["#"], ~["#"], text.
h5: -"##### ", ~["#"], text.
h6: -"###### ", text.
-text: c+.
-c: ~["<"; #a]; embedded-html.

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

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

ul: "@" . {todo}

hr: -"-"+.

pre: "$" . {to do }#


THE MARKDOWN


# A Test

This a <b class="red">paragraph</b>.

---

## Header 2

Another para <hr/>.

1. A list
2. More
3. 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>.</p>
       <hr/>
       <h2>Header 2</h2>
       <p>Another para &lt;hr/>.</p>
       <ol>
          <li>A list</li>
          <li>More</li>
          <li>Yet more</li>
       </ol>
       <p>The end</p>
    </body>
</html>


On Monday 01 August 2022 21:32:19 (+02:00), Steven Pemberton wrote:

 > Following on from this [evening]'s discussion about parsing markdown, 
here is a quick incomplete try with embedded html
 > THE IXML
 >
 > markdown: (section, #a)+.
 > -section: (h1; h2; h3; h4; h5; h6; p; blockquote; ol; ul; pre; hr), #a.
 >
 > h1: -"#", ~["#"], ~["#"], ~["#"], ~["#"], ~["#"], text.
 > h2: -"##", ~["#"], ~["#"], ~["#"], ~["#"], text.
 > h3: -"###", ~["#"], ~["#"], ~["#"], text.
 > h4: -"####", ~["#"], ~["#"], text.
 > h5: -"#####", ~["#"], text.
 > h6: -"######", text.
 > -text: c+.
 > -c: ~["<"; #a]; html.
 >
 > -html: "<", tag, ">", c+, "</", id, ">".
 > -tag: id, (s, attr)*, s?.
 > -id: [L]+.
 > -attr: id, "=", value.
 > -value: '"', ~['"']*, '"';
 > "'", ~['"']*, "'".
 > -s: " "+.
 >
 > p: nonstarter, c+.
 > -nonstarter: ~["#>-"; Nd].
 >
 > blockquote: ">", c+.
 > ol: li+.
 > li: d+, '.', c+.
 > -d: [Nd].
 >
 > ul: "@" . {todo}
 >
 > hr: -"-"+.
 >
 > pre: "$" . {to do }#
 >
 > THE MARKDOWN
 >
 > # A Test
 >
 > This a <b class="red">paragraph</b>.
 >
 > ---
 >
 > ## Header 2
 >
 > THE OUTPUT
 >
 > <markdown>
 > <h1> A Test</h1>
 >
 >
 > <p>This a &lt;b class="red">paragraph&lt;/b>.</p>
 >
 >
 > <hr/>
 >
 >
 > <h2> Header 2</h2>
 >
 > </markdown>
 >
 > END
 >
 >

Received on Tuesday, 2 August 2022 14:35:45 UTC