katdown

Un traducteur md -> html minimal en awk - retour accueil

git clone git://bebou.netlib.re/katdown
Log | Files | Refs | README |

commit b76b0fd814ad7257a5429fce22770bb9989fbda7
parent a469c41b35be1593f6074b11ce98888ad2db4436
Auteurice: Graham Marlow <graham@mgmarlow.com>
Date:   Fri,  8 Mar 2024 09:42:25 -0800

Fix pre tags

Diffstat:
MREADME.md | 6++++++
Mawkdown.awk | 9++++++++-
Mdocs/index.html | 5++++-
3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md @@ -38,3 +38,9 @@ Numbered list: > Deep in the human unconscious is a pervasive need for a logical > universe that makes sense. But the real universe is always one step > beyond logic. - Frank Herbert + +## How does it work? + +paragraph one + +paragraph two diff --git a/awkdown.awk b/awkdown.awk @@ -13,7 +13,7 @@ BEGIN { /^### / { print "<h3>" substr($0, 5) "</h3>"; next } /^#### / { print "<h4>" substr($0, 6) "</h4>"; next } /^---$/ { print "<hr />"; next } -inpre && /^```/ { print "</pre>"; inpre = 0; next } +inpre && /^```/ { flush(); print "</pre>"; inpre = 0; next } /^```/ { print "<pre>"; inpre = 1; next } /^-/ { if (!inul) print "<ul>"; inul = 1; print "<li>" substr($0, 3) "</li>"; next } inul && !/^-/ { print "</ul>"; inul = 0; next } @@ -35,6 +35,13 @@ function collect(v) { sep = " " } +function flush() { + if (line) { + print line + line = sep = "" + } +} + function flushp() { if (line) { print "<p>" render(line) "</p>" diff --git a/docs/index.html b/docs/index.html @@ -13,7 +13,7 @@ awk -f awkdown.awk README.md </pre> <hr /> <h2>Demo</h2> -<p>Here's an <a href='https://www.mgmarlow.com/'>example link</a>.</p> +<p>Here's an <a href="https://www.mgmarlow.com/">example link</a>.</p> <p>How about some <em>italicized text</em>? Maybe you're <strong>feeling bold</strong> instead.</p> <h1>Header one</h1> <h2>Header two</h2> @@ -35,5 +35,8 @@ Deep in the human unconscious is a pervasive need for a logical universe that makes sense. But the real universe is always one step beyond logic. - Frank Herbert </blockquote> +<h2>How does it work?</h2> +<p>paragraph one</p> +<p>paragraph two</p> </body> </html>