formatter

package module
v0.0.0-...-23e60f5 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2022 License: MIT Imports: 19 Imported by: 1

README

goldmark-formatter

GoDoc

This goldmark renderer extension adds support for formatting markdown.

source := []byte("# Title\nParagraph *em **bold*** [link](/).")
md := goldmark.New(
    goldmark.WithRenderer(formatter.Markdown), // markdown output
)
if err := md.Convert(source, os.Stdout); err != nil {
    log.Fatal(err)
}
Title
=====

Paragraph *em **bold*** [link](/).

Documentation

Overview

Example
package main

import (
	"log"
	"os"

	formatter "github.com/mdigger/goldmark-formatter"
)

func main() {
	source := []byte("# Title\nParagraph *em **bold*** [link](/).")
	err := formatter.Format(source, os.Stdout)
	if err != nil {
		log.Fatal(err)
	}
}
Output:

Title
=====

Paragraph _em **bold**_ [link](/).

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	SkipHTML          = false
	STXHeader         = true
	LineBreak         = false
	UseListMarker     = true
	FencedCodeBlock   = "```"
	ThematicBreak     = "----"
	EntityReplacement = map[string]string{
		"“":  `"`,
		"”":  `"`,
		"«":  `"`,
		"»":  `"`,
		"‘":  `'`,
		"’":  `'`,
		"–":  `--`,
		"—":  `---`,
		"…": `...`,
	}
	Logger = log.New(os.Stderr, "", 0)
)

Format settings

View Source
var Markdown renderer.Renderer = new(markdownRenderer)

Markdown is a markdown format renderer.

Functions

func Format

func Format(source []byte, w io.Writer, opts ...parser.ParseOption) error

Format write reformatted markdown source.

Use internal markdown parser with extensions GFM, DefinitionList, Footnote, LineBlocks, BlockAttributes and other.

func Render

func Render(w io.Writer, source []byte, node ast.Node) (err error)

Render write node as Markdown o writer.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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