adding inline code parsing + tests
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
simonpetit 2025-11-05 15:43:45 +00:00
parent 2d792cbc97
commit b619837af2
2 changed files with 10 additions and 1 deletions

View File

@ -61,6 +61,13 @@ function replaceInline(line, result, start, end) {
line = substr(line, 1, start-1) "<a href=\"" matched_url "\">" matched_link "</a>" substr(line, end+1)
}
while (match(line, /`([^*]+)`/)) {
start = RSTART
end = RSTART + RLENGTH - 1
# Build the result: before match, <code>, content, </code>, after match
line = substr(line, 1, start-1) "<code>" substr(line, start+1, RLENGTH-2) "</code>" substr(line, end+1)
}
return line
}

View File

@ -116,7 +116,9 @@ declare -a tests=(
"A link to [wikipedia](https://www.wikipedia.org)"
"<p>A link to <a href=\"https://www.wikipedia.org\">wikipedia</a></p>"
"Inline Code"
$'A tiny variable `x`'
"<p>A tiny variable <code>x</code></p>"
# You can add more test cases following the same format...
)