Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
adf285d723 | |||
61a0348e38 |
@ -45,14 +45,6 @@ function replaceInline(line, result, start, end) {
|
||||
# Build the result: before match, <em>, content, </em>, after match
|
||||
line = substr(line, 1, start-1) "<em>" substr(line, start+1, RLENGTH-2) "</em>" substr(line, end+1)
|
||||
}
|
||||
# Replace occurrences of `...` with <code>...</code>
|
||||
while (match(line, /`([^`]+)`/)) {
|
||||
|
||||
start = RSTART
|
||||
end = RSTART + RLENGTH - 1
|
||||
# Build the result: before match, <em>, content, </em>, after match
|
||||
line = substr(line, 1, start-1) "<code>" substr(line, start+1, RLENGTH-2) "</code>" substr(line, end+1)
|
||||
}
|
||||
|
||||
# Replace occurances of [link](url) with <a href="url">link</<a>
|
||||
while (match(line, /\[([^\]]+)\]\([^\)]+\)/)) {
|
||||
@ -104,11 +96,11 @@ function closeOne() {
|
||||
env = last()
|
||||
if (env == "ul" ) {
|
||||
# In a unordered list block, print a new item
|
||||
print "<li>" substr($0, 3) "</li>"
|
||||
print "<li>" replaceInline(substr($0, 3)) "</li>"
|
||||
} else {
|
||||
# Otherwise, init the unordered list block
|
||||
push("ul")
|
||||
print "<ul>\n<li>" substr($0, 3) "</li>"
|
||||
print "<ul>\n<li>" replaceInline(substr($0, 3)) "</li>"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,9 +116,6 @@ 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 simple function \`printf()\`"
|
||||
"<p>A simple function <code>printf()</code></p>"
|
||||
|
||||
# You can add more test cases following the same format...
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user