### System Module Example in Lua Source: https://pandoc.org/releases.html Demonstrates interacting with the file system using the pandoc.system module in Lua. This includes getting the current directory and managing temporary directories. ```lua print(pandoc.system.get_current_directory()) ``` ```lua pandoc.system.with_temporary_directory('tikz', function (dir) -- write and compile a TikZ file with pdflatex end) ``` -------------------------------- ### Install Pandoc for All Users on Windows Source: https://pandoc.org/faqs.html Uses MSI installer commands to perform a system-wide installation of Pandoc. ```batch msiexec /i pandoc-VERSION.msi ALLUSERS=1 msiexec /i pandoc-1.11.1.msi ALLUSERS=1 APPLICATIONFOLDER="C:\Pandoc" ``` -------------------------------- ### EPUB Metadata Example Source: https://pandoc.org/demo/example9.db Example of Dublin Core metadata elements in an XML file for EPUB. ```xml Creative Commons es-AR ``` -------------------------------- ### For Loop Examples Source: https://pandoc.org/demo/example28.txt Shows how to use for loops to iterate over arrays or maps, with examples of accessing elements and using separators. ```pandoc $for(foo)$$foo$$sep$, $endfor$ ``` ```pandoc $for(foo)$ - $foo.last$, $foo.first$ $endfor$ ``` ```pandoc ${ for(foo.bar) } - ${ foo.bar.last }, ${ foo.bar.first } ${ endfor } ``` ```pandoc $for(mymap)$ $it.name$: $it.office$ $endfor$ ``` ```pandoc ${ for(foo) }${ foo }${ sep }, ${ endfor } ``` ```pandoc ${ for(foo.bar) } - ${ it.last }, ${ it.first } ${ endfor } ``` -------------------------------- ### Install Pandoc on Windows using Winget Source: https://pandoc.org/installing.html Installs Pandoc on Windows using the winget package manager. ```bash winget install --source winget --exact --id JohnMacFarlane.Pandoc ``` -------------------------------- ### Simple Table Example Source: https://pandoc.org/demo/example1.html Provides an example of a simple table format with column alignment specified. ```markdown Right Left Center Default ------- ------ ---------- ------- 12 12 12 12 123 123 123 123 1 1 1 1 ``` -------------------------------- ### Ordered List with Custom Start Number and Markers Source: https://pandoc.org/demo/example33/8.7-lists.html Pandoc's `startnum` extension preserves custom list marker types and starting numbers. This example shows a list starting at 9 with a ')' suffix and a sublist using lowercase Roman numerals. ```markdown 9) Ninth 10) Tenth 11) Eleventh i. subone ii. subtwo iii. subthree ``` -------------------------------- ### GladTeX Processing Example Source: https://pandoc.org/demo/example25.textile Demonstrates the command-line usage for processing HTML with GladTeX to generate images. ```bash pandoc -s --gladtex input.md -o myfile.htex gladtex -d image_dir myfile.htex ``` -------------------------------- ### Bullet List Example Source: https://pandoc.org/demo/example26.html A simple bullet list using asterisks. Each item starts with a bullet character. ```markdown * one * two * three ``` -------------------------------- ### PDF Engine Selection Example Source: https://pandoc.org/demo/example1.html Illustrates specifying a PDF engine and its options. This example shows how to set a custom output directory for latexmk. ```bash pandoc input.md -o output.pdf --pdf-engine=pdflatex --pdf-engine-opt=-outdir=foo ``` -------------------------------- ### Definition List Example Source: https://pandoc.org/demo/example5.text A definition list with terms and their definitions. Definitions start with a colon or tilde, optionally indented. ```markdown Term 1 : Definition 1 Term 2 with *inline markup* : Definition 2 { some code, part of Definition 2 } Third paragraph of definition 2. ``` -------------------------------- ### Enable Listings Source: https://pandoc.org/demo/example3.html Use the listings package for typesetting code. Use --listings or set listings: true. ```bash --listings ``` ```yaml listings: true ``` -------------------------------- ### Use Pandoc System Module in TikZ Example Source: https://pandoc.org/releases.html Demonstrates the use of the pandoc.system module in a TikZ example, showcasing temporary directory handling. ```lua * Use pandoc.system module in TikZ example (Albert Krewinkel). Showcase temporary directory handling with `with_temporary_directory` and `with_working_directory`. ``` -------------------------------- ### Line Block Example Source: https://pandoc.org/demo/example28.txt Preserve line breaks and leading spaces in output by starting each line with a vertical bar and a space. ```markdown | The limerick packs laughs anatomical | In space that is quite economical. | But the good ones I've seen | So seldom are clean | And the clean ones so seldom are comical | 200 Main St. | Berkeley, CA 94718 ``` ```markdown | The Right Honorable Most Venerable and Righteous Samuel L. Constable, Jr. | 200 Main St. | Berkeley, CA 94718 ``` -------------------------------- ### Enable KaTeX Rendering (Command Line) Source: https://pandoc.org/demo/example9.db Use the --katex flag to enable KaTeX for rendering mathematical content in HTML. ```bash --katex ``` -------------------------------- ### Fenced Code Block Example Source: https://pandoc.org/demo/example9.db Fenced code blocks start and end with a row of three or more tildes. Everything between these lines is treated as code. ```markdown ~~~~~~~ if (a > 3) { moveShip(5 * gravity, DOWN); } ~~~~~~~ ``` -------------------------------- ### repl Source: https://pandoc.org/lua-filters.html Starts a read-eval-print loop (REPL). The function returns all values of the last evaluated input. Exit the REPL by pressing `ctrl-d` or `ctrl-c`; press `F1` to get a list of all key bindings. The REPL is started in the global namespace by default, but can be customized with an `env` table. ```APIDOC ## Function: repl ### Description Starts an interactive read-eval-print loop (REPL). ### Signature `repl ([env])` ### Parameters * `env` (table, optional) - Extra environment; the global environment is merged into this table. ### Returns * The result(s) of the last evaluated input, or nothing if the last input resulted in an error. ### Example ```lua function Pandoc (doc) -- start repl, allow to access the `doc` parameter -- in the repl return pandoc.cli.repl{ doc = doc } end ``` **Note**: The function may exit immediately on Windows without prompting for user input. ``` -------------------------------- ### Enable GladTeX Rendering (Defaults File) Source: https://pandoc.org/demo/example9.db Configure GladTeX rendering in the defaults file using 'html-math-method'. ```yaml html-math-method: method: gladtex ``` -------------------------------- ### Run Pandoc as a Web Server Source: https://pandoc.org/demo/example28.txt Start Pandoc as a web server by renaming the executable to pandoc-server or calling it with 'server' as the first argument. This exposes a JSON API for conversion functionality. ```bash pandoc-server ``` -------------------------------- ### Pandoc Paragraph Formatting: Initialisms Source: https://pandoc.org/demo/example1.html This example demonstrates how Pandoc correctly handles normal paragraphs starting with initialisms, ensuring they are not treated as list items. ```text B. Russell won a Nobel Prize (but not for "On Denoting"). ``` -------------------------------- ### Pandoc INSTALL.md: Add ChromeOS Install Instructions Source: https://pandoc.org/releases.html Includes instructions for installing Pandoc on ChromeOS in `INSTALL.md`. This expands the documentation to cover more operating systems. ```markdown * Add chromeos install instructions (#4958) (Evan Pratten). ``` -------------------------------- ### Extension: blank_before_header Source: https://pandoc.org/demo/example1.html Shows an example where a blank line is required before a heading in Pandoc, contrasting with standard Markdown. This prevents accidental heading creation from lines starting with '#'. ```markdown I like several of their flavors of ice cream: #22, for example, and #5. ``` -------------------------------- ### Build Pandoc from Source using Cabal Source: https://pandoc.org/installing.html Steps to install Pandoc using the Cabal build system, including updating the package database and installing the CLI. ```bash cabal update cabal install pandoc-cli pandoc --help ``` -------------------------------- ### Line Block Example Source: https://pandoc.org/demo/example9.db Use line blocks to preserve line breaks and leading spaces, ideal for poetry or addresses. Lines start with a vertical bar and a space. ```markdown | The limerick packs laughs anatomical | | In space that is quite economical. | | But the good ones I've seen | | So seldom are clean | | And the clean ones so seldom are comical | | 200 Main St. | | Berkeley, CA 94718 ``` ```markdown | The Right Honorable Most Venerable and Righteous Samuel L. Constable, Jr. | | 200 Main St. | | Berkeley, CA 94718 ``` -------------------------------- ### Pandoc Example Lists Syntax Source: https://pandoc.org/demo/example33/8.7-lists.html Use the '@' marker for sequentially numbered examples. Numbering continues across lists. Labels can be used for references. ```markdown (@) My first example will be numbered (1). (@) My second example will be numbered (2). Explanation of examples. (@) My third example will be numbered (3). ``` ```markdown (@good) This is a good example. As (@good) illustrates, ... ``` ```markdown (@foo) Sample sentence. Intervening text... This theory can explain the case we saw earlier (repeated): (@foo) Sample sentence. ``` -------------------------------- ### Definition List Example Source: https://pandoc.org/demo/example36.text A definition list with terms and their definitions. Definitions start with a colon or tilde, which can be indented. Multiple paragraphs and code blocks are supported within definitions. ```markdown Term 1 : Definition 1 Term 2 with *inline markup* : Definition 2 { some code, part of Definition 2 } Third paragraph of definition 2. ``` -------------------------------- ### Line Block Example Source: https://pandoc.org/demo/example5.text Line blocks preserve line breaks and leading spaces. Each line must start with a vertical bar and a space. This is useful for addresses and poetry. ```markdown | The limerick packs laughs anatomical | In space that is quite economical. | But the good ones I've seen | So seldom are clean | And the clean ones so seldom are comical | 200 Main St. | Berkeley, CA 94718 ``` -------------------------------- ### Slide Level Source: https://pandoc.org/demo/example1.html Specifies the heading level to use for slides in presentation output. For example, level 2 would make H2 headings the start of new slides. ```shell --slide-level 2 ``` ```yaml slide-level: 2 ``` -------------------------------- ### Enable KaTeX Rendering (Defaults File) Source: https://pandoc.org/demo/example9.db Configure KaTeX rendering in the defaults file using 'html-math-method'. ```yaml html-math-method: method: katex ``` -------------------------------- ### Use Reference Links Source: https://pandoc.org/demo/example28.txt Format all links as reference-style links. ```yaml reference-links: true ``` -------------------------------- ### Multiline Table Example Source: https://pandoc.org/demo/example26.html Supports rows that span multiple lines of text. Rows must be separated by blank lines, and the table must start and end with a dashed line. ```markdown ------------------------------------------------------------- Centered Default Right Left Header Aligned Aligned Aligned ----------- ------- --------------- ------------------------- First row 12.0 Example of a row that spans multiple lines. Second row 5.0 Here's another one. Note the blank line between rows. ------------------------------------------------------------- : Here's the caption. It, too, may span multiple lines. ``` -------------------------------- ### Enable WebTeX Rendering (Command Line) Source: https://pandoc.org/demo/example9.db Use the --webtex flag to enable WebTeX for rendering mathematical content in HTML. ```bash --webtex ``` -------------------------------- ### Pandoc YAML Metadata Block Example Source: https://pandoc.org/demo/example28.txt YAML metadata blocks are valid YAML objects delimited by '---' or '...'. They can be placed anywhere but must be preceded by a blank line if not at the start. ```yaml --- key: value --- ``` ```yaml --- key: value ... ``` -------------------------------- ### Pandoc Line Blocks Example Source: https://pandoc.org/demo/example33/8.6-line-blocks.html Demonstrates basic line block syntax in Pandoc. Lines starting with '| ' are preserved with their line breaks and leading spaces. Useful for verse and addresses. ```markdown | The limerick packs laughs anatomical | In space that is quite economical. | But the good ones I've seen | So seldom are clean | And the clean ones so seldom are comical | 200 Main St. | Berkeley, CA 94718 ``` -------------------------------- ### Configure and Build Benchmarks with Cabal Source: https://pandoc.org/releases.html Integrates the benchmark program into Cabal. Use this to configure, build, and run benchmarks. ```bash cabal configure --enable-benchmarks && cabal build ``` ```bash cabal bench --benchmark-option='markdown' --benchmark-option='-s 20' ``` -------------------------------- ### Fenced Code Block Example Source: https://pandoc.org/demo/example33/8.5-verbatim-code-blocks.html Fenced code blocks start and end with a row of three or more tildes. Content between these delimiters is treated as code. Surrounding text must be separated by blank lines. ```text ~~~~~~~ if (a > 3) { moveShip(5 * gravity, DOWN); } ~~~~~~~ ``` -------------------------------- ### Image Width Conversion Example (HTML) Source: https://pandoc.org/demo/example5.text Illustrates how a percentage width image is converted to HTML style. ```html ``` -------------------------------- ### Clone and Prepare Git Repository Source: https://pandoc.org/epub.html Commands to clone a project repository and navigate to the source directory. ```bash git clone https://github.com/progit/progit.git cd progit/en ``` -------------------------------- ### repl Source: https://pandoc.org/doc/lua-filters.md Starts a read-eval-print loop (REPL). The function returns all values of the last evaluated input. Exit the REPL by pressing ctrl-d or ctrl-c; press F1 to get a list of all key bindings. ```APIDOC ## repl ### Description Starts a read-eval-print loop (REPL). The function returns all values of the last evaluated input. Exit the REPL by pressing `ctrl-d` or `ctrl-c`; press `F1` to get a list of all key bindings. The REPL is started in the global namespace, unless the `env` parameter is specified. In that case, the global namespace is merged into the given table and the result is used as `_ENV` value for the repl. Specifically, local variables _cannot_ be accessed, unless they are explicitly passed via the `env` parameter; e.g. ```lua function Pandoc (doc) -- start repl, allow to access the `doc` parameter -- in the repl return pandoc.cli.repl{ doc = doc } end ``` **Note** : it seems that the function exits immediately on Windows, without prompting for user input. ### Parameters #### env - **env** (table) - Description: Extra environment; the global environment is merged into this table. ### Returns - The result(s) of the last evaluated input, or nothing if the last input resulted in an error. ``` -------------------------------- ### Multiple Lists with Different Markers Source: https://pandoc.org/demo/example6.text Pandoc starts a new list each time a different list marker type is encountered. This example demonstrates three distinct lists created by alternating marker styles. ```markdown (2) Two (5) Three 1. Four * Five ``` -------------------------------- ### Partial Inclusion Examples Source: https://pandoc.org/demo/example28.txt Demonstrates how to include partial templates (subtemplates) and apply them to variables or iterate over arrays. ```pandoc ${ styles() } ``` ```pandoc ${ styles.html() } ``` ```pandoc ${ date:fancy() } ``` ```pandoc ${ articles:bibentry() } ``` ```pandoc ${ for(articles) } ${ it:bibentry() } ${ endfor } ``` ```pandoc ${months[, ]} ``` ```pandoc ${articles:bibentry()[; ]} ``` -------------------------------- ### Custom Numbered Lists with Sublists Source: https://pandoc.org/demo/example6.text Pandoc preserves custom list numbering and marker types. This example shows a list starting at 9 with parenthesis markers and a sublist using lowercase roman numerals. ```markdown 9) Ninth 10) Tenth 11) Eleventh i. subone ii. subtwo iii. subthree ``` -------------------------------- ### Enable WebTeX Rendering (Defaults File) Source: https://pandoc.org/demo/example9.db Configure WebTeX rendering in the defaults file using 'html-math-method'. ```yaml html-math-method: method: webtex ``` -------------------------------- ### Multiple Lists from Different Markers Source: https://pandoc.org/demo/example33/8.7-lists.html Pandoc starts a new list whenever a different type of list marker is encountered. This example demonstrates three distinct lists created by using parentheses, periods, and bullets. ```markdown (2) Two (5) Three 1. Four * Five ``` -------------------------------- ### YAML Metadata Block Example Source: https://pandoc.org/demo/example6.text A sample YAML metadata block demonstrating various data types like strings, lists, and indented literal blocks for abstracts. Ensure the block starts and ends with '---' or '...'. ```yaml --- title: 'This is the title: it contains a colon' author: - Author One - Author Two keywords: [nothing, nothingness] abstract: | This is the abstract. It consists of two paragraphs. ... ``` -------------------------------- ### Create a PDF document Source: https://pandoc.org/demo/example6.text To produce a PDF, specify an output file with a .pdf extension. This requires appropriate LaTeX installation. ```bash pandoc -o output.pdf input.txt ``` -------------------------------- ### Pandoc Fenced Divs Example Source: https://pandoc.org/demo/example33/8.18-divs-and-spans.html Use this syntax for native Div elements in Pandoc AST. The Div starts with a fence of at least three colons and attributes, ending with a similar fence. Ensure blank lines separate the Div from other blocks. ```markdown ::::: {#special .sidebar} Here is a paragraph. And another. ::::: ``` -------------------------------- ### Pandoc Citation Syntax Examples Source: https://pandoc.org/demo/example26.html Illustrates various ways to format citation keys, including handling special characters and URLs. Use curly braces for keys that do not start with an alphanumeric character or underscore, or that contain punctuation not considered internal. ```markdown See the CSL user documentation for more information about CSL styles and how they affect rendering. Unless a citation key starts with a letter, digit, or `_`, and contains only alphanumerics and single internal punctuation characters (`:.#$%&-+?<>~/`), it must be surrounded by curly braces, which are not considered part of the key. In `@Foo_bar.baz.`, the key is `Foo_bar.baz` because the final period is not _internal_ punctuation, so it is not included in the key. In `@{Foo_bar.baz.}`, the key is `Foo_bar.baz.`, including the final period. In `@Foo_bar--baz`, the key is `Foo_bar` because the repeated internal punctuation characters terminate the key. The curly braces are recommended if you use URLs as keys: `[@{https://example.com/bib?name=foobar&date=2000}, p. 33]`. ```