Documentation
¶
Index ¶
- func Format(b Block) string
- func ToHTML(b Block) string
- func ToText(b Block) string
- type AutoLink
- type Block
- type Code
- type CodeBlock
- type Del
- type Document
- type Emoji
- type Emph
- type Empty
- type Escaped
- type Footnote
- type FootnoteLink
- type HTMLBlock
- type HTMLTag
- type HardBreak
- type Heading
- type Image
- type Inline
- type Inlines
- type Item
- type Link
- type List
- type Paragraph
- type Parser
- type Plain
- type Position
- type Quote
- type SoftBreak
- type Strong
- type Table
- type Task
- type Text
- type ThematicBreak
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AutoLink ¶
An AutoLink is an Inline representing an autolink, which is an absolute URL or email address inside < > brackets.
type Block ¶
type Block interface {
Block()
Pos() Position
// contains filtered or unexported methods
}
Block is implemented by:
CodeBlock Document Empty HTMLBlock Heading Item List Paragraph Quote Text ThematicBreak
type CodeBlock ¶
type CodeBlock struct {
Position
Fence string // fence to use
Info string // info following open fence
Text []string // lines of code block
}
A CodeBlock is a Block representing an indented code block or fenced code block, usually displayed in <pre><code> tags.
When printing a CodeBlock as Markdown, the Fence field is used as a starting hint but is made longer as needed if the suggested fence text appears in Text.
type Del ¶
A Deleted is an Inline that represents deleted (strikethrough) text, a GitHub-flavored Markdown extension.
type Emoji ¶
type Emoji struct {
Name string // emoji :name:, including colons
Text string // Unicode for emoji sequence
}
An Emoji is an Inline that represents an emoji, like :smiley:, an apparently undocumented but widely used GitHub Markdown extension.
type Empty ¶
type Empty struct {
Position
}
An Empty is a Block representing no block at all. The parser never returns a parse tree containing an Empty, but it can be useful during syntax editing. It does not render as anything at all.
type Escaped ¶
type Escaped struct {
Plain // single character text (omitting the escaping backslash)
}
An Escaped is an Inline that represents a backslash escaped symbol.
type FootnoteLink ¶
func (*FootnoteLink) Inline ¶
func (*FootnoteLink) Inline()
type HTMLBlock ¶
type HTMLBlock struct {
Position
// TODO should these be 'Text string'?
Text []string // lines, without trailing newlines
}
An HTMLBlock is a Block representing an HTML block.
type HTMLTag ¶
type HTMLTag struct {
Text string // TODO rename to HTML?
}
An HTMLTag is an Inline representing a raw HTML tag.
type HardBreak ¶
type HardBreak struct{}
A HardBreak is an Inline representing a hard line break (<br> tag).
type Heading ¶
type Heading struct {
Position
// Level is the heading level: 1 through 6.
// Other values are clamped to the valid range.
Level int
// Text is the text of the heading.
Text *Text
// ID is the HTML id attribute.
// The parser populates this field if [Parser.HeadingID] is true
// and the heading ends with text like "{#id}".
ID string
}
A Heading is a Block representing an ATX heading or Setext heading, usually displayed with the <h1> through <h6> tags.
type Inline ¶
type Inline interface {
Inline()
// contains filtered or unexported methods
}
An Inline is an inline Markdown element, one of Plain, Escaped, Code, Strong, Emph, Del, Link, AutoLink, Image, SoftBreak, HardBreak, HTMLTag, Emoji, and Task.
type Inlines ¶
type Inlines []Inline
An Inlines is an Inline that represents a concatenation of Inlines.
type List ¶
type List struct {
Position
// Bullet is the bullet character used in the list: '-', '+', or '*'.
// For an ordered list, Bullet is the character following the number: '.' or ')'.
Bullet rune
// Start is the number of the first item in an ordered list.
Start int
// Loose indicates whether the list is loose.
// (See the [List] doc comment for details.)
Loose bool
// Items is the list's items.
// TODO: Should this be []*Item or Blocks?
Items []Block // always *Item
}
A List is a Block representing a list, either an unordered (bullet) list or an ordered (numbered) list.
Lists can be loose or tight, which controls the spacing between list items. In Markdown, a list is loose when there is a blank line between any two list items, or when any list item directly contains two blocks that are separated by a blank line. (Note that because paragraphs must be separated by blank lines, any multi-paragraph item necessarily creates a loose list.) When rendering HTML, loose list items are formatted in the usual way. For tight lists, a list item consisting of a single paragraph omits the <p>...</p> tags around the paragraph text.
type Paragraph ¶
A Paragraph is a Block representing a paragraph. Except when they appear as top-level blocks in an item of a tight list, paragraphs render in <p>...</p> tags.
type Parser ¶
type Parser struct {
// HeadingID 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>
HeadingID bool
// Strikethrough determines whether the parser accepts
// ~abc~ and ~~abc~~ as strikethrough syntax, producing
// <del>abc</del> in HTML.
Strikethrough bool
// TaskList 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.
TaskList bool
// TODO
AutoLinkText bool
AutoLinkAssumeHTTP bool
// TODO
Table bool
// TODO
Emoji bool
// TODO
SmartDot bool
SmartDash bool
SmartQuote bool
// TODO
Footnote bool
}
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 Plain ¶
type Plain struct {
Text string
}
A Plain is an Inline that represents [plain textual content].
type Quote ¶
A Quote is a Block representing a block quote.
type SoftBreak ¶
type SoftBreak struct{}
A SoftBreak is an Inline representing a soft line break (newline character).
type Strong ¶
A Strong is an Inline that represents strong emphasis (bold text).
type Table ¶
type Table struct {
Position
Header []*Text // header row (slice of columns)
Align []string // alignment for columns: "left", "center", "right"; "" for unset
Rows [][]*Text // data rows (slices of columns, not necessarily all same width)
}
A Table is a Block representing a table, a GitHub-flavored Markdown extension.
type Task ¶
type Task struct {
Checked bool
}
A Task is an Inline for a task list item marker (a checkbox), a GitHub-flavored Markdown extension.
type ThematicBreak ¶
type ThematicBreak struct {
Position
}
A ThematicBreak is a Block representing a thematic break, usually displayed as a horizontal rule (<hr> tag).
func (*ThematicBreak) Block ¶
func (*ThematicBreak) Block()