nihdoc

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

commit 8c0cdf65f6a499d14ff254d64f7ce2c79b18e228 (patch)
parent c5103ccf566da079865a0fd61943a485f50cacbd
Author: Alex Karle <alex@alexkarle.com>
Date:   Sat, 18 Dec 2021 14:07:44 -0500

Fix escaping of inline markup in code blocks

The tests are making this easy to identify -- time well spent :)

Diffstat:
Mblag.c | 6+++---
Mtest/big.html | 5+++++
Mtest/big.txt | 3+++
3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/blag.c b/blag.c @@ -214,7 +214,7 @@ int parse() { } break; case '`': - if (s.in_link == NONE) { + if (s.in_link == NONE && s.in != CODE) { if (s.in_code) { printf("</code>"); s.in_code = 0; @@ -225,7 +225,7 @@ int parse() { } break; case '*': - if (!s.in_code && s.in_link == NONE) { + if (!s.in_code && s.in_link == NONE && s.in != CODE) { if (s.in_bold) { printf("</strong>"); s.in_bold = 0; @@ -238,7 +238,7 @@ int parse() { } break; case '_': - if (!s.in_code && s.in_link == NONE) { + if (!s.in_code && s.in_link == NONE && s.in != CODE) { if (s.in_ital) { printf("</em>"); s.in_ital = 0; diff --git a/test/big.html b/test/big.html @@ -64,9 +64,14 @@ my <a href="gopher://alexkarle.com">gopherhole</a>. <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> diff --git a/test/big.txt b/test/big.txt @@ -27,6 +27,9 @@ my [gopher://alexkarle.com gopherhole]. > that wraps! $ this is a code block + $ *bold* and _italics_ and `code` have no effect! $ git status +<html> is escaped! + cheers!