mdterm

package module
v1.0.2-0...-6557698 Latest Latest
Warning

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

Go to latest
Published: May 8, 2018 License: MIT Imports: 7 Imported by: 0

README

mdterm godoc Go Report Card

Output markdown to terminal

Usage

output := mdterm.Run(input)
fmt.Println(string(output))

With options:

output := mdterm.Run(input,
  mdterm.WithColor("magenta"),
  mdterm.WithHeadingStyle(true, 2),
)
fmt.Println(string(output))

Supported syntax

  • heading
    • sharp style
    • underline style
  • emphasis
    • bold
    • italic
    • strikethrough
  • link
    • link
    • image
  • block
    • blockquote
    • source code
      • syntax highlight
  • list
    • unordered list
    • ordered list
    • definition list
  • table
    • simple table
    • with align
    • with inline styling
    • without outer pipe

Screenshot

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(input []byte, options ...Option) []byte

Run is the main entry point to mdterm. It parses and renders a block of markdown-encoded text. See Option to change heading style or color.

output := mdterm.Run(input,
  mdterm.WithColor("magenta"),
  mdterm.WithHeadingStyle(true, 2),
)

Types

type CLIRenderer

type CLIRenderer struct {
	// contains filtered or unexported fields
}

CLIRenderer is renderer for blackfriday.

func (*CLIRenderer) Init

func (c *CLIRenderer) Init(options ...Option)

Init initializes renderer.

func (*CLIRenderer) RenderFooter

func (c *CLIRenderer) RenderFooter(w io.Writer, ast *bf.Node)

RenderFooter adds text at the foot

func (*CLIRenderer) RenderHeader

func (c *CLIRenderer) RenderHeader(w io.Writer, ast *bf.Node)

RenderHeader adds text at the head

func (*CLIRenderer) RenderNode

func (c *CLIRenderer) RenderNode(w io.Writer, node *bf.Node, entering bool) bf.WalkStatus

RenderNode renders each node to writer

type Option

type Option func(*CLIRenderer)

Option customizes the Markdown processor's default behavior.

func WithColor

func WithColor(color string) Option

WithColor sets the accent color to output to the terminal.

func WithHeadingStyle

func WithHeadingStyle(useNumber bool, underlineLevel int) Option

WithHeadingStyle sets the style of the headings. If useNumber is ture, `### heading` is displayed like this:

1.2.3 headings

If underlineLevel is not zero, h[n, n<=underlineLevel] is displayed like this:

1.2 headings
──────────────────────

func WithoutColor

func WithoutColor() Option

WithoutColor turns off all color. Renderer draws with standard color only.

Jump to

Keyboard shortcuts

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