nihdoc

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

commit 8765abd72c999a0b626bfb0e80bb9f97e3bb8329 (patch)
parent 3efd22a207d0f330f400d821671a55e3bc5d2041
Author: Alex Karle <alex@alexkarle.com>
Date:   Thu, 23 Dec 2021 20:01:38 -0500

Allow newlines in link parsing

Not allowing newlines in links makes it hard to use text wrapping tools
like fmt(1). I don't think there's any reason to prevent newlines in the
descriptions, so this allows it!

Diffstat:
Mblag.c | 7++++---
Mtest/big.html | 9+++++++++
Mtest/big.txt | 7+++++++
3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/blag.c b/blag.c @@ -87,9 +87,10 @@ void handle_lf(state *s) { printf("</h%d>\n", s->hlvl); } - /* Guard against newlines when in parsing types */ - if (s->in_link == URL_PARSE || s->in_link == DESC_PARSE) { - errx(1, "newline detected while processing link"); + /* terminate url parsing in links */ + if (s->in_link == URL_PARSE) { + s->in_link = DESC_PARSE; + printf("\">"); } /* multi-line types (two lf to close) */ diff --git a/test/big.html b/test/big.html @@ -70,3 +70,12 @@ cheers! <p> <a href="gopher://alexkarle.com">use <code>sacc(1)</code></a> </p> +<p> +<a href="https://example.com">this is a link +with a newline!</a> +</p> +<p> +<a href="https://example.com"> +this is another link +with a newline!</a> +</p> diff --git a/test/big.txt b/test/big.txt @@ -41,3 +41,10 @@ my [gopher://alexkarle.com gopherhole]. cheers! [gopher://alexkarle.com use `sacc(1)`] + +[https://example.com this is a link +with a newline!] + +[https://example.com +this is another link +with a newline!]