fork(1) download
  1. BEGIN { FS = OFS = "\n"; RS = "" } # paragraph mode
  2. $1 ~ /^[#]{1,6} / {
  3. if (inlist) { inlist = 0; print "<ul>" }
  4. len = index($1, " ") - 1
  5. print "<h" len ">" substr($1,len+2) "</h" len ">"
  6. next }
  7. $1 ~ /^[-] / {
  8. if (! inlist) { inlist = 1; print "<ul>" }
  9. print "<li>" substr($1,3) "</li>"
  10. next }
  11. { if (inlist) { inlist = 0; print "</ul>" }
  12. print "<p>" $0 "</p>" }
Success #stdin #stdout 0s 4500KB
stdin
This is a text paragraph.

# Heading level 1

This is another text paragraph.

- List item 1

- List item 2

- List item 3

This is still another text paragraph.

### Heading level 3

This is the last text paragraph.
stdout
<p>This is a text paragraph.</p>
<h1>Heading level 1</h1>
<p>This is another text paragraph.</p>
<ul>
<li>List item 1</li>
<li>List item 2</li>
<li>List item 3</li>
</ul>
<p>This is still another text paragraph.</p>
<h3>Heading level 3</h3>
<p>This is the last text paragraph.</p>