poems

package module
v0.0.0-...-6d0590d Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2019 License: MIT Imports: 7 Imported by: 0

README

goldmark-poems

GoDoc

This goldmark extension adds support for parse code blocks as poems.

var source = []byte(`# Sample

    Alas for man! day after day may rise,
      Night may shade his thankless head,
	He sees no God in the bright, morning skies
      He sings no praises from his guarded bed.
`)
md := goldmark.New(
    goldmark.WithExtensions(poems.Extension))
err := md.Convert(source, os.Stdout)
<h1>Sample</h1>
<div class="poem">Alas for man! day after day may rise,<br>
&nbsp;&nbsp;Night may shade his thankless head,<br>
He sees no God in the bright, morning skies<br>
&nbsp;&nbsp;He sings no praises from his guarded bed.</div>

Documentation

Overview

Package poems is a extension for the goldmark (http://github.com/yuin/goldmark).

This extension adds parsing code blocks in markdown document as poems.

Example
package main

import (
	"log"
	"os"

	poems "github.com/mdigger/goldmark-poems"
	"github.com/yuin/goldmark"
)

func main() {
	var source = []byte("# Sample\n\n" +
		"\tAlas for man! day after day may rise,\n" +
		"\t  Night may shade his thankless head,\n" +
		"\tHe sees no God in the bright, morning skies\n" +
		"\t  He sings no praises from his guarded bed.")
	md := goldmark.New(
		goldmark.WithExtensions(poems.Extension))
	err := md.Convert(source, os.Stdout)
	if err != nil {
		log.Fatal(err)
	}
}
Output:

<h1>Sample</h1>
<div class="poem">Alas for man! day after day may rise,<br>
&nbsp;&nbsp;Night may shade his thankless head,<br>
He sees no God in the bright, morning skies<br>
&nbsp;&nbsp;He sings no praises from his guarded bed.</div>

Index

Examples

Constants

This section is empty.

Variables

Enable is goldmark.Enable for poem code blocks extension.

View Source
var Extension goldmark.Extender = new(poemExtension)

Extension is a initialized goldmark extension for poems code block support.

View Source
var KindPoem = ast.NewNodeKind("Poem")

KindPoem is a NodeKind of the Poem node.

Functions

This section is empty.

Types

type Poem

type Poem struct {
	ast.BaseBlock
}

Poem struct represents a poem block of Markdown text.

func NewPoem

func NewPoem() *Poem

NewPoem returns a new Poem node.

func (*Poem) Dump

func (n *Poem) Dump(source []byte, level int)

Dump implements Node.Dump .

func (*Poem) Kind

func (n *Poem) Kind() ast.NodeKind

Kind implements Node.Kind.

Jump to

Keyboard shortcuts

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