Expand: Towards an Extensible Pandoc System

  • Jacco Krijnen
  • Doaitse Swierstra
  • Marcos O. Viera
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8324)


The Pandoc program is a versatile tool for converting between document formats. It comes with a great variety of readers, each converting a specific input format into the universal Pandoc format, and a great variety of writers, each mapping a document represented in this universal format onto a specific output format.

Unfortunately the intermediate Pandoc format is fixed, which implies that a new, unforeseen document element cannot be added. In this paper we propose a more flexible approach, using our collection of Haskell libraries for constructing extensible parsers and attribute grammars. Both the parsing and the unparsing of a specific document can be constructed out of a collection of precompiled descriptions of document elements written in Haskell. This collection can be extended by any user, without having to touch existing code.

The Haskell type system is used to enforce that each component is well defined, and to verify that the composition of a collection components is consistent, i.e. that features needed by a component have been defined by that component or any of the other components. In this way we can get back the flexibility e.g. offered by the packages in the \(\mbox{\LaTeX}\) package eco-system.


Document Formatting Pandoc Attribute Grammars Parsing Haskell Type System 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Baars, A.I., Swierstra, S.D., Viera, M.: Typed transformations of typed abstract syntax. In: TLDI 2009: Proceedings of the 4th International Workshop on Types in Language Design and Implementation, pp. 15–26. ACM, New York (2009)Google Scholar
  2. 2.
    Bravenboer, M.: Exercises in Free Syntax. Syntax Definition, Parsing, and Assimilation of Language Conglomerates. Ph.D. thesis, Utrecht University, Utrecht, The Netherlands (January 2008)Google Scholar
  3. 3.
    Hughes, J.: Generalising monads to arrows. Sci. Comput. Program. 37(1-3), 67–111 (2000)CrossRefzbMATHGoogle Scholar
  4. 4.
    Kats, L., Sloane, A., Visser, E.: Decorated attribute grammars: Attribute evaluation meets strategic programming. In: de Moor, O., Schwartzbach, M.I. (eds.) CC 2009. LNCS, vol. 5501, pp. 142–157. Springer, Heidelberg (2009), CrossRefGoogle Scholar
  5. 5.
    Kiselyov, O., Lämmel, R., Schupke, K.: Strongly typed heterogeneous collections. In: Proc. of the 2004 Workshop on Haskell, pp. 96–107. ACM Press (2004)Google Scholar
  6. 6.
    Sloane, A.M., Kats, L.C.L., Visser, E.: A pure object-oriented embedding of attribute grammars. In: Proc. of the Ninth Workshop on Language Descriptions, Tools, and Applications (March 2009)Google Scholar
  7. 7.
    Swierstra, S.D., Chitil, O.: Linear, bounded, functional pretty-printing. Journal of Functional Programming 19(01), 1–16 (2009)CrossRefzbMATHMathSciNetGoogle Scholar
  8. 8.
    Van Wyk, E., Bodin, D., Gao, J., Krishnan, L.: Silver: An extensible attribute grammar system. Sci. Comput. Program. 75(1-2), 39–54 (2010)CrossRefzbMATHGoogle Scholar
  9. 9.
    Viera, M.: First Class Syntax, Semantics and Their Composition. Ph.D. thesis, Utrecht University, Department of Information and Computing Sciences (2013)Google Scholar
  10. 10.
    Viera, M., Swierstra, S.D., Dijkstra, A.: Grammar Fragments Fly First-Class. In: Proc.of the 12th Workshop on Language Descriptions Tools and Applications, pp. 47–60 (2012)Google Scholar
  11. 11.
    Viera, M., Swierstra, S.D., Lempsink, E.: Haskell, Do You Read Me?: Constructing and composing efficient top-down parsers at runtime. In: Proc. of the First Symposium on Haskell, pp. 63–74. ACM, New York (2008)Google Scholar
  12. 12.
    Viera, M., Swierstra, S.D., Middelkoop, A.: UUAG Meets AspectAG. In: Proc. of the 12th Workshop on Language Descriptions Tools and Applications (2012)Google Scholar
  13. 13.
    Viera, M., Swierstra, S.D., Swierstra, W.: Attribute Grammars Fly First-Class: How to do aspect oriented programming in Haskell. In: Proc.of the 14th Int. Conf. on Functional Programming, pp. 245–256. ACM, New York (2009)Google Scholar

Copyright information

© Springer International Publishing Switzerland 2014

Authors and Affiliations

  • Jacco Krijnen
    • 1
  • Doaitse Swierstra
    • 1
  • Marcos O. Viera
    • 2
  1. 1.Department of Computer ScienceUtrecht UniversityUtrechtThe Netherlands
  2. 2.Instituto de ComputaciónUniversidad de la RepúblicaMontevideoUruguay

Personalised recommendations