nihdoc

WIP markup parser (txt -> html)
git clone git://git.alexkarle.com.com/blag
Log | Files | Refs | README | LICENSE

commit 17ed3d13e0ac6e04071f81bae2c02694351407e2 (patch)
parent 1f0e043f48b8261563d10f8d7249a78290075f30
Author: Alex Karle <alex@alexkarle.com>
Date:   Mon, 20 Dec 2021 01:03:14 -0500

Remove newlines from output in NONE blocks

If we aren't in a block-level state, newlines are just extra bits over
the wire that have no syntactic meaning!

Diffstat:
Mblag.c | 6++++--
Mtest/big.html | 15---------------
Mtest/ulist.html | 1-
3 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/blag.c b/blag.c @@ -80,7 +80,7 @@ void handle_lf(state *s) { /* single line types (one lf to close) */ if (s->in == HEADER) { s->in = NONE; - printf("</h%d>", s->hlvl); + printf("</h%d>\n", s->hlvl); } /* Guard against newlines when in parsing types */ @@ -291,7 +291,9 @@ int parse() { break; case '\n': handle_lf(&s); - putesc(c); + if (s.in != NONE) { + putesc(c); + } break; default: maybe_startp(&s); diff --git a/test/big.html b/test/big.html @@ -1,26 +1,19 @@ <h1>hello world</h1> - <p> This is an example blag file! </p> - <p> <em>This should be emphasized within a paragraph</em> </p> - <p> <strong>As should this bold</strong> </p> - <p> <code>and code!</code> </p> - <h2>Sub Header 2</h2> - <h3>Woah a third header?</h3> - <ul> <li> We can have lists?? @@ -46,13 +39,11 @@ A tier1 item </li> </ul> - <p> This is a new paragraph that wraps nicely </p> - <ol> <li> This is a numbered list @@ -70,32 +61,26 @@ yes! </li> </ol> - <p> This is a <em>paragraph</em> <strong>dangit</strong> with links to <a href="https://alexkarle.com">https://alexkarle.com</a> and my <a href="gopher://alexkarle.com">gopherhole</a>. </p> - <blockquote> this is a block quote that wraps! </blockquote> - <code><pre> $ this is a code block $ *bold* and _italics_ and `code` have no effect! $ git status </pre></code> - <p> &lt;html&gt; is escaped! </p> - <p> cheers! </p> - <p> <a href="gopher://alexkarle.com">use <code>sacc(1)</code></a> </p> diff --git a/test/ulist.html b/test/ulist.html @@ -21,7 +21,6 @@ item 2 </li> </ul> - <ul> <li> it1