pandoc-crossref- Pandoc filter for cross-references

CopyrightCopyright (C) 2015 Nikolay Yakimov
LicenseGNU GPL, version 2 or above
MaintainerNikolay Yakimov <>
Safe HaskellNone



Public interface to pandoc-crossref library

Example of use:

import Text.Pandoc
import Text.Pandoc.JSON

import Text.Pandoc.CrossRef

main :: IO ()
main = toJSONFilter go
    go fmt p@(Pandoc meta _) = runCrossRefIO meta fmt action p
        action (Pandoc _ bs) = do
          meta' <- crossRefMeta
          bs' <- crossRefBlocks bs
          return $ Pandoc meta' bs'

This module also exports utility functions for setting up meta-settings for pandoc-crossref. Refer to documentation for a complete list of metadata field names. All functions accept a single argument of type, returned by Text.Pandoc.Builder functions, and return Meta.


runCrossRefIO meta fmt crossRefBlocks blocks
    meta =
         figureTitle (str "Figura")
      <> tableTitle (str "Tabla")
      <> figPrefix (str "fig.")
      <> eqnPrefix (str "ec.")
      <> tblPrefix (str "tbl.")
      <> loftitle (header 1 $ text "Lista de figuras")
      <> lotTitle (header 1 $ text "Lista de tablas")
      <> chaptersDepth (MetaString "2")



crossRefBlocks :: [Block] -> CrossRefM [Block] Source

Walk over blocks, while inserting cross-references, list-of, etc.

Works in CrossRefM monad.

crossRefMeta :: CrossRefM Meta Source

Modifies metadata for LaTeX output, adding header-includes instructions to setup custom and builtin environments.

Note, that if output format is not "latex", this function does nothing.

Works in CrossRefM monad.

runCrossRef :: Walkable a b => Meta -> Maybe Format -> (a -> CrossRefM b) -> a -> b Source

Run an action in CrossRefM monad with argument, and return pure result.

This is primary function to work with CrossRefM

runCrossRefIO :: Walkable a b => Meta -> Maybe Format -> (a -> CrossRefM b) -> a -> IO b Source

Run an action in CrossRefM monad with argument, and return IO result.

This function will attempt to read pandoc-crossref settings from settings file specified by crossrefYaml metadata field.

type CrossRefM a = Reader CrossRefEnv a Source

Essentially a reader monad for basic pandoc-crossref environment

data CrossRefEnv Source

Enviromnent for CrossRefM




creSettings :: Meta

Metadata settings

creOptions :: Options

Internal pandoc-crossref options