From 8765abd72c999a0b626bfb0e80bb9f97e3bb8329 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Thu, 23 Dec 2021 20:01:38 -0500 Subject: [PATCH] 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! --- blag.c | 7 ++++--- test/big.html | 9 +++++++++ test/big.txt | 7 +++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/blag.c b/blag.c index d092a38..7b845d6 100644 --- a/blag.c +++ b/blag.c @@ -87,9 +87,10 @@ void handle_lf(state *s) { printf("\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 index 76ee354..810bb01 100644 --- a/test/big.html +++ b/test/big.html @@ -70,3 +70,12 @@ cheers!

use sacc(1)

+

+this is a link +with a newline! +

+

+ +this is another link +with a newline! +

diff --git a/test/big.txt b/test/big.txt index 6fcbec9..0b2903c 100644 --- 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!] -- libgit2 1.1.1