
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
github-markdown-preview
Advanced tools
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.
gem install github-markdown-preview
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>
.html
preview is written beside your .md
file so that you can validate relative links locally.html
preview is deleted when the script exitsUse the -c
switch to generate a preview of how Github renders comments/issues, which differs from repository markdown files in a few ways:
@mentions
are linked to the user's home page$ github-markdown-preview -c <path/to/comment/draft.md> # writes <path/to/comment/draft.md.html>
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:
brew install icu4c
or apt-get install libicu-dev
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
$ 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
Contributions welcome!
FAQs
Unknown package
We found that github-markdown-preview demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.