markdown

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: GPL-3.0 Imports: 4 Imported by: 0

README

Supported Markdown

Rules

  • Two line breaks starts a new paragraph of text.
  • Single line breaks collapse into a single line, UNLESS the previous line ended with a double space (Not my convention!)
  • Most wrapping markdown can be nested, bold within emphasis inside of a Heading, etc.

Headings

Markdown:

# Heading

Html:

Html tag output: <h1>Heading</h1>

Ansitags:

<ansi fg="md-h1" bg="md-h1-bg"><ansi fg="md-h1-prefix" bg="md-h1-prefix-bg">.:</ansi> This is a <ansi fg="md-bold" bg="md-bold-bg">HEADING</ansi></ansi>

Note: Adding additional #'s will increment the <h#> Note: Ansitags only add the prefix for h1

Horizontal Lines

Markdown:

---
===
:::

Html:

<hr />

Ansitags:

<ansi fg="md-hr1" bg="md-hr1-bg">--------------------------------------------------------------------------------</ansi>
<ansi fg="md-hr2" bg="md-hr2-bg">================================================================================</ansi>
<ansi fg="md-hr3" bg="md-hr3-bg">::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::</ansi>

Lists

Markdown:

- List Item  1
  - List Sub 1
- List Item 2
- List Item 3

Html:

<ul>
  <li>List Item  1
    <ul>
    <li>List Sub 1</li>
    </ul>
  </li>
  <li>List Item 2</li>
  <li>List Item 3</li>
</ul>

Ansitags:

<ansi fg="md-li" bg="md-li-bg">- List Item  1
  <ansi fg="md-li" bg="md-li-bg">- List Sub 1</ansi></ansi>
<ansi fg="md-li" bg="md-li-bg">- List Item 2</ansi>
<ansi fg="md-li" bg="md-li-bg">- List Item 3</ansi>

Emphasis

Markdown:

*Emphasize me*

Html:

<em>Emphasize me</em>

Ansitags:

<ansi fg="md-em" bg="md-em-bg">Emphasize me</ansi>

Bold

Markdown:

**Bold me**

Html:

<strong>Bold me</strong>

Ansitags:

<ansi fg="md-bold" bg="md-bold-bg">Bold me</ansi>

Special

Markdown:

~I'm Special~

Html:

<span data-special="1">I'm Special</span>

Ansitags:

<ansi fg="md-sp1" bg="md-sp1-bg">I'm Special</ansi>

Notes: Additional wrapping ~'s increment the number: ~~I'm Special~~, ~~~I'm Special~~~ and so on. Notes: ~~ is typically treated as a strikethrough in markdown.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetFormatter

func SetFormatter(newFormatter Formatter)

Types

type ANSITags

type ANSITags struct{}

func (ANSITags) Document

func (ANSITags) Document(contents string, depth int) string

func (ANSITags) Emphasis

func (ANSITags) Emphasis(contents string, depth int) string

func (ANSITags) HardBreak

func (ANSITags) HardBreak(contents string, depth int) string

func (ANSITags) Heading

func (ANSITags) Heading(contents string, depth int) string

func (ANSITags) HorizontalLine

func (ANSITags) HorizontalLine(contents string, depth int) string

func (ANSITags) List

func (ANSITags) List(contents string, depth int) string

func (ANSITags) ListItem

func (ANSITags) ListItem(contents string, depth int) string

func (ANSITags) Paragraph

func (ANSITags) Paragraph(contents string, depth int) string

func (ANSITags) Special

func (ANSITags) Special(contents string, depth int) string

func (ANSITags) Strong

func (ANSITags) Strong(contents string, depth int) string

func (ANSITags) Text

func (ANSITags) Text(contents string, depth int) string

type Formatter

type Formatter interface {
	Document(string, int) string
	Paragraph(string, int) string
	HorizontalLine(string, int) string
	HardBreak(string, int) string
	Heading(string, int) string
	List(string, int) string
	ListItem(string, int) string
	Text(string, int) string
	Strong(string, int) string
	Emphasis(string, int) string
	Special(string, int) string
}

type HTML

type HTML struct{}

func (HTML) Document

func (HTML) Document(contents string, depth int) string

func (HTML) Emphasis

func (HTML) Emphasis(contents string, depth int) string

func (HTML) HardBreak

func (HTML) HardBreak(contents string, depth int) string

func (HTML) Heading

func (HTML) Heading(contents string, depth int) string

func (HTML) HorizontalLine

func (HTML) HorizontalLine(contents string, depth int) string

func (HTML) List

func (HTML) List(contents string, depth int) string

func (HTML) ListItem

func (HTML) ListItem(contents string, depth int) string

func (HTML) Paragraph

func (HTML) Paragraph(contents string, depth int) string

func (HTML) Special

func (HTML) Special(contents string, depth int) string

func (HTML) Strong

func (HTML) Strong(contents string, depth int) string

func (HTML) Text

func (HTML) Text(contents string, depth int) string

type Node

type Node interface {
	Type() NodeType
	Children() []Node
	String(int) string
}

Node is an element in the AST.

type NodeType

type NodeType string

NodeType identifies the kind of AST node.

const (
	DocumentNode       NodeType = "Document"
	HeadingNode        NodeType = "Heading"
	ParagraphNode      NodeType = "Paragraph"
	HorizontalLineNode NodeType = "HorizontalLine"
	HardBreakNode      NodeType = "HardBreak"
	ListNode           NodeType = "List"
	ListItemNode       NodeType = "ListItem"
	TextNode           NodeType = "Text"
	StrongNode         NodeType = "Strong"
	EmphasisNode       NodeType = "Emphasis"
	SpecialNode        NodeType = "Special"
)

type Parser

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

func NewParser

func NewParser(input string) *Parser

func (*Parser) Parse

func (p *Parser) Parse() Node

type ReMarkdown

type ReMarkdown struct{}

func (ReMarkdown) Document

func (ReMarkdown) Document(contents string, depth int) string

func (ReMarkdown) Emphasis

func (ReMarkdown) Emphasis(contents string, depth int) string

func (ReMarkdown) HardBreak

func (ReMarkdown) HardBreak(contents string, depth int) string

func (ReMarkdown) Heading

func (ReMarkdown) Heading(contents string, depth int) string

func (ReMarkdown) HorizontalLine

func (ReMarkdown) HorizontalLine(contents string, depth int) string

func (ReMarkdown) List

func (ReMarkdown) List(contents string, depth int) string

func (ReMarkdown) ListItem

func (ReMarkdown) ListItem(contents string, depth int) string

func (ReMarkdown) Paragraph

func (ReMarkdown) Paragraph(contents string, depth int) string

func (ReMarkdown) Special

func (ReMarkdown) Special(contents string, depth int) string

func (ReMarkdown) Strong

func (ReMarkdown) Strong(contents string, depth int) string

func (ReMarkdown) Text

func (ReMarkdown) Text(contents string, depth int) string

Jump to

Keyboard shortcuts

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