• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

dmarcotte/github-markdown-preview: Local previews for Github Flavored Markdown f ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

dmarcotte/github-markdown-preview

开源软件地址(OpenSource Url):

https://github.com/dmarcotte/github-markdown-preview

开源编程语言(OpenSource Language):

Ruby 100.0%

开源软件介绍(OpenSource Introduction):

Local Github Markdown Preview

Build Status

Use your favorite editor plus the usual edit/refresh cycle to quickly write and polish your markdown for Github.

This program marries html-pipeline with the Listen file watcher to provide a high-fidelity preview (in your local browser, automatically updating on edit) of how Github will render your markdown.

sample screenshot

Installation

gem install github-markdown-preview

Usage

Generate a preview of how Github renders markdown files in a repository:

$ github-markdown-preview <path/to/markdown/file.md> # writes <path/to/markdown/file.md.html>
  • The .html preview is written beside your .md file so that you can validate relative links locally
  • The .html preview is deleted when the script exits

Comment mode

Use the -c switch to generate a preview of how Github renders comments/issues, which differs from repository markdown files in a few ways:

  • newlines are rendered as hard breaks
  • @mentions are linked to the user's home page
  • Note: auto-linked references are not rendered as links. See #17
$ github-markdown-preview -c <path/to/comment/draft.md> # writes <path/to/comment/draft.md.html>

Enable syntax highlighting for code blocks

To enable syntax highlighting for code blocks, you will need to install github-linguist:

gem install github-linguist -v 3.3.1 # 3.3.1 is required
gem install rugged -v 0.23.0 # undeclared dependency of linguist

Note that this install will fail unless your system meets the requirements needed to build its native extensions:

  • You will to either brew install icu4c or apt-get install libicu-dev
  • On Mac, you will need to have XCode installed (seems like a full install is required, not just the Command Line Tools)

Code

Here's a sample file demonstrating how to call github-markdown-preview from your own code:

require 'github-markdown-preview'

# create a preview, which writes the source_file.md.html file to disk
preview = GithubMarkdownPreview::HtmlPreview.new('source_file.md')

# you can also configure your preview with a couple of options
preview = GithubMarkdownPreview::HtmlPreview.new('source_file.md', {
    :delete_on_exit => true, # delete the preview when the program exits
    :comment_mode => true, # render using the rules for Github comments/issues
    :preview_file => 'custom_preview_file.html' # write preview to the given filename,
                                                # rather than the default 'source_file.md.html'
})

# access the preview information
preview.source_file # returns 'source_file.md'
preview.preview_file # returns 'source_file.md.html'

# explicitly update the preview file from the source
preview.update

# watch the source file and update the preview on change
preview.watch # non-blocking watch
preview.watch! # blocking watch

# add a callback to be fired on update; add multiple listeners by calling again
preview.update { puts 'Preview updated!' }

# stop watching the file (only applies to non-blocking watch method)
preview.end_watch

# delete the preview file from disk
preview.delete

Development

$ bundle install
$ rake test

Alternatively, to test with optional dependencies

$ BUNDLE_GEMFILE=Gemfile.optional bundle install
$ BUNDLE_GEMFILE=Gemfile.optional rake test

To run your development copy of the main script without installing it

$ bundle exec bin/github-markdown-preview

To install the your development copy to your system

$ rake install

Contributing

Contributions welcome!




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap