Skip to content
A markdown renderer package for the terminal
Go Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
debug extract and add debug function to display ASTs Dec 23, 2019
fuzzing add ready to run fuzzing Dec 18, 2019
html html table rendering, better handling of ANSI code in table rendering Dec 15, 2019
misc
testdata_media
testdata_result update go-term-text to fix rendering issue over newlines Jan 3, 2020
testdata_source
.gitignore add travis config Jul 17, 2019
.travis.yml
LICENSE add license Jul 17, 2019
Readme.md
colors.go bypass the badly supported "bold off" problem Dec 17, 2019
go.mod update go-term-text to fix rendering issue over newlines Jan 3, 2020
go.sum
markdown.go extract and add debug function to display ASTs Dec 23, 2019
markdown_test.go image rendering ! Nov 23, 2019
numbering.go WIP blockquote May 26, 2019
numbering_test.go
options.go better HTML rendering with an AST walker Dec 15, 2019
renderer.go table: handle correctly TableFooter to generate a row Dec 23, 2019
renderer_test.go
shades.go wip Jun 19, 2019
tables.go
tables_test.go

Readme.md

go-term-markdown

Build Status GoDoc Go Report Card codecov GitHub license Gitter chat

go-term-markdown is a go package implementing a Markdown renderer for the terminal.

Note: Markdown being originally designed to render as HTML, rendering in a terminal is occasionally challenging and some adaptation had to be made.

Features:

  • formatting
  • lists
  • tables
  • images
  • code blocks with syntax highlighting
  • basic HTML support

Note: this renderer is packaged as a standalone terminal viewer at https://github.com/MichaelMure/mdr/

Usage

import (
	"fmt"
	"io/ioutil"

	markdown "github.com/MichaelMure/go-term-markdown"
)

func main() {
	path := "Readme.md"
	source, err := ioutil.ReadFile(path)
	if err != nil {
		panic(err)
	}

	result := markdown.Render(string(source), 80, 6)

	fmt.Println(result)
}

Example

Here is the Readme of go-term-text rendered with go-term-markdown:

rendering example

Here is an example of table rendering:

table rendering

Origin

This package has been extracted from the git-bug project. As such, its aim is to support this project and not to provide an all-in-one solution. Contributions or full-on takeover as welcome though.

Contribute

PRs accepted.

License

MIT

You can’t perform that action at this time.