pandocfilters

package
v0.0.0-...-f2a7b29 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2016 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsString

func AsString(input Any) string

func Contains

func Contains(slice List, value string) bool

func FromStdin

func FromStdin() []byte

func Load

func Load(bytes []byte) (List, string, Node)

Returns the AST, the format and the meta from the []byte input

func Save

func Save(AST Any) []byte

func Stringify

func Stringify(x Any) string

Walks the tree x and returns concatenated string content, leaving out all formatting.

func ToJSONFilter

func ToJSONFilter(action Action)

func ToJSONFilters

func ToJSONFilters(actions []Action)

Converts a list of actions <Action> into a filter that reads a JSON-formatted pandoc document from stdin, transforms it by walking the tree with the actions, and returns a new JSON-formatted pandoc document to stdout.

The argument is a list of functions of type <Action>, If the function returns None, the object to which it applies will remain unchanged. If it returns an object, the object will be replaced. If it returns a list, the list will be spliced in to the list to which the target object belongs. (So, returning an empty list deletes the object.)

func ToStdout

func ToStdout(input []byte)

Types

type Action

type Action func(key string, value Any, format string, meta Node) Any

IS KEY ALWAYS A STRING Action function type used as Filter

Key is the type of the pandoc object as string(e.g. 'Str', 'Para'), Value is the contents of the object as <Any>(e.g. a string for 'Str', a list of inline elements for 'Para', typed as <Any>), Format is the target output format as string (which will be taken for the first command line argument if present), and Meta is the document's metadata as <Node>.

type Any

type Any interface{}

func Deepcopy

func Deepcopy(input Any) Any

func GetMeta

func GetMeta(meta Node, name string) Any

Retrieves the metadata variable 'name' from the 'meta' dict.

func Reduce

func Reduce(actions []Action, AST List, format string, meta Node) Any

func Walk

func Walk(x Any, action Action, format string, meta Node) Any

Walk a tree, applying an action to every object. Returns a modified tree.

type EltFunc

type EltFunc func(...Any) Node
var (
	Plain          EltFunc
	Para           EltFunc
	CodeBlock      EltFunc
	RawBlock       EltFunc
	BlockQuote     EltFunc
	OrderedList    EltFunc
	BulletList     EltFunc
	DefinitionList EltFunc
	Header         EltFunc
	HorizontalRule EltFunc
	Table          EltFunc
	Div            EltFunc
	Null           EltFunc

	Str         EltFunc
	Emph        EltFunc
	Strong      EltFunc
	Strikeout   EltFunc
	Superscript EltFunc
	Subscript   EltFunc
	SmallCaps   EltFunc
	Quoted      EltFunc
	Cite        EltFunc
	Code        EltFunc
	Space       EltFunc
	LineBreak   EltFunc
	Math        EltFunc
	RawInline   EltFunc
	Link        EltFunc
	Image       EltFunc
	Note        EltFunc
	SoftBreak   EltFunc
	Span        EltFunc
)

type List

type List []Any

func AsList

func AsList(input Any) List

func AttributeList

func AttributeList(attributes Node) List

Returns an attribute list, constructed from the dictionary attrs.

func Empty

func Empty() List

func NewList

func NewList(args ...Any) List

func NewListUnpack

func NewListUnpack(args ...Any) List

type Node

type Node map[string]Any

func AsNode

func AsNode(input Any) Node

func NewNode

func NewNode() Node

Jump to

Keyboard shortcuts

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