nihdoc

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

commit b88de80277d68e8d33a863976cb065029ef259ce (patch)
parent d6eb447ca4c50e4ad9628ec9b7ed74dc513f4ee5
Author: Alex Karle <alex@alexkarle.com>
Date:   Thu, 23 Dec 2021 22:16:11 -0500

refactor: Save a few lines here and there

A couple of these are dicy in terms of better readability, but the
maybe_startp was a good find!

Diffstat:
Mblag.c | 13+++----------
1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/blag.c b/blag.c @@ -143,10 +143,7 @@ int parse() { while ((c = getchar()) != EOF) { /* Handle Escapes before all else */ if (escape) { - if (in == NONE) { - in = PARAGRAPH; - printf("<p>\n"); - } + maybe_startp(); putesc(c); escape = false; continue; @@ -257,9 +254,7 @@ int parse() { if (in == NONE || !linestarted) { ol = c != '-'; in = LIST_PARSE; - } else if (in == LIST_PARSE) { - /* no op */ - } else { + } else if (in != LIST_PARSE) { putesc(c); } break; @@ -275,9 +270,7 @@ int parse() { break; } lastc = c; - if (c != '\n') { - linestarted = true; - } + linestarted = c != '\n'; } /* pretend there's a final LF to close any blocks */ handle_lf();