Documentation
¶
Overview ¶
Author: Oleg Tolmatcev <oleg.tolmatcev@gmail.com> Copyright: (C) 2013-2017 Oleg Tolmatcev
Author: John MacFarlane <jgm@berkeley.edu> Copyright: (C) 2013 John MacFarlane License: BSD3
Functions to aid writing python scripts that process the pandoc AST serialized as JSON.
Index ¶
- func Attributes(attrs map[string]interface{}) []interface{}
- func BlockQuote(blocks []interface{}) map[string]interface{}
- func BulletList(listOfItems [][]interface{}) map[string]interface{}
- func Caps(key string, value interface{}, format string, meta interface{}) interface{}
- func Cite(citations []interface{}, inlines []interface{}) map[string]interface{}
- func Code(attrs []interface{}, str string) map[string]interface{}
- func CodeBlock(attrs []interface{}, str string) map[string]interface{}
- func DefinitionList(defList []interface{}) map[string]interface{}
- func Div(attrs []interface{}, blocks []interface{}) map[string]interface{}
- func Emph(inlines []interface{}) map[string]interface{}
- func GetCaption(kv []interface{}) ([]interface{}, string, []interface{})
- func GetExtension(format string, def string, alternates ...map[string]string) string
- func GetFilename4code(module string, content string, exts ...string) string
- func GetValue(keyvalues []interface{}, key string, values ...string) (interface{}, []interface{})
- func Header(level int, attrs []interface{}, inlines []interface{}) map[string]interface{}
- func HorizontalRule() map[string]interface{}
- func Image(attrs []interface{}, inlines []interface{}, target []string) map[string]interface{}
- func LineBreak() map[string]interface{}
- func Link(attrs []interface{}, inlines []interface{}, target []interface{}) map[string]interface{}
- func Math(mathType interface{}, str string) map[string]interface{}
- func Note(blocks []interface{}) map[string]interface{}
- func Null() map[string]interface{}
- func OrderedList(attrs []interface{}, listOfItems [][]interface{}) map[string]interface{}
- func Para(inlines []interface{}) map[string]interface{}
- func Plain(inlines []interface{}) map[string]interface{}
- func Quoted(quoteType interface{}, inlines []interface{}) map[string]interface{}
- func RawBlock(format interface{}, str string) map[string]interface{}
- func RawInline(format string, str string) map[string]interface{}
- func SmallCaps(inlines []interface{}) map[string]interface{}
- func SoftBreak() map[string]interface{}
- func Space() map[string]interface{}
- func Span(attrs []interface{}, inlines []interface{}) map[string]interface{}
- func Str(text string) map[string]interface{}
- func Strikeout(inlines []interface{}) map[string]interface{}
- func Stringify(x interface{}) string
- func Strong(inlines []interface{}) map[string]interface{}
- func Subscript(inlines []interface{}) map[string]interface{}
- func Superscript(inlines []interface{}) map[string]interface{}
- func Table(caption []interface{}, colAlign []interface{}, relColWidth []interface{}, ...) map[string]interface{}
- func ToJSONFilter(action Action)
- func ToJSONFilters(actions []Action)
- func Walk(x interface{}, action Action, format string, meta interface{}) interface{}
- type Action
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Attributes ¶
func Attributes(attrs map[string]interface{}) []interface{}
Returns an attribute list, constructed from the dictionary attrs.
func BlockQuote ¶
func BlockQuote(blocks []interface{}) map[string]interface{}
func BulletList ¶
func BulletList(listOfItems [][]interface{}) map[string]interface{}
func DefinitionList ¶
func DefinitionList(defList []interface{}) map[string]interface{}
func GetCaption ¶
func GetCaption(kv []interface{}) ([]interface{}, string, []interface{})
get caption from the keyvalues (options)
Example:
if key == 'CodeBlock': [[ident, classes, keyvals], code] = value caption, typef, keyvals = get_caption(keyvals) ... return Para([Image([ident, [], keyvals], caption, [filename, typef])])
func GetExtension ¶
get the extension for the result, needs a default and some specialisations
Example:
filetype = get_extension(format, "png", html="svg", latex="eps")
func GetFilename4code ¶
Generate filename based on content
The function ensures that the (temporary) directory exists, so that the file can be written.
Example:
filename = get_filename4code("myfilter", code)
func HorizontalRule ¶
func HorizontalRule() map[string]interface{}
func Link ¶
func Link(attrs []interface{}, inlines []interface{}, target []interface{}) map[string]interface{}
func OrderedList ¶
func OrderedList(attrs []interface{}, listOfItems [][]interface{}) map[string]interface{}
func Stringify ¶
func Stringify(x interface{}) string
Walks the tree x and returns concatenated string content, leaving out all formatting.
func Superscript ¶
func Superscript(inlines []interface{}) map[string]interface{}
func Table ¶
func Table(caption []interface{}, colAlign []interface{}, relColWidth []interface{}, colHeader []interface{}, rows [][]interface{}) map[string]interface{}
func ToJSONFilter ¶
func ToJSONFilter(action Action)
Like `toJSONFilters`, but takes a single action as argument.
func ToJSONFilters ¶
func ToJSONFilters(actions []Action)
Generate a JSON-to-JSON filter from stdin to stdout The filter: * reads a JSON-formatted pandoc document from stdin * transforms it by walking the tree and performing the actions * returns a new JSON-formatted pandoc document to stdout The argument `actions` is a list of functions of the form `action(key, value, format, meta)`, as described in more detail under `walk`. This function calls `applyJSONFilters`, with the `format` argument provided by the first command-line argument, if present. (Pandoc sets this by default when calling filters.)
func Walk ¶
Walk a tree, applying an action to every object. Returns a modified tree. An action is a function of the form `action(key, value, format, meta)`, where:
- `key` is the type of the pandoc object (e.g. 'Str', 'Para') `value` is
- the contents of the object (e.g. a string for 'Str', a list of inline elements for 'Para')
- `format` is the target output format (as supplied by the `format` argument of `walk`)
- `meta` is the document's metadata
The return of an action is either:
- `None`: this means that the object should remain unchanged
- a pandoc object: this will replace the original object
- a list of pandoc objects: these will replace the original object; the list is merged with the neighbors of the orignal objects (spliced into the list the original object belongs to); returning an empty list deletes the object