func ToHTML(b Block) string
func ToMarkdown(b Block) string
type AutoLink struct {
Text string
URL string
}
func (*AutoLink) Inline()
func (x *AutoLink) PrintHTML(buf *bytes.Buffer)
func (x *AutoLink) PrintText(buf *bytes.Buffer)
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 struct {
Text string
}
func (*Code) Inline()
func (x *Code) PrintHTML(buf *bytes.Buffer)
func (x *Code) PrintText(buf *bytes.Buffer)
type CodeBlock struct {
Position
Fence string
Info string
Text []string
}
func (b *CodeBlock) PrintHTML(buf *bytes.Buffer)
type Del struct {
Marker string
Inner []Inline
}
func (x *Del) Inline()
func (x *Del) PrintHTML(buf *bytes.Buffer)
func (x *Del) PrintText(buf *bytes.Buffer)
type Document struct {
Position
Blocks []Block
Links map[string]*Link
}
func (b *Document) PrintHTML(buf *bytes.Buffer)
type Emoji struct {
Name string // emoji :name:, including colons
Text string // Unicode for emoji sequence
}
func (*Emoji) Inline()
func (x *Emoji) PrintHTML(buf *bytes.Buffer)
func (x *Emoji) PrintText(buf *bytes.Buffer)
type Emph struct {
Marker string
Inner []Inline
}
func (*Emph) Inline()
func (x *Emph) PrintHTML(buf *bytes.Buffer)
func (x *Emph) PrintText(buf *bytes.Buffer)
type Empty struct {
Position
}
func (b *Empty) PrintHTML(buf *bytes.Buffer)
type Escaped struct {
Plain
}
type HTMLBlock struct {
Position
Text []string
}
func (b *HTMLBlock) PrintHTML(buf *bytes.Buffer)
type HTMLTag struct {
Text string
}
func (*HTMLTag) Inline()
func (x *HTMLTag) PrintHTML(buf *bytes.Buffer)
func (x *HTMLTag) PrintText(buf *bytes.Buffer)
type HardBreak struct{}
func (*HardBreak) Inline()
func (x *HardBreak) PrintHTML(buf *bytes.Buffer)
func (x *HardBreak) PrintText(buf *bytes.Buffer)
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 (b *Heading) PrintHTML(buf *bytes.Buffer)
type Image struct {
Inner []Inline
URL string
Title string
TitleChar byte
// contains filtered or unexported fields
}
func (*Image) Inline()
func (x *Image) PrintHTML(buf *bytes.Buffer)
func (x *Image) PrintText(buf *bytes.Buffer)
type Inline interface {
PrintHTML(*bytes.Buffer)
PrintText(*bytes.Buffer)
// contains filtered or unexported methods
}
type Item struct {
Position
Blocks []Block
// contains filtered or unexported fields
}
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 (x *Link) PrintHTML(buf *bytes.Buffer)
func (x *Link) PrintText(buf *bytes.Buffer)
type List struct {
Position
Bullet rune
Start int
Loose bool
Items []Block // always *Item
}
func (b *List) PrintHTML(buf *bytes.Buffer)
type Paragraph struct {
Position
Text *Text
}
func (b *Paragraph) PrintHTML(buf *bytes.Buffer)
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 (p *Parser) Parse(text string) *Document
type Plain struct {
Text string
}
func (*Plain) Inline()
func (x *Plain) PrintHTML(buf *bytes.Buffer)
func (x *Plain) PrintText(buf *bytes.Buffer)
type Position struct {
StartLine int
EndLine int
}
func (p Position) Pos() Position
type Quote struct {
Position
Blocks []Block
}
func (b *Quote) PrintHTML(buf *bytes.Buffer)
type SoftBreak struct{}
func (*SoftBreak) Inline()
func (x *SoftBreak) PrintHTML(buf *bytes.Buffer)
func (x *SoftBreak) PrintText(buf *bytes.Buffer)
type Strong struct {
Marker string
Inner []Inline
}
func (x *Strong) Inline()
func (x *Strong) PrintHTML(buf *bytes.Buffer)
func (x *Strong) PrintText(buf *bytes.Buffer)
type Table struct {
Position
Header []*Text
Align []string // 'l', 'c', 'r' for left, center, right; 0 for unset
Rows [][]*Text
}
func (t *Table) PrintHTML(buf *bytes.Buffer)
type Task struct {
Checked bool
}
func (x *Task) Inline()
func (x *Task) PrintHTML(buf *bytes.Buffer)
func (x *Task) PrintText(buf *bytes.Buffer)
type Text struct {
Position
Inline []Inline
// contains filtered or unexported fields
}
func (b *Text) PrintHTML(buf *bytes.Buffer)
type ThematicBreak struct {
Position
// contains filtered or unexported fields
}
func (b *ThematicBreak) PrintHTML(buf *bytes.Buffer)