goskirt

package module
v0.0.0-...-244ff76 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2012 License: MIT Imports: 3 Imported by: 0

README

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.

Example

package main

import (
	"github.com/madari/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)
}

Extensions and render modes

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

Install

go get github.com/madari/goskirt

License

For the Sundown license, see the bundled C files.

Copyright (c) 2012 Jukka-Pekka Kekkonen karatepekka@gmail.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Overview

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

Constants

View Source
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

View Source
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

View Source
const (
	HTMLRenderer = iota
	TOCRenderer
)

Renderers

View Source
const (
	Version = C.SUNDOWN_VERSION
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Goskirt

type Goskirt struct {
	Extensions, RenderModes uint
}

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

func (Goskirt) WriteHTML

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

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

Path Synopsis

Jump to

Keyboard shortcuts

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