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. | DefaultStyle
  2. | Example
  3. | Decimal
  4. | LowerRoman
  5. | UpperRoman
  6. | LowerAlpha
  7. | UpperAlpha
type list_number_delim =
  1. | DefaultDelim
  2. | Period
  3. | OneParen
  4. | TwoParensPeriod
type list_attributes = int * list_number_style * list_number_delim
type quote_type =
  1. | DoubleQuote
  2. | SingleQuote
type format = string

Format for raw blocks.

type math_type =
  1. | DisplayMath
  2. | InlineMath

Type of math element (display or inline).

type citation_mode =
  1. | AuthorInText
  2. | SuppressAuthor
  3. | NormalCitation
type alignment =
  1. | AlignLeft
  2. | AlignRight
  3. | AlignCenter
  4. | AlignDefault

Alignment of a table column.

type col_width =
  1. | ColWidth of float
  2. | ColWidthDefault

The width of a table column, as a percentage of the text width.

type col_spec = alignment * col_width

The specification for a single table column.

type row_span =
  1. | RowSpan of int

The number of rows occupied by a cell; the height of a cell.

type col_span =
  1. | ColSpan of int

The number of columns occupied by a cell; the width of a cell.

type row_head_columns =
  1. | RowHeadColumns of int

The number of columns taken up by the row head of each row of a 'TableBody'. The row body takes up the remaining columns.

type inline =
  1. | Code of attr * string
  2. | Emph of inline list
  3. | Image of attr * inline list * target
  4. | Quoted of quote_type * inline list
  5. | RawInline of string * string
  6. | Space
  7. | SmallCaps of inline list
  8. | Str of string
  9. | Underline of inline list
  10. | Strong of inline list
  11. | Strikeout of inline list
  12. | Superscript of inline list
  13. | Subscript of inline list
  14. | Cite of citation list * inline list
  15. | SoftBreak
  16. | LineBreak
  17. | Math of math_type * string
  18. | Note of block list
  19. | Span of attr * inline list
  20. | UnhandledInline of Yojson.Basic.t

Inline elements.

and block =
  1. | BulletList of block list list
  2. | CodeBlock of attr * string
  3. | Header of int * attr * inline list
  4. | OrderedList of list_attributes * block list list
  5. | Para of inline list
  6. | Plain of inline list
  7. | RawBlock of format * string
  8. | Div of attr * block list
  9. | LineBlock of inline list list
  10. | BlockQuote of block list
  11. | DefinitionList of (inline list * block list list) list
  12. | HorizontalRule
  13. | Table of attr * caption * col_spec list * table_head * table_body list * table_foot
  14. | Figure of attr * caption * block list
  15. | UnhandledBlock of Yojson.Basic.t

Block elements.

and citation =
  1. | Citation of {
    1. citation_id : string;
    2. citation_prefix : inline list;
    3. citation_suffix : inline list;
    4. citation_mode : citation_mode;
    5. citation_note_num : int;
    6. citation_hash : int;
    }
and caption =
  1. | Caption of short_caption option * block list

The caption of a table or figure, with optional short caption.

and short_caption = inline list

A short caption, for use in, for instance, lists of figures.

and cell =
  1. | Cell of attr * alignment * row_span * col_span * block list

A table cell.

and row =
  1. | Row of attr * cell list

A table row.

and table_head =
  1. | TableHead of attr * row list

The head of a table.

and table_body =
  1. | TableBody of attr * row_head_columns * row list * row list

A body of a table, with an intermediate head, intermediate body, and the specified number of row header columns in the intermediate body.

and table_foot =
  1. | TableFoot of attr * row list

The foot of a table.

type t

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.

val api_version : t -> int list

API version.

val blocks : t -> block list

Blocks.

Metadata

type meta_value =
  1. | MetaBool of bool
  2. | MetaInlines of inline list
  3. | MetaString of string
  4. | MetaMap of (string * meta_value) list
  5. | MetaList of meta_value list
  6. | MetaBlocks of block list
  7. | MetaUnhandled of Yojson.Basic.t
val meta : t -> (string * meta_value) list

Document metadata.

val meta_bool : t -> string -> bool

Value of a boolean metadata.

val meta_string : t -> string -> string

Value of a string metadata.

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.

OCaml

Innovation. Community. Security.