From b619837af21471ed9ee45f4abf1cf3c873f7c1f9 Mon Sep 17 00:00:00 2001 From: simonpetit Date: Wed, 5 Nov 2025 15:43:45 +0000 Subject: [PATCH] adding inline code parsing + tests --- lib/markdown.awk | 7 +++++++ test/parser/test_md_parser.sh | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/markdown.awk b/lib/markdown.awk index e66a068..c6802c6 100755 --- a/lib/markdown.awk +++ b/lib/markdown.awk @@ -61,6 +61,13 @@ function replaceInline(line, result, start, end) { line = substr(line, 1, start-1) "" matched_link "" substr(line, end+1) } + while (match(line, /`([^*]+)`/)) { + start = RSTART + end = RSTART + RLENGTH - 1 + # Build the result: before match, , content, , after match + line = substr(line, 1, start-1) "" substr(line, start+1, RLENGTH-2) "" substr(line, end+1) + } + return line } diff --git a/test/parser/test_md_parser.sh b/test/parser/test_md_parser.sh index 9b9a292..abb2623 100755 --- a/test/parser/test_md_parser.sh +++ b/test/parser/test_md_parser.sh @@ -116,7 +116,9 @@ declare -a tests=( "A link to [wikipedia](https://www.wikipedia.org)" "

A link to wikipedia

" - + "Inline Code" + $'A tiny variable `x`' + "

A tiny variable x

" # You can add more test cases following the same format... )