Documentation ¶
Overview ¶
Package lineblocks is a extension for the goldmark (http://github.com/yuin/goldmark).
This extension adds support for line blocks in markdown.
A LineBlocks is a sequence of lines beginning with a vertical bar (|) followed by a space. The division into lines will be preserved in the output, as will any leading spaces; otherwise, the lines will be formatted as Markdown. This is useful for verse and addresses:
| The limerick packs laughs anatomical | In space that is quite economical. | But the good ones I've seen | So seldom are clean | And the clean ones so seldom are comical | 200 Main St. | Berkeley, CA 94718
The lines can be hard-wrapped if needed.
| The Right Honorable Most Venerable and Righteous Samuel L. Constable, Jr. | 200 Main St. | Berkeley, CA 94718
This syntax is borrowed from reStructuredText.
Example ¶
package main import ( "log" "os" lineblocks "github.com/mdigger/goldmark-lineblocks" "github.com/yuin/goldmark" ) func main() { var md = goldmark.New( lineblocks.Enable, // goldmark.WithExtensions(lineblocks.Extension), ) var source = []byte(` | The limerick packs laughs anatomical | In space that is quite economical. | But the good ones I've seen | So seldom are clean | And the clean ones so seldom are comical`) err := md.Convert(source, os.Stdout) if err != nil { log.Fatal(err) } }
Output: <div class="line-block"> <div class="line">The limerick packs laughs anatomical</div> <div class="line">In space that is quite economical.</div> <div class="line"> But the good ones I've seen</div> <div class="line"> So seldom are clean</div> <div class="line">And the clean ones so seldom are comical</div> </div>
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var Enable = goldmark.WithExtensions(Extension)
Enable is goldmark.Option for line blocks extension.
var Extension goldmark.Extender = new(defaultExtension)
Extension is a initialized goldmark extension for line blocks support.
var KindLineBlock = ast.NewNodeKind("LineBlock")
KindLineBlock is a NodeKind of the LineBlock node.
var KindLineBlockItem = ast.NewNodeKind("LineBlockItem")
KindLineBlock is a NodeKind of the LineBlock node.
var ParagraphTransformer parser.ParagraphTransformer = new(transformer)
ParagraphTransformer is a ParagraphTransformer implementation that parses and transform line blocks from paragraphs.
Functions ¶
func NewHTMLRenderer ¶
func NewHTMLRenderer(opts ...html.Option) renderer.NodeRenderer
NewHTMLRenderer returns a new sectionHTMLRenderer
Types ¶
type LineBlock ¶
A LineBlock struct represents a list of inline text block.
type LineBlockItem ¶
A LineBlockItem struct represents a list of inline text block.
func NewLineBlockItem ¶
func NewLineBlockItem(padding int) *LineBlockItem
NewLineBlockItem return new initialized LineBlockItem.
func (*LineBlockItem) Dump ¶
func (l *LineBlockItem) Dump(source []byte, level int)
Dump implements Node.Dump.