Learn sed(1) by rendering Markdown to HTML
(And also by reading the O'Reilly sed & awk book)
sed -f md2html.sed test.md
diff -B <(sed -f md2html.sed test.md) test.html
diff <(sed -f md2html.sed test.md) <(gsed -f md2html.sed test.md)
sed -f md2html.sed README.md
- Make sure the script tests successfully, before changing it
- Add or modify Markdown in
test.md
- Add or modify corresponding HTML in
test.html
- Add or modify commands to render Markdown to HTML in
md2html.sed
- Update README.md, if it's no longer correct
- Make sure the script tests successfully, after changing it
md2html.sed
supports a small subset of Markdown features. See
test.md
for the current list.
Kindly share your feedback in a pull request or an issue 🙇
In Markdown, use blank lines between different formats and layouts.
When script begins or ends, hold space contains all pending output.
- If pattern space is blank then swap hold to pattern and jump to :close
- If pattern begins with ``` then start or end a pre
- If hold space contains a pre tag then jump to :save
- Render links
- Render headings
- Render trailing spaces line breaks
- Render ordered lists
- Render unordered lists
- [:save] If pattern is not blank, append to hold and swap
- If not last line, swap pattern to hold and end
- [:close] If pattern is blank, delete and continue
- If pattern does not begin with <, render as p
- Close some opening tags: ol, ul, pre
- Render inline formatting: ` _ *
- Clear hold space