Markdown.awk

Supported Features / TODO:

  • done
  • todo
  • not planned
  • ? unsure (whether to implement)
  • partial

Basic Markdown - Block elements:

  • Paragraphs

    • Double space line breaks
  • Proper block element nesting
  • Headings
  • ATX-Style Headings
  • Blockquotes
  • Lists (ordered, unordered)
  • Code blocks (using indention)
  • Horizontal rules
  • Verbatim HTML block (disabled by default)

Basic Markdown - Inline elements:

  • Links
  • Reference style links
  • Emphasis em/strong (Asterisk, Underscore)
  • code, also code containing `backticks`
  • Images / reference style images
  • <automatic links>
  • backslash escapes
  • Verbatim HTML inline (disabled by default)
  • HTML escaping

NOTE: Set the environment variable MD_HTML=true to enable verbatim HTML

Extensions - Block elements:

  • Automatic <section>-wrapping (custom)
  • ? Heading identifiers (php md, pandoc)

    • Heading attributes (custom)
  • Automatic heading identifiers (custom)
  • Fenced code blocks (php md, pandoc)

    • Fenced code attributes
  • Images (as block elements, <figure>-wrapped) (custom)

    • reference style block images
  • Tables

    • ? Simple table (pandoc)
    • ? Multiline table (pandoc)
    • Grid table (pandoc)

      • Headerless
    • Pipe table (php md, pandoc)
  • Line blocks (pandoc)
  • Task lists (pandoc, custom)
  • Definition lists (php md, pandoc)
  • Numbered example lists (pandoc)
  • Metadata blocks (pandoc)
  • Metadata blocks (custom)
  • Fenced Divs (pandoc)

Extensions - Inline elements:

  • Ignore embedded_underscores (php md, pandoc)
  • strikeout (pandoc)
  • Superscript Subscript (pandoc)
  • Bracketed spans (pandoc)

    • Inline attributes (pandoc)
  • Image attributes (custom, pandoc inspired, not for reference style)
  • Wiki style links PageName / Link Text
  • TEX-Math (pandoc)
  • ? Footnotes (php md)
  • ? Abbreviations (php md)
  • ? "Curly quotes" (smartypants)
  • em-dashes (--) (smartypants old)
  • ? ... three-dot ellipsis (smartypants)
  • en-dash (smartypants)
  • Automatic em-dash / en-dash
  • Automatic → Arrows ← (custom)

Compatibility

Markdown.awk can run in GNU awk (gawk) and in Busybox awk. It is not fully POSIX compliant and does not run in mawk or nawk. In particular it makes heavy use of the gensub() function and its ability to use paranthesized subexpressions in the replacement text. This feature is not available in the POSIX specified sub() and gsub() functions. Hence it cannot be replaced without effort.

Tests

Link with Title, emphasis, strong, strong containing emphasis, inline code, code with `backticks`. See more tests here.