gh-gfm-preview

command module
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2025 License: MIT Imports: 1 Imported by: 0

README

gh gfm-preview

A Go program to preview GitHub Flavored Markdown (GFM) 📓.

The gh-gfm-preview command start a local web server to serve the markdown document. gh gfm-preview renders the HTML using yuin/goldmark and some extensions and frontend tricks to have similar features and look to how GitHub renders a markdown.

It may also be used as a GitHub CLI extension.

This is a hard fork of yusukebe/gh-markdown-preview, that uses the GitHub Markdown API, but this means it doesn't work offline. The code of this repository tries to emulate the look of GitHub Markdown rendering as close as possible, but the original project will be even closer to the actual result if you don't need offline rendering.

Features

  • Works offline - You don't need an internet connection.
  • No-dependencies - You need gh command only.
  • Zero-configuration - You don't have to set the GitHub access token.
  • Live reloading - You don't need reload the browser.
  • Auto open browser - Your browser will be opened automatically.
  • Auto find port - You don't need find an available port if default is used.

Installation

You need to have Go installed.

Standalone
go run github.com/thiagokokada/gh-gfm-preview
Nix

Assuming that you have Flakes enabled:

nix run github:thiagokokada/gh-gfm-preview
GitHub Extension
gh extension install thiagokokada/gh-gfm-preview

Upgrade:

gh extension upgrade markdown-preview

Usage

The usage:

gh gfm-preview README.md

Or this command will detect README file in the directory automatically.

gh gfm-preview

Then access the local web server such as http://localhost:3333 with Chrome, Firefox, or Safari.

Available options:

    --dark-mode           force dark mode
    --disable-auto-open   disable auto opening your browser
    --disable-reload      disable live reloading
-h, --help                help for gh-gfm-preview
    --host string         hostname this server will bind (default "localhost")
    --light-mode          force light mode
    --markdown-mode       force "markdown" mode (rather than default "gfm")
-p, --port int            TCP port number of this server (default 3333)
    --verbose             show verbose output

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL