adding inline code parsing + tests
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
2d792cbc97
commit
b619837af2
@ -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)
|
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
|
return line
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -116,7 +116,9 @@ declare -a tests=(
|
|||||||
"A link to [wikipedia](https://www.wikipedia.org)"
|
"A link to [wikipedia](https://www.wikipedia.org)"
|
||||||
"<p>A link to <a href=\"https://www.wikipedia.org\">wikipedia</a></p>"
|
"<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...
|
# You can add more test cases following the same format...
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user