Mmark markdown output

1 minute read Published:

The latest mmark versions gained a new renderer: -markdown that outputs markdown again. You can use this to autoformat the contents in your editor.

See these two asciinema renderings, one where we format the entire file and another to reformat a table.

For VIM you can use the following config:

function! MmarkFmt ()
    let l = line(".")
    let c = col(".")
    silent !clear
    execute "%!" . "mmark -markdown"
    call cursor(l, c)

au FileType pandoc command! Fmt call MmarkFmt()
au FileType markdown command! Fmt call MmarkFmt()
let mmark = "mmark -markdown -width 100"
au FileType pandoc set formatprg=mmark
au FileType markdown set formatprg=mmark