#WORK
#WORK

_library/index-include.md.cms

_library/sitemap-include.md.cms

Introduction

If you need to render a format not already handled by pandoc, or you want to change how pandoc renders a format, you can create a custom writer using the Lua language. Pandoc has a built-in Lua interpreter, so you needn’t install any additional software to do this.

A custom writer is a Lua file that defines how to render the document. Two styles of custom writers are supported: classic custom writers must define rendering functions for each AST element. New style writers, available since pandoc 2.17.2, must define just a single function Writer, which gets passed the document and writer options, and then does all rendering.

Classic style

A writer using the classic style defines rendering functions for each element of the pandoc AST.

For example,

function Para(s)
  return "<paragraph>" .. s .. "</paragraph>"
end

The best way to go about creating a classic custom writer is to modify the example that comes with pandoc. To get the example, you can do

pandoc --print-default-data-file sample.lua > sample.lua

[…]

(permalink to full text)

Introduction

If you need to parse a format not already handled by pandoc, you can create a custom reader using the Lua language. Pandoc has a built-in Lua interpreter, so you needn’t install any additional software to do this.

A custom reader is a Lua file that defines a function called Reader, which takes two arguments:

  • the raw input to be parsed, as a list of sources
  • optionally, a table of reader options, e.g. { columns = 62, standalone = true }.

The Reader function should return a Pandoc AST. This can be created using functions in the pandoc module, which is automatically in scope. (Indeed, all of the utility functions that are available for Lua filters are available in custom readers, too.)

Each source item corresponds to a file or stream passed to pandoc containing its text and name. E.g., if a single file input.txt is passed to pandoc, then the list of sources will contain just a single element s, where s.name == 'input.txt' and s.text contains the file contents as a string.

[…]

(permalink to full text)

Introduction

Pandoc has long supported filters, which allow the pandoc abstract syntax tree (AST) to be manipulated between the parsing and the writing phase. Traditional pandoc filters accept a JSON representation of the pandoc AST and produce an altered JSON representation of the AST. They may be written in any programming language, and invoked from pandoc using the --filter option.

Although traditional filters are very flexible, they have a couple of disadvantages. First, there is some overhead in writing JSON to stdout and reading it from stdin (twice, once on each side of the filter). Second, whether a filter will work will depend on details of the user’s environment. A filter may require an interpreter for a certain programming language to be available, as well as a library for manipulating the pandoc AST in JSON form. One cannot simply provide a filter that can be used by anyone who has a certain version of the pandoc executable.

Starting with version 2.0, pandoc makes it possible to write filters in Lua without any external dependencies at all. A Lua interpreter (version 5.3) and a Lua library for creating pandoc filters is built into the pandoc executable. Pandoc data types are marshaled to Lua directly, avoiding the overhead of writing JSON to stdout and reading it from stdin.

[…]

(permalink to full text)

Synopsis

pandoc [options] [input-file]…

Description

Pandoc is a Haskell library for converting from one markup format to another, and a command-line tool that uses this library.

Pandoc can convert between numerous markup and word processing formats, including, but not limited to, various flavors of Markdown, HTML, LaTeX and Word docx. For the full lists of input and output formats, see the --from and --to options below. Pandoc can also produce PDF output: see creating a PDF, below.

Pandoc’s enhanced version of Markdown includes syntax for tables, definition lists, metadata blocks, footnotes, citations, math, and much more. See below under Pandoc’s Markdown.

[…]

(permalink to full text)

Starting with version 1.6, pandoc can produce output in the EPUB electronic book format. EPUB books can be viewed on iPads, Nooks, and other electronic book readers, including many smart phones. (They can also be converted to Kindle books using the GUI only KindlePreviewer on Windows and Mac OSX. KindleGen – which offers a command line interface and supports Linux, Mac OSX and Windows – has been deprecated, but binaries can still be found on the internet.)

This means that it’s now very easy to produce an electronic book! Let’s try it.

A toy example

Use your text editor to create a file mybook.txt, with the following contents:

% My Book
% Sam Smith

This is my book!

# Chapter One

Chapter one is over.

# Chapter Two

Chapter two has just begun.

[…]

(permalink to full text)

This document provides a quick overview over the various ways to customize pandoc’s output, with links to fuller documentation and some examples.

Templates

When the -s/--standalone option is used, pandoc will generate a standalone document rather than a fragment. For example, in HTML output this will include the <head> element; in LaTeX output, it will include the preamble.

Pandoc comes with a default template for (almost) every output format. A template is a plain text file containing variables that are replaced by text generated by pandoc. For example, the variable $body$ will be replaced by the document body, and $title$ by the title from metadata.

To look at the default template for an output format, you can do pandoc -D FORMAT, where FORMAT is replaced by the name of the format. For example pandoc -D latex. You can also use your own template instead, either by using the --template option or by putting the custom template in your user data directory (on Linux and macOS, ~/.pandoc/templates/).

[…]

(permalink to full text)

This document is for people who are unfamiliar with command line tools. Command-line experts can go straight to the User’s Guide or the pandoc man page.

Step 1: Install pandoc

First, install pandoc, following the instructions for your platform.

Step 2: Open a terminal

Pandoc is a command-line tool. There is no graphic user interface. So, to use it, you’ll need to open a terminal window:

  • On OS X, the Terminal application can be found in /Applications/Utilities. Open a Finder window and go to Applications, then Utilities. Then double click on Terminal. (Or, click the spotlight icon in the upper right hand corner of your screen and type Terminal – you should see Terminal under Applications.)

  • On Windows, you can use either the classic command prompt or the more modern PowerShell terminal. If you use Windows in desktop mode, run the cmd or powershell command from the Start menu. If you use the Windows 8 start screen instead, simply type cmd or powershell, and then run either the “Command Prompt” or “Windows Powershell” application. If you are using cmd, type chcp 65001 before using pandoc, to set the encoding to UTF-8.

  • On Linux, there are many possible configurations, depending on what desktop environment you’re using:

    • In Unity, use the search function on the Dash, and search for Terminal. Or, use the keyboard shortcut Ctrl-Alt-T.
    • In Gnome, go to Applications, then Accessories, and select Terminal, or use Ctrl-Alt-T.
    • In XFCE, go to Applications, then System, then Terminal, or use Super-T.
    • In KDE, go to KMenu, then System, then Terminal Program (Konsole).

[…]

(permalink to full text)

The following Haskell libraries have been developed to support pandoc:

skylighting-core and skylighting
Syntax highlighting engine supporting over 140 languages.
citeproc
Citation processing using CSL stylesheets.
texmath
Conversion of math between tex, Word equation, MathML, and GNU eqn.
unicode-collation
Proper Unicode collation (sorting).
doclayout
Combinators for laying out a textual document, with support for line wrapping, tabular layout, and more.
doctemplates
Supports pandoc’s templates.
commonmark, commonmark-extensions, and commonmark-pandoc
Efficient, standards-compliant parser for commonmark and extensions.
ipynb
Representation of Jupyter notebooks and conversion to and from JSON.
zip-archive
A pure zip file creator and extractor, used by pandoc for docx, ODT, and EPUB.
rfc5051
Simple unicode collation (used for citation sorting).
emojis
Conversion between emoji characters and aliases.
jira-wiki-markup
Support for parsing Jira wiki syntax.

[…]

(permalink to full text)

  • ITEM 1
  • ITEM 2
  • ITEM 3

RIGHT BOX

RIGHT TEXT