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

后端 未结 25 1756
一个人的身影
一个人的身影 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

    Maybe this might help:

    gem install github-markdown
    

    No documentation exists, but I got it from the gollum documentation. Looking at rubydoc.info, it looks like you can use:

    require 'github/markdown'  
    puts GitHub::Markdown.render_gfm('your markdown string')
    

    in your Ruby code. You can wrap that easily in a script to turn it into a command line utility:

    #!/usr/bin/env ruby
    
    # render.rb
    require 'github/markdown'
    
    puts GitHub::Markdown.render_gfm File.read(ARGV[0])
    

    Execute it with ./render.rb path/to/my/markdown/file.md. Note that this is not safe for use in production without sanitization.

提交回复
热议问题