goskirt: github.com/madari/goskirt Index | Files | Directories

package goskirt

import "github.com/madari/goskirt"

Package goskirt provides Go-bindings for the excellent Sundown markdown parser (F/K/A Upskirt).

To use goskirt, create a new Goskirt-value with the markdown extensions and render modes you want. The extensions and render modes are encapsulated in the struct as bitsets following the schematics of the Sundown library. The created value contains two methods: WriteHTML and WriteTOC that both parse the data given in a byte slice and writes the formatted results into the given io.Writer using the setup encapsuled in the underlaying struct type.

Usage:

package main

import (
	"goskirt"
	"os"
)

func main() {
	data := []byte("Hello, sundown!\n===============\n")

	skirt := goskirt.Goskirt{
		goskirt.EXT_AUTOLINK | goskirt.EXT_STRIKETHROUGH,
		goskirt.HTML_SMARTYPANTS | goskirt.HTML_USE_XHTML,
	}

	// <h1>Hello, sundown!</h1>
	skirt.WriteHTML(os.Stdout, data)
}

Render mode is a combination of:

HTML_SKIP_HTML
HTML_SKIP_STYLE
HTML_SKIP_IMAGES
HTML_SKIP_LINKS
HTML_EXPAND_TABS
HTML_SAFELINK
HTML_TOC
HTML_HARD_WRAP
HTML_USE_XHTML
HTML_ESCAPE
HTML_SMARTYPANTS

... and the extensions respectively:

EXT_NO_INTRA_EMPHASIS
EXT_TABLES
EXT_FENCED_CODE
EXT_AUTOLINK
EXT_STRIKETHROUGH
EXT_SPACE_HEADERS
EXT_SUPERSCRIPT
EXT_LAX_SPACING

See LICENSE file for licensing details.

Index

Package Files

doc.go goskirt.go

Constants

const (
    EXT_NO_INTRA_EMPHASIS = C.MKDEXT_NO_INTRA_EMPHASIS
    EXT_TABLES            = C.MKDEXT_TABLES
    EXT_FENCED_CODE       = C.MKDEXT_FENCED_CODE
    EXT_AUTOLINK          = C.MKDEXT_AUTOLINK
    EXT_STRIKETHROUGH     = C.MKDEXT_STRIKETHROUGH
    EXT_SPACE_HEADERS     = C.MKDEXT_SPACE_HEADERS
    EXT_SUPERSCRIPT       = C.MKDEXT_SUPERSCRIPT
    EXT_LAX_SPACING       = C.MKDEXT_LAX_SPACING
)

Markdown extensions

const (
    HTML_SKIP_HTML   = C.HTML_SKIP_HTML // 1 << 0
    HTML_SKIP_STYLE  = C.HTML_SKIP_STYLE
    HTML_SKIP_IMAGES = C.HTML_SKIP_IMAGES
    HTML_SKIP_LINKS  = C.HTML_SKIP_LINKS
    HTML_EXPAND_TABS = C.HTML_EXPAND_TABS
    HTML_SAFELINK    = C.HTML_SAFELINK
    HTML_TOC         = C.HTML_TOC
    HTML_HARD_WRAP   = C.HTML_HARD_WRAP
    HTML_USE_XHTML   = C.HTML_USE_XHTML
    HTML_ESCAPE      = C.HTML_ESCAPE    // 1 << 9
    HTML_SMARTYPANTS = HTML_ESCAPE << 1 // 1 << 10
)

Render modes

const (
    HTMLRenderer = iota
    TOCRenderer
)

Renderers

const (
    Version = C.SUNDOWN_VERSION
)

type Goskirt Uses

type Goskirt struct {
    Extensions, RenderModes uint
}

An Goskirt represents a combination of rendering modes and enabled markdown extensions.

func (Goskirt) WriteHTML Uses

func (g Goskirt) WriteHTML(w io.Writer, p []byte) (n int, err error)

WriteHTML renders HTML into w using the source markdown-data p. It returns the number of bytes written or and error if writing failed.

func (Goskirt) WriteTOC Uses

func (g Goskirt) WriteTOC(w io.Writer, p []byte) (n int, err error)

WriteTOC renders a list table of contents into w using the source markdown-data p It returns the number of bytes written or and error if writing failed.

Directories

PathSynopsis
goskirt

Package goskirt imports 3 packages (graph) and is imported by 2 packages. Updated 2016-07-20. Refresh now. Tools for package owners.