From 17ed3d13e0ac6e04071f81bae2c02694351407e2 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Mon, 20 Dec 2021 01:03:14 -0500 Subject: [PATCH] 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! --- blag.c | 6 ++++-- test/big.html | 15 --------------- test/ulist.html | 1 - 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/blag.c b/blag.c index baab51b..48a8194 100644 --- 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("", s->hlvl); + printf("\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 index fcd2182..4cf19ae 100644 --- a/test/big.html +++ b/test/big.html @@ -1,26 +1,19 @@

hello world

-

This is an example blag file!

-

This should be emphasized within a paragraph

-

As should this bold

-

and code!

-

Sub Header 2

-

Woah a third header?

- -

This is a new paragraph that wraps nicely

-
  1. This is a numbered list @@ -70,32 +61,26 @@ yes!
-

This is a paragraph dangit with links to https://alexkarle.com and my gopherhole.

-
this is a block quote that wraps!
-
 $ this is a code block
 $ *bold* and _italics_ and `code` have no effect!
 $ git status
 
-

<html> is escaped!

-

cheers!

-

use sacc(1)

diff --git a/test/ulist.html b/test/ulist.html index aec9620..adbafd6 100644 --- a/test/ulist.html +++ b/test/ulist.html @@ -21,7 +21,6 @@ item 2 -