package pandoc

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Library to write pandoc filters.

Types for pandoc

type attr = string * string list * (string * string) list

Attributes: identifier, classes, key/values.

type target = string * string

Target of a link: url and title.

type list_number_style =
  1. | Decimal
type list_number_delim =
  1. | Period
type list_attributes = int * list_number_style * list_number_delim
type math_type =
  1. | DisplayMath
  2. | InlineMath
type quote_type =
  1. | DoubleQuote
  2. | SingleQuote
type format = string

Format for raw blocks.

type inline =
  1. | Code of attr * string
  2. | Image of attr * inline list * target
  3. | Quoted of quote_type * inline list
  4. | RawInline of string * string
  5. | Space
  6. | Str of string
  7. | UnhandledInline of Yojson.Basic.t

Inline elements.

and block =
  1. | BulletList of block list list
  2. | CodeBlock of attr * string
  3. | OrderedList of list_attributes * block list list
  4. | Para of inline list
  5. | Plain of inline list
  6. | RawBlock of format * string
  7. | UnhandledBlock of Yojson.Basic.t

Block elements.

type t = {
  1. api_version : int list;
  2. meta : Yojson.Basic.t;
  3. blocks : block list;
}

JSON representation of a pandoc file.

Reading and writing

val of_json : Yojson.Basic.t -> t

Internal representation from JSON representation.

val to_json : t -> Yojson.Basic.t

JSON representation from internal representation.

val of_md_file : string -> t

Construct representation of a markdown file.

Mapping functions

val map : ?block:(block -> block list option) -> ?inline:(inline -> inline list option) -> t -> t

General mapping function which maps a function on blocks and a function on inlines. If the functions return None the mapping is further recursed into.

val map_inlines : (inline list -> inline list) -> t -> t

Map a function to every list of inlines.

val map_blocks : (block -> block list option) -> t -> t

Map a function to every block. If the function returns None then the block is further recursed into.

val map_top_blocks : (block -> block list) -> t -> t

Map a function to every block at toplevel.