ret = ret HTML(substr(line, 1, 1)); line = substr(line, 2);
continue;
- # continue walk over string
- } else {
- ret = ret substr(line, 1, 1); line = substr(line, 2);
- continue;
- }
+ } # inline patterns end
+
+ # continue walk over string
+ ret = ret substr(line, 1, 1); line = substr(line, 2);
}
return ret;
}
ret = ret _block(substr(block, 1, st - 1)) "<hr>\n"; block = substr(block, st + len);
continue;
+ } # block patterns end
+
# Plain paragraph
- } else {
- return ret "<p>" inline(block) "</p>\n";
- }
+ return ret "<p>" inline(block) "</p>\n";
}
return ret;
}
#!/bin/sh
-runtimes="gawk bawk mawk goawk"
+runtimes="gawk busybox mawk goawk"
BR='
'
awk() { /bin/awk "$@"; }
md_gawk() { gawk -f markdown.awk "$@"; }
-md_bawk() { busybox awk -f markdown.awk "$@"; }
+md_busybox() { busybox awk -f markdown.awk "$@"; }
md_mawk() { mawk -f markdown.awk "$@"; }
md_goawk() { goawk -f markdown.awk "$@"; }
assert "foo ${BR}bar" "<p>foo<br>${BR}bar</p>" 'double space line break'
assert '```©```' "<p><code>&copy;</code></p>" "code span escape"
+assert '````' "<pre><code>````</code></pre>" "empty code span"
assert '_emphasized text_' '<p><em>emphasized text</em></p>' "em"
assert '_emphasized_text_' '<p><em>emphasized_text</em></p>' "em"
but &shy; <escaped></code></pre>' \
"fenced code block"
+assert 'foobar
+````
+foobar' \
+'<p>foobar
+````
+foobar</p>' \
+"Open Fence"
+
# Block Images
assert '![Testbild](Test Bild.jpg)' \
'<figure data-src="Test Bild.jpg"><img src="Test Bild.jpg" alt="Testbild"></figure>' \