mdhero

package module
v0.0.0-...-82956d6 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: GPL-3.0 Imports: 19 Imported by: 1

README

Markdown Hero

A command line tool to work with markdown files.

Why

While markdown is great, and its great that most web sites support it, it is not so easy to render and view markdown files locally, when they contain rich content like diagrams, code blocks, and other things.

There are a number of tools that can be combined to do this, but they are not always easy to use, and they are not always available on all platforms.

This tool is designed provide the full set of required features to effectively work with markdown files.

Installation

go install github.com/bluebrown/markdown-hero/cmd/md@latest

Usage

md [-html] [-browser] <source> [<target>]
Mode

By default, the tool will render the markdown file in ANSI mode. HTML mode is enabled by the -html flag.

Depending on the mode an empty target has different semantics.

  • In ANSI mode, the target is set to -, which means write to stdout.
  • In HTML mode, the target is set to the source file with a .html extension.
Browser

If the -browser flag is set, the generated HTML file is opened in the browser. If -html is not explicitly set alongside, HTML output is assumed, but the generated file path defaults to os temporary directory, instead of following the source file name.

The browser is opened on a best effort basis, and may not work on all platforms. If the browser fails to open, the HTML file will still be created, and can be opened manually.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(source string, options ...Option) error

Types

type Engine

type Engine struct {
	Stdin  io.Reader
	Stdout io.Writer
	Title  string
	Source string
	Target string
	Flags  Flags
	Chroma string
}

func New

func New(source string, options ...Option) *Engine

func (*Engine) Run

func (ng *Engine) Run() error

type Flags

type Flags uint8
const (
	DEBUG   Flags = 1 << iota // debug mode
	HTML                      // output HTML
	BROWSER                   // open in browser
)

func (Flags) String

func (f Flags) String() string

type Option

type Option func(*Engine)

func WithChroma

func WithChroma(chroma string) Option

func WithFlags

func WithFlags(flags Flags) Option

func WithStdIO

func WithStdIO(r io.Reader, w io.Writer) Option

func WithTarget

func WithTarget(target string) Option

func WithTitle

func WithTitle(title string) Option

Directories

Path Synopsis
cmd
md command

Jump to

Keyboard shortcuts

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