...

Package markdown

import "cmd/vendor/rsc.io/markdown"
Overview
Index

Overview ▾

Index ▾

func ToHTML(b Block) string
func ToMarkdown(b Block) string
type AutoLink
    func (*AutoLink) Inline()
    func (x *AutoLink) PrintHTML(buf *bytes.Buffer)
    func (x *AutoLink) PrintText(buf *bytes.Buffer)
type Block
type Code
    func (*Code) Inline()
    func (x *Code) PrintHTML(buf *bytes.Buffer)
    func (x *Code) PrintText(buf *bytes.Buffer)
type CodeBlock
    func (b *CodeBlock) PrintHTML(buf *bytes.Buffer)
type Del
    func (x *Del) Inline()
    func (x *Del) PrintHTML(buf *bytes.Buffer)
    func (x *Del) PrintText(buf *bytes.Buffer)
type Document
    func (b *Document) PrintHTML(buf *bytes.Buffer)
type Emoji
    func (*Emoji) Inline()
    func (x *Emoji) PrintHTML(buf *bytes.Buffer)
    func (x *Emoji) PrintText(buf *bytes.Buffer)
type Emph
    func (*Emph) Inline()
    func (x *Emph) PrintHTML(buf *bytes.Buffer)
    func (x *Emph) PrintText(buf *bytes.Buffer)
type Empty
    func (b *Empty) PrintHTML(buf *bytes.Buffer)
type Escaped
type HTMLBlock
    func (b *HTMLBlock) PrintHTML(buf *bytes.Buffer)
type HTMLTag
    func (*HTMLTag) Inline()
    func (x *HTMLTag) PrintHTML(buf *bytes.Buffer)
    func (x *HTMLTag) PrintText(buf *bytes.Buffer)
type HardBreak
    func (*HardBreak) Inline()
    func (x *HardBreak) PrintHTML(buf *bytes.Buffer)
    func (x *HardBreak) PrintText(buf *bytes.Buffer)
type Heading
    func (b *Heading) PrintHTML(buf *bytes.Buffer)
type Image
    func (*Image) Inline()
    func (x *Image) PrintHTML(buf *bytes.Buffer)
    func (x *Image) PrintText(buf *bytes.Buffer)
type Inline
type Item
    func (b *Item) PrintHTML(buf *bytes.Buffer)
type Link
    func (*Link) Inline()
    func (x *Link) PrintHTML(buf *bytes.Buffer)
    func (x *Link) PrintText(buf *bytes.Buffer)
type List
    func (b *List) PrintHTML(buf *bytes.Buffer)
type Paragraph
    func (b *Paragraph) PrintHTML(buf *bytes.Buffer)
type Parser
    func (p *Parser) Parse(text string) *Document
type Plain
    func (*Plain) Inline()
    func (x *Plain) PrintHTML(buf *bytes.Buffer)
    func (x *Plain) PrintText(buf *bytes.Buffer)
type Position
    func (p Position) Pos() Position
type Quote
    func (b *Quote) PrintHTML(buf *bytes.Buffer)
type SoftBreak
    func (*SoftBreak) Inline()
    func (x *SoftBreak) PrintHTML(buf *bytes.Buffer)
    func (x *SoftBreak) PrintText(buf *bytes.Buffer)
type Strong
    func (x *Strong) Inline()
    func (x *Strong) PrintHTML(buf *bytes.Buffer)
    func (x *Strong) PrintText(buf *bytes.Buffer)
type Table
    func (t *Table) PrintHTML(buf *bytes.Buffer)
type Task
    func (x *Task) Inline()
    func (x *Task) PrintHTML(buf *bytes.Buffer)
    func (x *Task) PrintText(buf *bytes.Buffer)
type Text
    func (b *Text) PrintHTML(buf *bytes.Buffer)
type ThematicBreak
    func (b *ThematicBreak) PrintHTML(buf *bytes.Buffer)

Package files

break.go code.go emoji.go entity.go heading.go html.go inline.go link.go list.go para.go parse.go quote.go table.go tables.go

func ToHTML

func ToHTML(b Block) string

func ToMarkdown

func ToMarkdown(b Block) string
type AutoLink struct {
    Text string
    URL  string
}

func (*AutoLink) Inline

func (*AutoLink) Inline()

func (*AutoLink) PrintHTML

func (x *AutoLink) PrintHTML(buf *bytes.Buffer)

func (*AutoLink) PrintText

func (x *AutoLink) PrintText(buf *bytes.Buffer)

type Block

Block is implemented by:

CodeBLock
Document
Empty
HTMLBlock
Heading
Item
List
Paragraph
Quote
Text
ThematicBreak
type Block interface {
    Pos() Position
    PrintHTML(buf *bytes.Buffer)
    // contains filtered or unexported methods
}

type Code

type Code struct {
    Text string
}

func (*Code) Inline

func (*Code) Inline()

func (*Code) PrintHTML

func (x *Code) PrintHTML(buf *bytes.Buffer)

func (*Code) PrintText

func (x *Code) PrintText(buf *bytes.Buffer)

type CodeBlock

type CodeBlock struct {
    Position
    Fence string
    Info  string
    Text  []string
}

func (*CodeBlock) PrintHTML

func (b *CodeBlock) PrintHTML(buf *bytes.Buffer)

type Del

type Del struct {
    Marker string
    Inner  []Inline
}

func (*Del) Inline

func (x *Del) Inline()

func (*Del) PrintHTML

func (x *Del) PrintHTML(buf *bytes.Buffer)

func (*Del) PrintText

func (x *Del) PrintText(buf *bytes.Buffer)

type Document

type Document struct {
    Position
    Blocks []Block
    Links  map[string]*Link
}

func (*Document) PrintHTML

func (b *Document) PrintHTML(buf *bytes.Buffer)

type Emoji

type Emoji struct {
    Name string // emoji :name:, including colons
    Text string // Unicode for emoji sequence
}

func (*Emoji) Inline

func (*Emoji) Inline()

func (*Emoji) PrintHTML

func (x *Emoji) PrintHTML(buf *bytes.Buffer)

func (*Emoji) PrintText

func (x *Emoji) PrintText(buf *bytes.Buffer)

type Emph

type Emph struct {
    Marker string
    Inner  []Inline
}

func (*Emph) Inline

func (*Emph) Inline()

func (*Emph) PrintHTML

func (x *Emph) PrintHTML(buf *bytes.Buffer)

func (*Emph) PrintText

func (x *Emph) PrintText(buf *bytes.Buffer)

type Empty

type Empty struct {
    Position
}

func (*Empty) PrintHTML

func (b *Empty) PrintHTML(buf *bytes.Buffer)

type Escaped

type Escaped struct {
    Plain
}

type HTMLBlock

type HTMLBlock struct {
    Position
    Text []string
}

func (*HTMLBlock) PrintHTML

func (b *HTMLBlock) PrintHTML(buf *bytes.Buffer)

type HTMLTag

type HTMLTag struct {
    Text string
}

func (*HTMLTag) Inline

func (*HTMLTag) Inline()

func (*HTMLTag) PrintHTML

func (x *HTMLTag) PrintHTML(buf *bytes.Buffer)

func (*HTMLTag) PrintText

func (x *HTMLTag) PrintText(buf *bytes.Buffer)

type HardBreak

type HardBreak struct{}

func (*HardBreak) Inline

func (*HardBreak) Inline()

func (*HardBreak) PrintHTML

func (x *HardBreak) PrintHTML(buf *bytes.Buffer)

func (*HardBreak) PrintText

func (x *HardBreak) PrintText(buf *bytes.Buffer)

type Heading

type Heading struct {
    Position
    Level int
    Text  *Text
    // The HTML id attribute. The parser populates this field if
    // [Parser.HeadingIDs] is true and the heading ends with text like "{#id}".
    ID string
}

func (*Heading) PrintHTML

func (b *Heading) PrintHTML(buf *bytes.Buffer)

type Image

type Image struct {
    Inner     []Inline
    URL       string
    Title     string
    TitleChar byte
    // contains filtered or unexported fields
}

func (*Image) Inline

func (*Image) Inline()

func (*Image) PrintHTML

func (x *Image) PrintHTML(buf *bytes.Buffer)

func (*Image) PrintText

func (x *Image) PrintText(buf *bytes.Buffer)

type Inline

type Inline interface {
    PrintHTML(*bytes.Buffer)
    PrintText(*bytes.Buffer)
    // contains filtered or unexported methods
}

type Item

type Item struct {
    Position
    Blocks []Block
    // contains filtered or unexported fields
}

func (*Item) PrintHTML

func (b *Item) PrintHTML(buf *bytes.Buffer)
type Link struct {
    Inner     []Inline
    URL       string
    Title     string
    TitleChar byte // ', " or )
    // contains filtered or unexported fields
}

func (*Link) Inline

func (*Link) Inline()

func (*Link) PrintHTML

func (x *Link) PrintHTML(buf *bytes.Buffer)

func (*Link) PrintText

func (x *Link) PrintText(buf *bytes.Buffer)

type List

type List struct {
    Position
    Bullet rune
    Start  int
    Loose  bool
    Items  []Block // always *Item
}

func (*List) PrintHTML

func (b *List) PrintHTML(buf *bytes.Buffer)

type Paragraph

type Paragraph struct {
    Position
    Text *Text
}

func (*Paragraph) PrintHTML

func (b *Paragraph) PrintHTML(buf *bytes.Buffer)

type Parser

A Parser is a Markdown parser. The exported fields in the struct can be filled in before calling Parser.Parse in order to customize the details of the parsing process. A Parser is safe for concurrent use by multiple goroutines.

type Parser struct {
    // HeadingIDs determines whether the parser accepts
    // the {#hdr} syntax for an HTML id="hdr" attribute on headings.
    // For example, if HeadingIDs is true then the Markdown
    //    ## Overview {#overview}
    // will render as the HTML
    //    <h2 id="overview">Overview</h2>
    HeadingIDs bool

    // Strikethrough determines whether the parser accepts
    // ~abc~ and ~~abc~~ as strikethrough syntax, producing
    // <del>abc</del> in HTML.
    Strikethrough bool

    // TaskListItems determines whether the parser accepts
    // “task list items” as defined in GitHub Flavored Markdown.
    // When a list item begins with the plain text [ ] or [x]
    // that turns into an unchecked or checked check box.
    TaskListItems bool

    // TODO
    AutoLinkText       bool
    AutoLinkAssumeHTTP bool

    // TODO
    Table bool

    // TODO
    Emoji bool

    // TODO
    SmartDot   bool
    SmartDash  bool
    SmartQuote bool
}

func (*Parser) Parse

func (p *Parser) Parse(text string) *Document

type Plain

type Plain struct {
    Text string
}

func (*Plain) Inline

func (*Plain) Inline()

func (*Plain) PrintHTML

func (x *Plain) PrintHTML(buf *bytes.Buffer)

func (*Plain) PrintText

func (x *Plain) PrintText(buf *bytes.Buffer)

type Position

type Position struct {
    StartLine int
    EndLine   int
}

func (Position) Pos

func (p Position) Pos() Position

type Quote

type Quote struct {
    Position
    Blocks []Block
}

func (*Quote) PrintHTML

func (b *Quote) PrintHTML(buf *bytes.Buffer)

type SoftBreak

type SoftBreak struct{}

func (*SoftBreak) Inline

func (*SoftBreak) Inline()

func (*SoftBreak) PrintHTML

func (x *SoftBreak) PrintHTML(buf *bytes.Buffer)

func (*SoftBreak) PrintText

func (x *SoftBreak) PrintText(buf *bytes.Buffer)

type Strong

type Strong struct {
    Marker string
    Inner  []Inline
}

func (*Strong) Inline

func (x *Strong) Inline()

func (*Strong) PrintHTML

func (x *Strong) PrintHTML(buf *bytes.Buffer)

func (*Strong) PrintText

func (x *Strong) PrintText(buf *bytes.Buffer)

type Table

type Table struct {
    Position
    Header []*Text
    Align  []string // 'l', 'c', 'r' for left, center, right; 0 for unset
    Rows   [][]*Text
}

func (*Table) PrintHTML

func (t *Table) PrintHTML(buf *bytes.Buffer)

type Task

type Task struct {
    Checked bool
}

func (*Task) Inline

func (x *Task) Inline()

func (*Task) PrintHTML

func (x *Task) PrintHTML(buf *bytes.Buffer)

func (*Task) PrintText

func (x *Task) PrintText(buf *bytes.Buffer)

type Text

type Text struct {
    Position
    Inline []Inline
    // contains filtered or unexported fields
}

func (*Text) PrintHTML

func (b *Text) PrintHTML(buf *bytes.Buffer)

type ThematicBreak

type ThematicBreak struct {
    Position
    // contains filtered or unexported fields
}

func (*ThematicBreak) PrintHTML

func (b *ThematicBreak) PrintHTML(buf *bytes.Buffer)