less-style markdown viewer for UNIX systems

后端 未结 9 1425
刺人心
刺人心 2020-12-22 21:39

I have a Markdown string in JavaScript, and I\'d like to display it (with bolding, etc) in a less (or, I suppose, more)-style viewer for the comman

9条回答
  •  独厮守ぢ
    2020-12-22 22:13

    I wrote a couple functions based on Keith's answer:

    mdt() {
        markdown "$*" | lynx -stdin
    }
    
    mdb() {
        local TMPFILE=$(mktemp)
        markdown "$*" > $TMPFILE && ( xdg-open $TMPFILE > /dev/null 2>&1 & )
    }
    

    If you're using zsh, just place those two functions in ~/.zshrc and then call them from your terminal like

    mdt README.md
    mdb README.md
    

    "t" is for "terminal", "b" is for browser.

提交回复
热议问题