Is there a command line utility for rendering GitHub flavored Markdown?

后端 未结 25 1750
一个人的身影
一个人的身影 2020-11-28 16:53

I\'m wondering if there is a command line utility for taking a GitHub flavored Markdown file and rendering it to HTML.

I\'m using a GitHub wiki to create website con

25条回答
  •  野性不改
    2020-11-28 17:48

    This is mostly a follow-on to @barry-staes's answer for using Pandoc. Homebrew has it as well, if you're on a Mac:

    brew install pandoc
    

    Pandoc supports GFM as an input format via the markdown_github name.

    Output to file

    cat foo.md | pandoc -f markdown_github > foo.html
    

    Open in Lynx

    cat foo.md | pandoc -f markdown_github | lynx -stdin # To open in Lynx
    

    Open in the default browser on OS X

    cat foo.md | pandoc -f markdown_github > foo.html && open foo.html # To open in the default browser on OS X`
    

    TextMate Integration

    You can always pipe the current selection or current document to one of the above, as most editors allow you to do. You can also easily configure the environment so that pandoc replaces the default Markdown processor used by the Markdown bundle.

    First, create a shell script with the following contents (I'll call it ghmarkdown):

    #!/bin/bash
    # Note included, optional --email-obfuscation arg
    pandoc -f markdown_github --email-obfuscation=references
    

    You can then set the TM_MARKDOWN variable (in Preferences→Variables) to /path/to/ghmarkdown, and it will replace the default Markdown processor.

提交回复
热议问题