From d559ccaca60acb46c6a12c256ea2a1dcc867d0f8 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 5 Apr 2019 21:09:01 +0000 Subject: markdown (5apr19) git-svn-id: svn://tug.org/texlive/trunk@50784 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/doc/generic/markdown/markdown.css | 25 + .../texmf-dist/doc/generic/markdown/markdown.html | 5670 ++++++++++++------ Master/texmf-dist/doc/generic/markdown/markdown.md | 3324 +---------- .../texmf-dist/doc/generic/markdown/markdown.pdf | Bin 398905 -> 412653 bytes .../texmf-dist/scripts/markdown/markdown-cli.lua | 8 +- .../source/generic/markdown/docstrip.cfg | 4 +- .../source/generic/markdown/markdown.dtx | 6013 ++++++++++++++++---- .../source/generic/markdown/markdown.ins | 3 + .../tex/context/third/markdown/t-markdown.tex | 2 +- .../texmf-dist/tex/generic/markdown/markdown.tex | 24 +- Master/texmf-dist/tex/latex/markdown/markdown.sty | 196 +- Master/texmf-dist/tex/luatex/markdown/markdown.lua | 253 +- 12 files changed, 9433 insertions(+), 6089 deletions(-) (limited to 'Master') diff --git a/Master/texmf-dist/doc/generic/markdown/markdown.css b/Master/texmf-dist/doc/generic/markdown/markdown.css index 2e2f4fb6c44..5abe7013b44 100644 --- a/Master/texmf-dist/doc/generic/markdown/markdown.css +++ b/Master/texmf-dist/doc/generic/markdown/markdown.css @@ -323,3 +323,28 @@ table td { } } +.tex sub, .latex sub, .latex sup { + text-transform: uppercase; +} + +.tex sub, .latex sub { + vertical-align: -0.1ex; + margin-left: -0.1667em; + margin-right: -0.125em; +} + +.tex, .latex, .tex sub, .latex sub { + font-size: 1em; +} + +.latex sup { + font-size: 0.85em; + vertical-align: -0.35em; + margin-left: -0.36em; + margin-right: -0.15em; +} + +abbr { + font-variant: small-caps; +} + diff --git a/Master/texmf-dist/doc/generic/markdown/markdown.html b/Master/texmf-dist/doc/generic/markdown/markdown.html index 523805f0347..203c1be5121 100644 --- a/Master/texmf-dist/doc/generic/markdown/markdown.html +++ b/Master/texmf-dist/doc/generic/markdown/markdown.html @@ -1,150 +1,149 @@ - - + + - - + + Markdown Package User Manual - - + + + - -
+

Vít Novotný

+

v2.7.0 (2019/04/04)

+ +
+

1 Introduction

-

The Markdown package converts markdown markup to TeX commands. The functionality is provided both as a Lua module, and as plain TeX, LaTeX, and ConTeXt macro packages that can be used to directly typeset TeX documents containing markdown markup. Unlike other convertors, the Markdown package makes it easy to redefine how each and every markdown element is rendered. Creative abuse of the markdown syntax is encouraged.

-

This document is a user manual for the Markdown package. It provides beginner tutorials and code examples. For an in-depth description of the package requirements, interfaces, and implementation, please refer to the technical documentation.

+

The Markdown package converts markdown markup to TeX commands. The functionality is provided both as a Lua module and as plain TeX, LaTeX, and ConTeXt macro packages that can be used to directly typeset documents containing markdown markup. Unlike other convertors, the Markdown package makes it easy to redefine how each and every markdown element is rendered. Creative abuse of the markdown syntax is encouraged.

+

This document is a user manual for the Markdown package. It provides tutorials and code examples. For an in-depth description of the package requirements, interfaces, and implementation, please refer to the technical documentation.

1.1 Requirements

-

The package requires a working TeX distribution. TeX Live ≥ 2013 is known to work and so are recent installation of MikTeX. If you are using a minimal installation of a TeX distribution, please consult the technical documentation for a detailed list of required packages.

+

The package requires a working TeX distribution. TeX Live ≥ 2013 is known to work and so are recent installation of MikTeX. If you are using a minimal installation of a TeX distribution, please consult the technical documentation for a detailed list of required packages.

1.2 Installation

-

The package comes pre-installed with TeX Live ≥ 2016 and with recent installations of MikTeX. Unless you explicitly wish to use the latest version of the package, you are encouraged to skip this step.

+

The package comes pre-installed with TeX Live ≥ 2016 and with recent installations of MikTeX. Unless you explicitly wish to use the latest version of the package, you are encouraged to skip this step.

To install the package, first download the package from the repository using Git:

-
git clone https://github.com/witiko/markdown
-

Next, enter the directory named markdown and interpret the file named markdown.ins file using a Unicode-aware TeX engine, such as XeTeX or LuaTeX:

-
cd markdown
-luatex markdown.ins
+
git clone https://github.com/witiko/markdown
+

Next, enter the directory named markdown and interpret the file named markdown.ins file using a Unicode-aware TeX engine, such as XeTeX or LuaTeX:

+
cd markdown
+luatex markdown.ins

This should produce the following files:

-

1.2.1 Local installation

-

To perform a local installation, place the above files into your TeX directory structure. This is generally where the individual files should be placed:

+

1.2.1 Local Installation

+

To perform a local installation, place the above files into your TeX directory structure. This is generally where the individual files should be placed:

-

where <TEXMF> corresponds to a root of your TeX distribution, such as /usr/share/texmf and ~/texmf on UN*X systems or C:\Users\<YOUR␣USERNAME>\texmf on Windows systems. When in doubt, consult the manual of your TeX distribution.

-

1.2.2 Portable installation

-

Alternatively, you can also store the above files in the same folder as your TeX document and distribute them together. This way your document can be portably typeset on legacy TeX distributions.

-

1.3 First document

-

In this section, we will take the necessary steps to typeset our first markdown document in TeX. This will serve as our first hands-on experience with the package and also as a reassurance that the package has been correctly installed.

+

where <TEXMF> corresponds to a root of your TeX distribution, such as /usr/share/texmf and ~/texmf on UN*X systems or C:\Users\Your username\texmf on Windows systems. When in doubt, consult the manual of your TeX distribution.

+

1.2.2 Portable Installation

+

Alternatively, you can also store the above files in the same folder as your TeX document and distribute them together. This way your document can be portably typeset on legacy TeX distributions.

+

1.3 First Document

+

In this section, we will take the necessary steps to typeset our first markdown document in TeX. This will serve as our first hands-on experience with the package and also as a reassurance that the package has been correctly installed.

1.3.1 Using Lua

Using a text editor, create a text document named document.tex with the following content:

-
\input markdown
-\input hello
-\bye
-

1.3.1.1 Using the Lua module

+
\input markdown
+\input hello
+\bye
+

1.3.1.1 Using the Lua Module

Using a text editor, create a text document named hello.lua with the following content:

-
#!/usr/bin/env texlua
-local kpse = require("kpse")
-kpse.set_program_name("luatex")
-local markdown = require("markdown")
-local convert = markdown.new()
-print(convert("Hello *world*!"))
-

Next, invoke LuaTeX from the terminal:

-
texlua hello.lua > hello.tex
-luatex document.tex
+
#!/usr/bin/env texlua
+local kpse = require("kpse")
+kpse.set_program_name("luatex")
+local markdown = require("markdown")
+local convert = markdown.new()
+print(convert("Hello *world*!"))
+

Next, invoke LuaTeX from the terminal:

+
texlua hello.lua > hello.tex
+luatex document.tex

A PDF document named document.pdf should be produced and contain the text “Hello world!” Invoking pdfTeX should have the same effect:

-
texlua hello.lua > hello.tex
-pdftex document.tex
-

1.3.1.2 Using the Lua CLI

+
texlua hello.lua > hello.tex
+pdftex document.tex
+

1.3.1.2 Using the Lua Command-Line Interface

Using a text editor, create a text document named hello.md with the following content:

-
Hello *world*!
+
Hello *world*!

Next, invoke LuaTeX from the terminal:

-
texlua <CLI␣PATHNAME> -- hello.md hello.tex
-luatex document.tex
-

where <CLI␣PATHNAME> corresponds to the location of the Lua CLI script file, such as ~/texmf/scripts/markdown/markdown-cli.lua on UN*X systems or C:\Users\<YOUR␣USERNAME>\texmf\scripts\markdown\markdown-cli.lua on Windows systems. Use the command kpsewhich markdown-cli.lua to locate the Lua CLI script file using Kpathsea.

+
texlua ⟨CLI pathname⟩ -- hello.md hello.tex
+luatex document.tex
+

where ⟨CLI pathname⟩ corresponds to the location of the Lua CLI script file, such as ~/texmf/scripts/markdown/markdown-cli.lua on UN*X systems or C:\Users\Your username\texmf\scripts\markdown\markdown-cli.lua on Windows systems. Use the command kpsewhich markdown-cli.lua to locate the Lua CLI script file using Kpathsea.

A PDF document named document.pdf should be produced and contain the text “Hello world!” Invoking pdfTeX should have the same effect:

-
texlua <CLI␣PATHNAME> -- hello.md hello.tex
-pdftex document.tex
-

1.3.2 Using plain TeX

+
texlua ⟨CLI pathname⟩ -- hello.md hello.tex
+pdftex document.tex
+

1.3.2 Using Plain TeX

Using a text editor, create a text document named document.tex with the following content:

-
\input markdown
-\markdownBegin
-Hello *world*!
-\markdownEnd
-\bye
+
\input markdown
+\markdownBegin
+Hello *world*!
+\markdownEnd
+\bye

Next, invoke LuaTeX from the terminal:

-
luatex document.tex
+
luatex document.tex

A PDF document named document.pdf should be produced and contain the text “Hello world!” Invoking pdfTeX should have the same effect:

-
pdftex --shell-escape document.tex
-

1.3.3 Using LaTeX

-

Using a text editor, create a text document named document.tex with the following content:

-
\documentclass{article}
-\usepackage{markdown}
-\begin{document}
-\begin{markdown}
-Hello *world*!
-\end{markdown}
-\end{document}
-

Next, invoke LuaTeX from the terminal:

-
lualatex document.tex
+
pdftex --shell-escape document.tex
+

1.3.3 Using LaTeX

+

Using a text editor, create a text document named document.tex with the following content:

+
\documentclass{article}
+\usepackage{markdown}
+\begin{document}
+\begin{markdown}
+Hello *world*!
+\end{markdown}
+\end{document}
+

Next, invoke LuaTeX from the terminal:

+
lualatex document.tex

A PDF document named document.pdf should be produced and contain the text “Hello world!” Invoking pdfTeX should have the same effect:

-
pdflatex --shell-escape document.tex
+
pdflatex --shell-escape document.tex

As the next step, try typesetting the example documents distributed along with the Markdown package:

-
git clone https://github.com/witiko/markdown
-cd markdown/examples
-lualatex latex.tex
+
git clone https://github.com/witiko/markdown
+cd markdown/examples
+lualatex latex.tex

A PDF document named latex.pdf should be produced. Open the text documents latex.tex and example.md in a text editor to see how the example documents are structured. Try changing the documents and typesetting them as follows:

-
lualatex latex.tex
+
lualatex latex.tex

to see the effect of your changes.

-

1.3.4 Using ConTeXt

+

1.3.4 Using ConTeXt

Using a text editor, create a text document named document.tex with the following content:

-
\usemodule[t][markdown]
-\starttext
-\startmarkdown
-Hello *world*!
-\stopmarkdown
-\stoptext
+
\usemodule[t][markdown]
+\starttext
+\startmarkdown
+Hello *world*!
+\stopmarkdown
+\stoptext

Next, invoke LuaTeX from the terminal:

-
context document.tex
+
context document.tex

A PDF document named document.pdf should be produced and contain the text “Hello world!” Invoking pdfTeX should have the same effect:

-
texexec --passon=--shell-escape document.tex
+
texexec --passon=--shell-escape document.tex

As the next step, try typesetting the example documents distributed along with the Markdown package:

-
git clone https://github.com/witiko/markdown
-cd markdown/examples
-context context.tex
+
git clone https://github.com/witiko/markdown
+cd markdown/examples
+context context.tex

A PDF document named context.pdf should be produced. Open the text documents context.tex and example.md in a text editor to see how the example documents are structured. Try changing the documents and typesetting them as follows:

-
context context.tex
+
context context.tex

to see the effect of your changes.

2 Examples

-

This section will show how to use the package by example.

-

2.1 Lua

-

The Lua part of the package makes it possible to convert a markdown document into TeX commands and typeset it later when convenient. Although the typical user will not find this terribly useful and will instead use the plain TeX, LaTeX, and ConTeXt macro packages to convert and typeset the markdown documents in a single step, they will still benefit from learning the options that control the behavior of the Lua parser.

-

2.1.1 Interfaces

-

The Lua part of the package exposes two interfaces – the markdown Lua module, and the Lua command-line interface (CLI).

-

2.1.1.1 The Lua module

-

The markdown Lua module exposes the new(options) method, which creates a converter function from markdown to TeX. The properties of the converter function are specified by the Lua table options. The parameter is optional; when unspecified, the behaviour will be the same as if options were an empty table.

-

Using a text editor, create a text document named document.tex with the following content:

-
\input markdown
-\input lmfonts
-\input example
-\bye
+

In this section, I will describe the individual parts of the Markdown package. Each part will be shown by example, leaving the implementation details to the technical documentation.

+

2.1 Interfaces

+

In this section, I will describe the individual interfaces exposed by the Markdown package starting with the low-level Lua interfaces and all the way up to the LaTeX and ConTeXt interfaces intended for the ordinary user.

+

2.1.1 Lua

+

The Lua programming language is what drives the conversion from markdown to TeX in the Markdown package. Based on the Lunamark Lua library by John MacFarlane, the Lua implementation is largely independent on TeX, and can be used separately from typesetting a document. Lua provides two interfaces: a Lua module and a command-line interface (CLI).

+

2.1.1.1 Lua Module

+

A Lua module is a software library that can be used from in other programs. The markdown Lua module makes it possible to convert markdown to TeX from within LuaTeX documents and Lua scripts.

+

The markdown Lua module exposes the new(options) method, which creates a converter function from markdown to TeX. The properties of the converter function are specified by the Lua table options. The parameter is optional; when unspecified, the behaviour will be the same as if ⟨options⟩ were an empty table.

+

Using a text editor, create a text document named document.tex with the following content:

+
\input markdown
+\input lmfonts
+\input example
+\bye

Using a text editor, create a text document named example.lua with the following content:

-
#!/usr/bin/env texlua
-local kpse = require("kpse")
-kpse.set_program_name("luatex")
-local markdown = require("markdown")
-local convert_safe = markdown.new()
-local convert_unsafe = markdown.new({hybrid = true})
-local input = [[$\sqrt{-1}$ *equals* $i$.]]
-print(convert_safe(input) .. " " .. convert_unsafe(input))
-

Next, invoke LuaTeX from the terminal:

-
texlua example.lua > example.tex
-luatex document.tex
-

A PDF document named document.pdf should be produced and contain the text “$\sqrt{-1}$ equals $i$. √-̅1̅ equals i.” Invoking pdfTeX should have the same effect:

-
texlua example.lua > example.tex
-pdftex document.tex
+
#!/usr/bin/env texlua
+local kpse = require("kpse")
+kpse.set_program_name("luatex")
+local markdown = require("markdown")
+local input, convert_safe, convert_unsafe, paragraph
+
+input = [[$\sqrt{-1}$ *equals* $i$.]]
+convert_safe = markdown.new()
+convert_unsafe = markdown.new({hybrid = true})
+paragraph = [[\par]]
+
+print(
+  convert_safe(input) .. paragraph ..
+  convert_unsafe(input)
+)
+

Next, invoke LuaTeX from the terminal:

+
texlua example.lua > example.tex
+luatex document.tex
+

A PDF document named document.pdf should be produced and contain the following text:

+
+

$\sqrt{-1}$ equals $i$.

+

√-̅1̅ equals i.

+
+

Invoking pdfTeX should have the same effect:

+
texlua example.lua > example.tex
+pdftex document.tex

Rather than use the texlua interpreter, we can also access the markdown Lua module directly from our document. Using a text editor, create a text document named document.tex with the following content:

-
\input markdown
-\input lmfonts
-\directlua{
-  local markdown = require("markdown")
-  local convert_safe = markdown.new()
-  local convert_unsafe = markdown.new({hybrid = true})
-  local input = [[$\noexpand\sqrt{-1}$ *equals* $i$.]]
-  tex.sprint(convert_safe(input) .. " " .. convert_unsafe(input)) }
-\bye
-

Next, invoke LuaTeX from the terminal:

-
luatex document.tex
-

A PDF document named document.pdf should be produced and contain the text “$\sqrt {-1}$ equals $i$. √-̅1̅ equals i.” In this case, we cannot use pdfTeX, because pdfTeX does not define the \directlua TeX command.

-

2.1.1.2 The Lua CLI

-

The Lua command-line interface (CLI) accepts the same options as the markdown Lua module, but now the options are specified as command-line parameters.

-

Using a text editor, create a text document named document.tex with the following content:

-
\input markdown
-\input lmfonts
-\input safe\ \input unsafe
-\bye
+
\input markdown
+\input lmfonts
+\directlua{
+  local markdown = require("markdown")
+  local input, convert_safe, convert_unsafe, paragraph
+
+  input = [[$\string\sqrt{-1}$ *equals* $i$.]]
+  convert_safe = markdown.new()
+  convert_unsafe = markdown.new({hybrid = true})
+  paragraph = [[\par]]
+
+  tex.sprint(
+    convert_safe(input) .. paragraph ..
+    convert_unsafe(input)
+  )
+}
+\bye
+

Next, invoke LuaTeX from the terminal:

+
luatex document.tex
+

A PDF document named document.pdf should be produced and contain the following text:

+
+

$\sqrt{-1}$ equals $i$.

+

√-̅1̅ equals i.

+
+

In this case, we cannot use pdfTeX, because pdfTeX does not define the \directlua TeX command.

+

2.1.1.2 Lua Command-Line Interface

+

The Lua command-line interface (CLI) of the Markdown package makes the functionality of the Lua module accessible from the command line. This makes it possible to convert documents from markdown to TeX manually without any knowledge of the Lua programming language.

+

The Lua command-line interface accepts the same options as the markdown Lua module, but now the options are specified as command-line parameters.

+

Using a text editor, create a text document named document.tex with the following content:

+
\input markdown
+\input lmfonts
+\input safe
+
+\input unsafe
+\bye

Using a text editor, create a text document named example.md with the following content:

-
$\sqrt{-1}$ *equals* $i$.
-

Next, invoke LuaTeX from the terminal:

-
texlua <CLI␣PATHNAME> -- example.md safe.tex
-texlua <CLI␣PATHNAME> hybrid=true -- example.md unsafe.tex
-luatex document.tex
-

where <CLI␣PATHNAME> corresponds to the location of the Lua CLI script file, such as ~/texmf/scripts/markdown/markdown-cli.lua on UN*X systems or C:\Users\<YOUR␣USERNAME>\texmf\scripts\markdown\markdown-cli.lua on Windows systems. Use the command kpsewhich markdown-cli.lua to locate the Lua CLI script file using Kpathsea.

-

A PDF document named document.pdf should be produced and contain the text “$\sqrt{-1}$ equals $i$. √-̅1̅ equals i.” Invoking pdfTeX should have the same effect:

-
texlua <CLI␣PATHNAME> -- example.md safe.tex
-texlua <CLI␣PATHNAME> hybrid=true -- example.md unsafe.tex
-pdftex document.tex
-

2.1.2 Options

-

This section will cover the options recognized by the Lua interface. The interfaces of the plain TeX, LaTeX, and ConTeXt macro packages recognize these options as well, in addition to their own options.

-

2.1.2.1 File and Directory Names

-
2.1.2.1.1 Option cacheDir
+
$\sqrt{-1}$ *equals* $i$.
+

Next, invoke LuaTeX from the terminal:

+
texlua ⟨CLI pathname⟩ -- example.md safe.tex
+texlua ⟨CLI pathname⟩ hybrid=true -- example.md unsafe.tex
+luatex document.tex
+

where ⟨CLI pathname⟩ corresponds to the location of the Lua CLI script file, such as ~/texmf/scripts/markdown/markdown-cli.lua on UN*X systems or C:\Users\Your username\texmf\scripts\markdown\markdown-cli.lua on Windows systems. Use the command kpsewhich markdown-cli.lua to locate the Lua CLI script file using Kpathsea.

+

A PDF document named document.pdf should be produced and contain the following text:

+
+

$\sqrt{-1}$ equals $i$.

+

√-̅1̅ equals i.

+
+

Invoking pdfTeX should have the same effect:

+
texlua ⟨CLI pathname⟩ -- example.md safe.tex
+texlua ⟨CLI pathname⟩ hybrid=true -- example.md unsafe.tex
+pdftex document.tex
+

2.1.2 Plain TeX

+

The plain TeX interface provides TeX commands that typeset markdown documents by using the Lua interface behind the scenes. Unlike the Lua interface, the plain TeX interface does not provide low-level tools for converting markdown to TeX. Instead, its goal is to provide high-level typesetting capabilities.

+

The plain TeX interface accepts the same options as the markdown Lua module, in addition to its own options, but now the options are specified as TeX commands.

+

Using a text editor, create a text document named document.tex with the following content:

+
\input markdown
+\input lmfonts
+
+\markdownBegin
+$\sqrt{-1}$ *equals* $i$.
+\markdownEnd
+
+\def\markdownOptionHybrid{true}
+\markdownBegin
+$\sqrt{-1}$ *equals* $i$.
+\markdownEnd
+
+\bye
+

Next, invoke LuaTeX from the terminal:

+
luatex document.tex
+

A PDF document named document.pdf should be produced and contain the following text:

+
+

$\sqrt{-1}$ equals $i$.

+

√-̅1̅ equals i.

+
+

Invoking pdfTeX should have the same effect:

+
pdftex --shell-escape document.tex
+

2.1.3 LaTeX

+

The LaTeX interface provides the same level of functionality as the plain TeX interface by using the plain TeX interface behind the scenes. Unlike the plain TeX interface, the LaTeX interface uses familiar LaTeX idioms, such as package options and environments.

+

The LaTeX interface accepts the same options as the plain TeX interface, but now the options are specified as ⟨key = value⟩ pairs and they are passed either as package options, in the \markdownSetup command, or as parameters for the markdown* LaTeX environment.

+

Using a text editor, create a text document named document.tex with the following content:

+
\documentclass{article}
+\usepackage{markdown}
+\begin{document}
+
+\begin{markdown}
+$\sqrt{-1}$ *equals* $i$
+\end{markdown}
+
+\begin{markdown*}{hybrid}
+$\sqrt{-1}$ *equals* $i$
+\end{markdown*}
+
+\end{document}
+

Next, invoke LuaTeX from the terminal:

+
lualatex document.tex
+

A PDF document named document.pdf should be produced and contain the following text:

+
+

$\sqrt{-1}$ equals $i$.

+

√-̅1̅ equals i.

+
+

Invoking pdfTeX should have the same effect:

+
pdflatex --shell-escape document.tex
+

2.1.4 ConTeXt

+

The ConTeXt interface provides the same level of functionality as the plain TeX interface by using the plain TeX interface behind the scenes. Unlike the plain TeX interface, the ConTeXt interface uses familiar ConTeXt idioms, such as environments.

+

The ConTeXt interface accepts the same options as the plain TeX interface.

+

Using a text editor, create a text document named document.tex with the following content:

+
\usemodule[t][markdown]
+\starttext
+
+\startmarkdown
+$\sqrt{-1}$ *equals* $i$.
+\stopmarkdown
+
+\def\markdownOptionHybrid{true}
+\startmarkdown
+$\sqrt{-1}$ *equals* $i$.
+\stopmarkdown
+
+\stoptext
+

Next, invoke LuaTeX from the terminal:

+
context document.tex
+

A PDF document named document.pdf should be produced and contain the following text:

+
+

$\sqrt{-1}$ equals $i$.

+

√-̅1̅ equals i.

+
+

Invoking pdfTeX should have the same effect:

+
texexec --passon=--shell-escape document.tex
+

2.2 Options

+

In this section, I will describe all the options recognized by the Markdown package.

+

2.2.1 Lua

+

Lua options control the conversion from markdown to TeX. They are supported by all interfaces of the Markdown package starting with the low-level Lua interfaces and all the way up to the LaTeX and ConTeXt interfaces.

+

2.2.1.1 Option cacheDir

cacheDir (default value: ".")
-

A path to the directory containing auxiliary cache files. If the last segment of the path does not exist, it will be created by the Lua command-line and plain TeX implementations. The Lua implementation expects that the entire path already exists.

+

A path to the directory containing auxiliary cache files. If the last segment of the path does not exist, it will be created by the Lua command-line and plain TeX implementations. The Lua implementation expects that the entire path already exists.

When iteratively writing and typesetting a markdown document, the cache files are going to accumulate over time. You are advised to clean the cache directory every now and then, or to set it to a temporary filesystem (such as /tmp on UN*X systems), which gets periodically emptied.

-
Lua module example
-

Using a text editor, create a text document named document.tex with the following content:

-
\input markdown
-\directlua{
-  local markdown = require("markdown")
-  local convert = markdown.new({cacheDir = "cache"})
-  local input = "Hello *world*!"
-  tex.sprint(convert(input)) }
-\bye
+
Lua Module Example
+

Using a text editor, create a text document named document.tex with the following content:

+
\input markdown
+\directlua{
+  local markdown = require("markdown")
+  local convert = markdown.new({cacheDir = "cache"})
+  local input = "Hello *world*!"
+  tex.sprint(convert(input)) }
+\bye

Create an empty directory named cache next to our text document. Then, invoke LuaTeX from the terminal:

-
luatex document.tex
+
luatex document.tex

A PDF document named document.pdf should be produced and contain the text “Hello world!” Several cache files of the Markdown package will also be produced in the cache directory as we requested using the cacheDir option.

-
Lua CLI example
+
Lua CLI Example

Using a text editor, create a text document named document.tex with the following content:

-
\input markdown
-\input hello
-\bye
+
\input markdown
+\input hello
+\bye

Using a text editor, create a text document named hello.md with the following content:

-
Hello *world*!
+
Hello *world*!

Next, invoke LuaTeX from the terminal:

-
texlua <CLI␣PATHNAME> cacheDir=cache -- hello.md hello.tex
-luatex document.tex
-

where <CLI␣PATHNAME> corresponds to the location of the Lua CLI script file, such as ~/texmf/scripts/markdown/markdown-cli.lua on UN*X systems or C:\Users\<YOUR␣USERNAME>\texmf\scripts\markdown\markdown-cli.lua on Windows systems. Use the command kpsewhich markdown-cli.lua to locate the Lua CLI script file using Kpathsea.

+
texlua ⟨CLI pathname⟩ cacheDir=cache -- hello.md hello.tex
+luatex document.tex
+

where ⟨CLI pathname⟩ corresponds to the location of the Lua CLI script file, such as ~/texmf/scripts/markdown/markdown-cli.lua on UN*X systems or C:\Users\Your username\texmf\scripts\markdown\markdown-cli.lua on Windows systems. Use the command kpsewhich markdown-cli.lua to locate the Lua CLI script file using Kpathsea.

A PDF document named document.pdf should be produced and contain the text “Hello world!” A directory named cache containing several cache files of the Markdown package will also be produced as we requested using the cacheDir option.

-
Plain TeX example
+
Plain TeX Example

Using a text editor, create a text document named document.tex with the following content:

-
\input markdown
-\def\markdownOptionCacheDir{cache}
-\markdownBegin
-Hello *world*!
-\markdownEnd
-\bye
+
\input markdown
+\def\markdownOptionCacheDir{cache}
+\markdownBegin
+Hello *world*!
+\markdownEnd
+\bye

Next, invoke LuaTeX from the terminal:

-
luatex document.tex
+
luatex document.tex

A PDF document named document.pdf should be produced and contain the text “Hello world!” A directory named cache containing several cache files of the Markdown package will also be produced as we requested using the cacheDir option.

-
LaTeX example
+
LaTeX Example

Using a text editor, create a text document named document.tex with the following content:

-
\documentclass{article}
-\usepackage[cacheDir=cache]{markdown}
-\begin{document}
-\begin{markdown}
-Hello *world*!
-\end{markdown}
-\end{document}
+
\documentclass{article}
+\usepackage[cacheDir=cache]{markdown}
+\begin{document}
+\begin{markdown}
+Hello *world*!
+\end{markdown}
+\end{document}

Next, invoke LuaTeX from the terminal:

-
lualatex document.tex
+
lualatex document.tex

A PDF document named document.pdf should be produced and contain the text “Hello world!” A directory named cache containing several cache files of the Markdown package will also be produced as we requested using the cacheDir option.

-
ConTeXt example
+
ConTeXt Example

Using a text editor, create a text document named document.tex with the following content:

-
\usemodule[t][markdown]
-\def\markdownOptionCacheDir{cache}
-\starttext
-\startmarkdown
-Hello *world*!
-\stopmarkdown
-\stoptext
+
\usemodule[t][markdown]
+\def\markdownOptionCacheDir{cache}
+\starttext
+\startmarkdown
+Hello *world*!
+\stopmarkdown
+\stoptext

Next, invoke LuaTeX from the terminal:

-
context document.tex
+
context document.tex

A PDF document named document.pdf should be produced and contain the text “Hello world!” A directory named cache containing several cache files of the Markdown package will also be produced as we requested using the cacheDir option.

-

2.1.2.2 Parser Options

-
2.1.2.2.1 Option blankBeforeBlockquote
+

2.2.1.2 Option blankBeforeBlockquote

blankBeforeBlockquote (default value: false)
@@ -381,27 +492,27 @@ Hello *world*!
-
Lua module example
-

Using a text editor, create a text document named document.tex with the following content:

-
\input markdown
-\input lmfonts
-\directlua{
-  local markdown = require("markdown")
-  local newline = [[^^J^^J]]
-  local convert, input
-
-  convert = markdown.new()
-  input = "A paragraph." .. newline ..
-          "> A quote."   .. newline
-  tex.sprint(convert(input))
-
-  convert = markdown.new({blankBeforeBlockquote = true})
-  input = "A paragraph."   .. newline ..
-          "> Not a quote." .. newline
-  tex.sprint(convert(input)) }
-\bye
+
Lua Module Example
+

Using a text editor, create a text document named document.tex with the following content:

+
\input markdown
+\input lmfonts
+\directlua{
+  local markdown = require("markdown")
+  local newline = [[^^J^^J]]
+  local convert, input
+
+  convert = markdown.new()
+  input = "A paragraph." .. newline ..
+          "> A quote."   .. newline
+  tex.sprint(convert(input))
+
+  convert = markdown.new({blankBeforeBlockquote = true})
+  input = "A paragraph."   .. newline ..
+          "> Not a quote." .. newline
+  tex.sprint(convert(input)) }
+\bye

Then, invoke LuaTeX from the terminal:

-
luatex document.tex
+
luatex document.tex

A PDF document named document.pdf should be produced and contain the following text:

A paragraph.

@@ -410,21 +521,21 @@ Hello *world*!

A paragraph > Not a quote.

-
Lua CLI example
+
Lua CLI Example

Using a text editor, create a text document named document.tex with the following content:

-
\input markdown
-\input lmfonts
-\input optionfalse
-\input optiontrue
-\bye
+
\input markdown
+\input lmfonts
+\input optionfalse
+\input optiontrue
+\bye

Using a text editor, create a text document named content.md with the following content:

-
A paragraph.
-> A quote?
+
A paragraph.
+> A quote?

Next, invoke LuaTeX from the terminal:

-
texlua <CLI␣PATHNAME> -- content.md optionfalse.tex
-texlua <CLI␣PATHNAME> blankBeforeBlockquote=true -- content.md optiontrue.tex
-luatex document.tex
-

where <CLI␣PATHNAME> corresponds to the location of the Lua CLI script file, such as ~/texmf/scripts/markdown/markdown-cli.lua on UN*X systems or C:\Users\<YOUR␣USERNAME>\texmf\scripts\markdown\markdown-cli.lua on Windows systems. Use the command kpsewhich markdown-cli.lua to locate the Lua CLI script file using Kpathsea.

+
texlua ⟨CLI pathname⟩ -- content.md optionfalse.tex
+texlua ⟨CLI pathname⟩ blankBeforeBlockquote=true -- content.md optiontrue.tex
+luatex document.tex
+

where ⟨CLI pathname⟩ corresponds to the location of the Lua CLI script file, such as ~/texmf/scripts/markdown/markdown-cli.lua on UN*X systems or C:\Users\Your username\texmf\scripts\markdown\markdown-cli.lua on Windows systems. Use the command kpsewhich markdown-cli.lua to locate the Lua CLI script file using Kpathsea.

A PDF document named document.pdf should be produced and contain the following text:

A paragraph.

@@ -433,24 +544,24 @@ Hello *world*!

A paragraph. > A quote?

-
Plain TeX example
+
Plain TeX Example

Using a text editor, create a text document named document.tex with the following content:

-
\input markdown
-
-\markdownBegin
-A paragraph.
-> A quote.
-\markdownEnd
-
-\def\markdownOptionBlankBeforeBlockquote{true}
-\markdownBegin
-A paragraph.
-> Not a quote.
-\markdownEnd
-
-\bye
+
\input markdown
+
+\markdownBegin
+A paragraph.
+> A quote.
+\markdownEnd
+
+\def\markdownOptionBlankBeforeBlockquote{true}
+\markdownBegin
+A paragraph.
+> Not a quote.
+\markdownEnd
+
+\bye

Next, invoke LuaTeX from the terminal:

-
luatex document.tex
+
luatex document.tex

A PDF document named document.pdf should be produced and contain the following text:

A paragraph.

@@ -459,25 +570,25 @@ A paragraph.

A paragraph > Not a quote.

-
LaTeX example
+
LaTeX Example

Using a text editor, create a text document named document.tex with the following content:

-
\documentclass{article}
-\usepackage{markdown}
-\begin{document}
-
-\begin{markdown}
-A paragraph.
-> A quote.
-\end{markdown}
-
-\begin{markdown*}{blankBeforeBlockquote}
-A paragraph.
-> Not a quote.
-\end{markdown*}
-
-\end{document}
+
\documentclass{article}
+\usepackage{markdown}
+\begin{document}
+
+\begin{markdown}
+A paragraph.
+> A quote.
+\end{markdown}
+
+\begin{markdown*}{blankBeforeBlockquote}
+A paragraph.
+> Not a quote.
+\end{markdown*}
+
+\end{document}

Next, invoke LuaTeX from the terminal:

-
lualatex document.tex
+
lualatex document.tex

A PDF document named document.pdf should be produced and contain the following text:

A paragraph.

@@ -486,25 +597,25 @@ A paragraph.

A paragraph > Not a quote.

-
ConTeXt example
+
ConTeXt Example

Using a text editor, create a text document named document.tex with the following content:

-
\usemodule[t][markdown]
-\starttext
-
-\startmarkdown
-A paragraph.
-> A quote.
-\stopmarkdown
-
-\def\markdownOptionBlankBeforeBlockquote{true}
-\startmarkdown
-A paragraph.
-> Not a quote.
-\stopmarkdown
-
-\stoptext
+
\usemodule[t][markdown]
+\starttext
+
+\startmarkdown
+A paragraph.
+> A quote.
+\stopmarkdown
+
+\def\markdownOptionBlankBeforeBlockquote{true}
+\startmarkdown
+A paragraph.
+> Not a quote.
+\stopmarkdown
+
+\stoptext

Next, invoke LuaTeX from the terminal:

-
context document.tex
+
context document.tex

A PDF document named document.pdf should be produced and contain the following text:

A paragraph.

@@ -513,7 +624,7 @@ A paragraph.

A paragraph > Not a quote.

-
2.1.2.2.2 Option blankBeforeCodeFence
+

2.2.1.3 Option blankBeforeCodeFence

blankBeforeCodeFence (default value: false)
@@ -526,150 +637,150 @@ A paragraph.
-
Lua module example
-

Using a text editor, create a text document named document.tex with the following content:

-
\input markdown
-\input lmfonts
-\directlua{
-  local markdown = require("markdown")
-  local newline = [[^^J^^J]]
-  local convert, input
-
-  convert = markdown.new({fencedCode = true})
-  input = "A paragraph."   .. newline ..
-          "```"            .. newline ..
-          "A code fence."  .. newline ..
-          "```"            .. newline
-  tex.sprint(convert(input))
-
-  convert = markdown.new({
-    fencedCode = true, blankBeforeCodeFence = true})
-  input = "A paragraph."       .. newline ..
-          "```"                .. newline ..
-          "Not a code fence."  .. newline ..
-          "```"                .. newline
-  tex.sprint(convert(input)) }
-\bye
+
Lua Module Example
+

Using a text editor, create a text document named document.tex with the following content:

+
\input markdown
+\input lmfonts
+\directlua{
+  local markdown = require("markdown")
+  local newline = [[^^J^^J]]
+  local convert, input
+
+  convert = markdown.new({fencedCode = true})
+  input = "A paragraph."   .. newline ..
+          "```"            .. newline ..
+          "A code fence."  .. newline ..
+          "```"            .. newline
+  tex.sprint(convert(input))
+
+  convert = markdown.new({
+    fencedCode = true, blankBeforeCodeFence = true})
+  input = "A paragraph."       .. newline ..
+          "```"                .. newline ..
+          "Not a code fence."  .. newline ..
+          "```"                .. newline
+  tex.sprint(convert(input)) }
+\bye

Then, invoke LuaTeX from the terminal:

-
luatex document.tex
+
luatex document.tex

A PDF document named document.pdf should be produced and contain the following text:

A paragraph.

A code fence.

A paragraph. Not a code fence.

-
Lua CLI example
+
Lua CLI Example

Using a text editor, create a text document named document.tex with the following content:

-
\input markdown
-\input lmfonts
-\input optionfalse
-\input optiontrue
-\bye
+
\input markdown
+\input lmfonts
+\input optionfalse
+\input optiontrue
+\bye

Using a text editor, create a text document named content.md with the following content:

-
A paragraph.
-```
-A code fence?
-```
+
A paragraph.
+```
+A code fence?
+```

Next, invoke LuaTeX from the terminal:

-
texlua <CLI␣PATHNAME> fencedCode=true -- content.md optionfalse.tex
-texlua <CLI␣PATHNAME> fencedCode=true blankBeforeCodeFence=true  -- content.md optiontrue.tex
-luatex document.tex
-

where <CLI␣PATHNAME> corresponds to the location of the Lua CLI script file, such as ~/texmf/scripts/markdown/markdown-cli.lua on UN*X systems or C:\Users\<YOUR␣USERNAME>\texmf\scripts\markdown\markdown-cli.lua on Windows systems. Use the command kpsewhich markdown-cli.lua to locate the Lua CLI script file using Kpathsea.

+
texlua ⟨CLI pathname⟩ fencedCode=true -- content.md optionfalse.tex
+texlua ⟨CLI pathname⟩ fencedCode=true blankBeforeCodeFence=true  -- content.md optiontrue.tex
+luatex document.tex
+

where ⟨CLI pathname⟩ corresponds to the location of the Lua CLI script file, such as ~/texmf/scripts/markdown/markdown-cli.lua on UN*X systems or C:\Users\Your username\texmf\scripts\markdown\markdown-cli.lua on Windows systems. Use the command kpsewhich markdown-cli.lua to locate the Lua CLI script file using Kpathsea.

A PDF document named document.pdf should be produced and contain the following text:

A paragraph.

A code fence?

A paragraph. A code fence?

-
Plain TeX example
-

Using a text editor, create a text document named document.tex with the following content:

-
\input markdown
-\def\markdownOptionFencedCode{true}
-
-\markdownBegin
-A paragraph.
-```
-A code fence.
-```
-\markdownEnd
-
-\def\markdownOptionBlankBeforeCodeFence{true}
-\markdownBegin
-A paragraph.
-```
-Not a code fence.
-```
-\markdownEnd
-
-\bye
-

Next, invoke LuaTeX from the terminal:

-
luatex document.tex
+
Plain TeX Example
+

Using a text editor, create a text document named document.tex with the following content:

+
\input markdown
+\def\markdownOptionFencedCode{true}
+
+\markdownBegin
+A paragraph.
+```
+A code fence.
+```
+\markdownEnd
+
+\def\markdownOptionBlankBeforeCodeFence{true}
+\markdownBegin
+A paragraph.
+```
+Not a code fence.
+```
+\markdownEnd
+
+\bye
+

Next, invoke LuaTeX from the terminal:

+
luatex document.tex

A PDF document named document.pdf should be produced and contain the following text:

A paragraph.

A code fence.

A paragraph. Not a code fence.

-
LaTeX example
-

Using a text editor, create a text document named document.tex with the following content:

-
\documentclass{article}
-\usepackage[fencedCode]{markdown}
-\begin{document}
-
-\begin{markdown}
-A paragraph.
-```
-A code fence.
-```
-\end{markdown}
-
-\begin{markdown*}{blankBeforeCodeFence}
-A paragraph.
-```
-Not a code fence.
-```
-\end{markdown*}
-
-\end{document}
-

Next, invoke LuaTeX from the terminal:

-
lualatex document.tex
+
LaTeX Example
+

Using a text editor, create a text document named document.tex with the following content:

+
\documentclass{article}
+\usepackage[fencedCode]{markdown}
+\begin{document}
+
+\begin{markdown}
+A paragraph.
+```
+A code fence.
+```
+\end{markdown}
+
+\begin{markdown*}{blankBeforeCodeFence}
+A paragraph.
+```
+Not a code fence.
+```
+\end{markdown*}
+
+\end{document}
+

Next, invoke LuaTeX from the terminal:

+
lualatex document.tex

A PDF document named document.pdf should be produced and contain the following text:

A paragraph.

A code fence.

A paragraph. Not a code fence.

-
ConTeXt example
-

Using a text editor, create a text document named document.tex with the following content:

-
\usemodule[t][markdown]
-\def\markdownOptionFencedCode{true}
-\starttext
-
-\startmarkdown
-A paragraph.
-```
-A code fence.
-```
-\stopmarkdown
-
-\def\markdownOptionBlankBeforeCodeFence{true}
-\startmarkdown
-A paragraph.
-```
-Not a code fence.
-```
-\stopmarkdown
-
-\stoptext
-

Next, invoke LuaTeX from the terminal:

-
context document.tex
+
ConTeXt Example
+

Using a text editor, create a text document named document.tex with the following content:

+
\usemodule[t][markdown]
+\def\markdownOptionFencedCode{true}
+\starttext
+
+\startmarkdown
+A paragraph.
+```
+A code fence.
+```
+\stopmarkdown
+
+\def\markdownOptionBlankBeforeCodeFence{true}
+\startmarkdown
+A paragraph.
+```
+Not a code fence.
+```
+\stopmarkdown
+
+\stoptext
+

Next, invoke LuaTeX from the terminal:

+
context document.tex

A PDF document named document.pdf should be produced and contain the following text:

A paragraph.

A code fence.

A paragraph. Not a code fence.

-
2.1.2.2.3 Option blankBeforeHeading
+

2.2.1.4 Option blankBeforeHeading

blankBeforeHeading (default value: false)
@@ -682,139 +793,139 @@ Not a code fence.
-
Lua module example
-

Using a text editor, create a text document named document.tex with the following content:

-
\input markdown
-\input lmfonts
-\def\markdownRendererHeadingOne#1{{\bf #1}\par}
-\directlua{
-  local markdown = require("markdown")
-  local newline = [[^^J^^J]]
-  local convert, input
-
-  convert = markdown.new()
-  input = "A paragraph." .. newline ..
-          "A heading."   .. newline ..
-          "=========="   .. newline
-  tex.sprint(convert(input))
-
-  convert = markdown.new({blankBeforeHeading = true})
-  input = "A paragraph."    .. newline ..
-          "Not a heading."  .. newline ..
-          "=============="  .. newline
-  tex.sprint(convert(input)) }
-\bye
+
Lua Module Example
+

Using a text editor, create a text document named document.tex with the following content:

+
\input markdown
+\input lmfonts
+\def\markdownRendererHeadingOne#1{{\bf #1}\par}
+\directlua{
+  local markdown = require("markdown")
+  local newline = [[^^J^^J]]
+  local convert, input
+
+  convert = markdown.new()
+  input = "A paragraph." .. newline ..
+          "A heading."   .. newline ..
+          "=========="   .. newline
+  tex.sprint(convert(input))
+
+  convert = markdown.new({blankBeforeHeading = true})
+  input = "A paragraph."    .. newline ..
+          "Not a heading."  .. newline ..
+          "=============="  .. newline
+  tex.sprint(convert(input)) }
+\bye

Then, invoke LuaTeX from the terminal:

-
luatex document.tex
+
luatex document.tex

A PDF document named document.pdf should be produced and contain the following text:

A paragraph.

A heading.

A paragraph. Not a heading. ==============

-
Lua CLI example
+
Lua CLI Example

Using a text editor, create a text document named document.tex with the following content:

-
\input markdown
-\input lmfonts
-\input optionfalse
-\input optiontrue
-\bye
+
\input markdown
+\input lmfonts
+\input optionfalse
+\input optiontrue
+\bye

Using a text editor, create a text document named content.md with the following content:

-
A paragraph.
-A heading?
-==========
+
A paragraph.
+A heading?
+==========

Next, invoke LuaTeX from the terminal:

-
texlua <CLI␣PATHNAME> -- content.md optionfalse.tex
-texlua <CLI␣PATHNAME> blankBeforeHeading=true  -- content.md optiontrue.tex
-luatex document.tex
-

where <CLI␣PATHNAME> corresponds to the location of the Lua CLI script file, such as ~/texmf/scripts/markdown/markdown-cli.lua on UN*X systems or C:\Users\<YOUR␣USERNAME>\texmf\scripts\markdown\markdown-cli.lua on Windows systems. Use the command kpsewhich markdown-cli.lua to locate the Lua CLI script file using Kpathsea.

+
texlua ⟨CLI pathname⟩ -- content.md optionfalse.tex
+texlua ⟨CLI pathname⟩ blankBeforeHeading=true  -- content.md optiontrue.tex
+luatex document.tex
+

where ⟨CLI pathname⟩ corresponds to the location of the Lua CLI script file, such as ~/texmf/scripts/markdown/markdown-cli.lua on UN*X systems or C:\Users\Your username\texmf\scripts\markdown\markdown-cli.lua on Windows systems. Use the command kpsewhich markdown-cli.lua to locate the Lua CLI script file using Kpathsea.

A PDF document named document.pdf should be produced and contain the following text:

A paragraph.

A heading?

A paragraph. A heading? ==========

-
Plain TeX example
+
Plain TeX Example

Using a text editor, create a text document named document.tex with the following content:

-
\input markdown
-
-\markdownBegin
-A paragraph.
-A heading.
-==========
-\markdownEnd
-
-\def\markdownOptionBlankBeforeHeading{true}
-\markdownBegin
-A paragraph.
-Not a heading.
-==============
-\markdownEnd
-
-\bye
+
\input markdown
+
+\markdownBegin
+A paragraph.
+A heading.
+==========
+\markdownEnd
+
+\def\markdownOptionBlankBeforeHeading{true}
+\markdownBegin
+A paragraph.
+Not a heading.
+==============
+\markdownEnd
+
+\bye

Next, invoke LuaTeX from the terminal:

-
luatex document.tex
+
luatex document.tex

A PDF document named document.pdf should be produced and contain the following text:

A paragraph.

A heading.

A paragraph. Not a heading. ==============

-
LaTeX example
-

Using a text editor, create a text document named document.tex with the following content:

-
\documentclass{article}
-\usepackage{markdown}
-\begin{document}
-
-\begin{markdown}
-A paragraph.
-A heading.
-==========
-\end{markdown}
-
-\begin{markdown*}{blankBeforeHeading}
-A paragraph.
-Not a heading.
-==============
-\end{markdown*}
-
-\end{document}
-

Next, invoke LuaTeX from the terminal:

-
lualatex document.tex
+
LaTeX Example
+

Using a text editor, create a text document named document.tex with the following content:

+
\documentclass{article}
+\usepackage{markdown}
+\begin{document}
+
+\begin{markdown}
+A paragraph.
+A heading.
+==========
+\end{markdown}
+
+\begin{markdown*}{blankBeforeHeading}
+A paragraph.
+Not a heading.
+==============
+\end{markdown*}
+
+\end{document}
+

Next, invoke LuaTeX from the terminal:

+
lualatex document.tex

A PDF document named document.pdf should be produced and contain the following text:

A paragraph.

A heading.

A paragraph. Not a heading. ==============

-
ConTeXt example
-

Using a text editor, create a text document named document.tex with the following content:

-
\usemodule[t][markdown]
-\starttext
-
-\startmarkdown
-A paragraph.
-A heading.
-==========
-\stopmarkdown
-
-\def\markdownOptionBlankBeforeHeading{true}
-\startmarkdown
-A paragraph.
-Not a heading.
-==============
-\stopmarkdown
-
-\stoptext
-

Next, invoke LuaTeX from the terminal:

-
context document.tex
+
ConTeXt Example
+

Using a text editor, create a text document named document.tex with the following content:

+
\usemodule[t][markdown]
+\starttext
+
+\startmarkdown
+A paragraph.
+A heading.
+==========
+\stopmarkdown
+
+\def\markdownOptionBlankBeforeHeading{true}
+\startmarkdown
+A paragraph.
+Not a heading.
+==============
+\stopmarkdown
+
+\stoptext
+

Next, invoke LuaTeX from the terminal:

+
context document.tex

A PDF document named document.pdf should be produced and contain the following text:

A paragraph.

A heading.

A paragraph. Not a heading. ==============

-
2.1.2.2.4 Option breakableBlockquotes
+

2.2.1.5 Option breakableBlockquotes

breakableBlockquotes (default value: false)
@@ -827,28 +938,28 @@ Not a heading.
-
Lua module example
-

Using a text editor, create a text document named document.tex with the following content:

-
\input markdown
-\input lmfonts
-\def\markdownRendererHeadingOne#1{{\bf #1}\par}
-\directlua{
-  local markdown = require("markdown")
-  local newline = [[^^J^^J]]
-  local convert, input
-
-  convert = markdown.new()
-  input = "> A single"     .. newline .. newline ..
-          "> block quote." .. newline
-  tex.sprint(convert(input))
-
-  convert = markdown.new({breakableBlockquotes = true})
-  input = "> A block quote."       .. newline .. newline ..
-          "> Another block quote." .. newline
-  tex.sprint(convert(input)) }
-\bye
+
Lua Module Example
+

Using a text editor, create a text document named document.tex with the following content:

+
\input markdown
+\input lmfonts
+\def\markdownRendererHeadingOne#1{{\bf #1}\par}
+\directlua{
+  local markdown = require("markdown")
+  local newline = [[^^J^^J]]
+  local convert, input
+
+  convert = markdown.new()
+  input = "> A single"     .. newline .. newline ..
+          "> block quote." .. newline
+  tex.sprint(convert(input))
+
+  convert = markdown.new({breakableBlockquotes = true})
+  input = "> A block quote."       .. newline .. newline ..
+          "> Another block quote." .. newline
+  tex.sprint(convert(input)) }
+\bye

Then, invoke LuaTeX from the terminal:

-
luatex document.tex
+
luatex document.tex

A PDF document named document.pdf should be produced and contain the following text:

@@ -861,22 +972,22 @@ Not a heading.

Another block quote.

-
Lua CLI example
+
Lua CLI Example

Using a text editor, create a text document named document.tex with the following content:

-
\input markdown
-\input lmfonts
-\input optionfalse
-\input optiontrue
-\bye
+
\input markdown
+\input lmfonts
+\input optionfalse
+\input optiontrue
+\bye

Using a text editor, create a text document named content.md with the following content:

-
> A single block quote
-
-> or two block quotes?
+
> A single block quote
+
+> or two block quotes?

Next, invoke LuaTeX from the terminal:

-
texlua <CLI␣PATHNAME> -- content.md optionfalse.tex
-texlua <CLI␣PATHNAME> breakableBlockquotes=true  -- content.md optiontrue.tex
-luatex document.tex
-

where <CLI␣PATHNAME> corresponds to the location of the Lua CLI script file, such as ~/texmf/scripts/markdown/markdown-cli.lua on UN*X systems or C:\Users\<YOUR␣USERNAME>\texmf\scripts\markdown\markdown-cli.lua on Windows systems. Use the command kpsewhich markdown-cli.lua to locate the Lua CLI script file using Kpathsea.

+
texlua ⟨CLI pathname⟩ -- content.md optionfalse.tex
+texlua ⟨CLI pathname⟩ breakableBlockquotes=true  -- content.md optiontrue.tex
+luatex document.tex
+

where ⟨CLI pathname⟩ corresponds to the location of the Lua CLI script file, such as ~/texmf/scripts/markdown/markdown-cli.lua on UN*X systems or C:\Users\Your username\texmf\scripts\markdown\markdown-cli.lua on Windows systems. Use the command kpsewhich markdown-cli.lua to locate the Lua CLI script file using Kpathsea.

A PDF document named document.pdf should be produced and contain the following text:

@@ -889,26 +1000,26 @@ Not a heading.

or two block quotes?

-
Plain TeX example
+
Plain TeX Example

Using a text editor, create a text document named document.tex with the following content:

-
\input markdown
-
-\markdownBegin
-> A single
-
-> block quote.
-\markdownEnd
-
-\def\markdownOptionBreakableBlockquotes{true}
-\markdownBegin
-> A block quote.
-
-> Another block quote.
-\markdownEnd
-
-\bye
+
\input markdown
+
+\markdownBegin
+> A single
+
+> block quote.
+\markdownEnd
+
+\def\markdownOptionBreakableBlockquotes{true}
+\markdownBegin
+> A block quote.
+
+> Another block quote.
+\markdownEnd
+
+\bye

Next, invoke LuaTeX from the terminal:

-
luatex document.tex
+
luatex document.tex

A PDF document named document.pdf should be produced and contain the following text:

@@ -921,27 +1032,27 @@ Not a heading.

Another block quote.

-
LaTeX example
+
LaTeX Example

Using a text editor, create a text document named document.tex with the following content:

-
\documentclass{article}
-\usepackage{markdown}
-\begin{document}
-
-\begin{markdown}
-> A single
-
-> block quote.
-\end{markdown}
-
-\begin{markdown*}{breakableBlockquotes}
-> A block quote.
-
-> Another block quote.
-\end{markdown*}
-
-\end{document}
+
\documentclass{article}
+\usepackage{markdown}
+\begin{document}
+
+\begin{markdown}
+> A single
+
+> block quote.
+\end{markdown}
+
+\begin{markdown*}{breakableBlockquotes}
+> A block quote.
+
+> Another block quote.
+\end{markdown*}
+
+\end{document}

Next, invoke LuaTeX from the terminal:

-
lualatex document.tex
+
lualatex document.tex

A PDF document named document.pdf should be produced and contain the following text:

@@ -954,27 +1065,27 @@ Not a heading.

Another block quote.

-
ConTeXt example
+
ConTeXt Example

Using a text editor, create a text document named document.tex with the following content:

-
\usemodule[t][markdown]
-\starttext
-
-\startmarkdown
-> A single
-
-> block quote.
-\stopmarkdown
-
-\def\markdownOptionBreakableBlockquotes{true}
-\startmarkdown
-> A block quote.
-
-> Another block quote.
-\stopmarkdown
-
-\stoptext
+
\usemodule[t][markdown]
+\starttext
+
+\startmarkdown
+> A single
+
+> block quote.
+\stopmarkdown
+
+\def\markdownOptionBreakableBlockquotes{true}
+\startmarkdown
+> A block quote.
+
+> Another block quote.
+\stopmarkdown
+
+\stoptext

Next, invoke LuaTeX from the terminal:

-
context document.tex
+
context document.tex

A PDF document named document.pdf should be produced and contain the following text:

@@ -987,7 +1098,7 @@ Not a heading.

Another block quote.

-
2.1.2.2.5 Option citationNbsps
+

2.2.1.6 Option citationNbsps

citationNbsps (default value: true)
@@ -1000,60 +1111,61 @@ Not a heading.
-
LaTeX example
+
LaTeX Example

Using a text editor, create a text document named document.bib with the following content:

-
@book{knuth:tex,
-  author    = "Knuth, Donald Ervin",
-  title     = "The \TeX book, volume A of Computers and typesetting",
-  publisher = "Addison-Wesley",
-  year      = "1984" }
-

Using a text editor, create a text document named document.tex with the following content:

-
\documentclass{article}
-\usepackage[citations]{markdown}
-\begin{document}
-
-\begin{markdown}
-The TeXbook [@knuth:tex, p. 123 and 130] is good.
-\end{markdown}
-
-\begin{markdown*}{citationNbsps = false}
-The TeXbook [@knuth:tex, p. 123 and 130] is good.
-\end{markdown*}
-
-\bibliographystyle{plain}
-\bibliography{document.bib}
-\end{document}
+
@book{knuth:tex,
+  author    = "Knuth, Donald Ervin",
+  title     = "The \TeX book, volume A of Computers and typesetting",
+  publisher = "Addison-Wesley",
+  year      = "1984"
+}
+

Using a text editor, create a text document named document.tex with the following content:

+
\documentclass{article}
+\usepackage[citations]{markdown}
+\begin{document}
+
+\begin{markdown}
+The TeXbook [@knuth:tex, p. 123 and 130] is good.
+\end{markdown}
+
+\begin{markdown*}{citationNbsps = false}
+The TeXbook [@knuth:tex, p. 123 and 130] is good.
+\end{markdown*}
+
+\bibliographystyle{plain}
+\bibliography{document.bib}
+\end{document}

Next, invoke LuaTeX and BibTeX from the terminal:

-
lualatex document.tex
-bibtex document.aux
-lualatex document.tex
-lualatex document.tex
+
lualatex document.tex
+bibtex document.aux
+lualatex document.tex
+lualatex document.tex

A PDF document named document.pdf should be produced and contain the following text, where the middot (·) denotes a non-breakable space:

The TeXbook [1, p.·123·and·130] is good.

-

The TeXbook [1, p. 123 and 130] is good.

+

The TeXbook [1, p. 123 and 130] is good.

References

[1] Donald·Ervin Knuth. The TeXbook, volume A of Computers and typesetting. Addison-Wesley, 1984.

-
2.1.2.2.6 Option citations
+

2.2.1.7 Option citations

citations (default value: false)
true

Enable the pandoc citation syntax extension:

-
Here is a simple parenthetical citation [@doe99] and here
-is a string of several [see @doe99, pp. 33-35; also
-@smith04, chap. 1].
-
-A parenthetical citation can have a [prenote @doe99] and
-a [@smith04 postnote]. The name of the author can be
-suppressed by inserting a dash before the name of an
-author as follows [-@smith04].
-
-Here is a simple text citation @doe99 and here is
-a string of several @doe99 [pp. 33-35; also @smith04,
-chap. 1]. Here is one with the name of the author
-suppressed -@doe99.
+
@@ -1064,45 +1176,46 @@ suppressed -@doe99.
-
LaTeX example
+
LaTeX Example

Using a text editor, create a text document named document.bib with the following content:

-
@book{knuth:tex,
-  author    = "Knuth, Donald Ervin",
-  title     = "The \TeX book, volume A of Computers and typesetting",
-  publisher = "Addison-Wesley",
-  year      = "1984" }
-

Using a text editor, create a text document named document.tex with the following content:

-
\documentclass{article}
-\usepackage[backend=biber]{biblatex}
-\addbibresource{document.bib}
-\usepackage[citations]{markdown}
-\begin{document}
-
-\begin{markdown}
-The TeXbook [@knuth:tex, p. 123 and 130] was written by @knuth:tex.
-\end{markdown}
-
-\printbibliography
-\end{document}
+
@book{knuth:tex,
+  author    = "Knuth, Donald Ervin",
+  title     = "The \TeX book, volume A of Computers and typesetting",
+  publisher = "Addison-Wesley",
+  year      = "1984"
+}
+

Using a text editor, create a text document named document.tex with the following content:

+
\documentclass{article}
+\usepackage[backend=biber]{biblatex}
+\addbibresource{document.bib}
+\usepackage[citations]{markdown}
+\begin{document}
+
+\begin{markdown}
+The TeXbook [@knuth:tex, p. 123 and 130] was written by @knuth:tex.
+\end{markdown}
+
+\printbibliography
+\end{document}

Next, invoke LuaTeX and Biber from the terminal:

-
lualatex document.tex
-biber document.bcf
-lualatex document.tex
-lualatex document.tex
+
lualatex document.tex
+biber document.bcf
+lualatex document.tex
+lualatex document.tex

A PDF document named document.pdf should be produced and contain the following text:

The TeXbook [1, p.·123 and 130] was written by Knuth [1].

References

-

[1] Donald Ervin Knuth. The TeXbook, volume A of Computers and typesetting. Addison-Wesley, 1984.

+

[1] Donald Ervin Knuth. The TeXbook, volume A of Computers and typesetting. Addison-Wesley, 1984.

-
2.1.2.2.7 Option codeSpans
+

2.2.1.8 Option codeSpans

codeSpans (default value: true)
true

Enable the code span syntax:

-
Use the `printf()` function.
-``There is a literal backtick (`) here.``
+
@@ -1114,136 +1227,136 @@ The TeXbook [@knuth:tex, p. 123 and 130] was written by @knuth:tex.
-
Lua module example
-

Using a text editor, create a text document named document.tex with the following content:

-
\input markdown
-\input lmfonts
-\directlua{
-  local markdown = require("markdown")
-  local convert = markdown.new()
-  local input =
-    "``This is a code span.'' " ..
-    "``This is no longer a code span.''"
-  tex.sprint(convert(input)) }
-\par
-\directlua{
-  local markdown = require("markdown")
-  local convert = markdown.new({codeSpans = false})
-  local input =
-    "``This is a quote.'' " ..
-    "``This is another quote.''"
-  tex.sprint(convert(input)) }
-\bye
+
Lua Module Example
+

Using a text editor, create a text document named document.tex with the following content:

+
\input markdown
+\input lmfonts
+\directlua{
+  local markdown = require("markdown")
+  local convert = markdown.new()
+  local input =
+    "``This is a code span.'' " ..
+    "``This is no longer a code span.''"
+  tex.sprint(convert(input)) }
+\par
+\directlua{
+  local markdown = require("markdown")
+  local convert = markdown.new({codeSpans = false})
+  local input =
+    "``This is a quote.'' " ..
+    "``This is another quote.''"
+  tex.sprint(convert(input)) }
+\bye

Then, invoke LuaTeX from the terminal:

-
luatex document.tex
+
luatex document.tex

A PDF document named document.pdf should be produced and contain the following text:

-

This is a code span.''This is no longer a code span.''

+

This is a code span.''This is no longer a code span.’’

“This is a quote.” “This is another quote.”

-
Lua CLI example
+
Lua CLI Example

Using a text editor, create a text document named document.tex with the following content:

-
\input markdown
-\input lmfonts
-\input optionfalse
-\par
-\input optiontrue
-\bye
+
\input markdown
+\input lmfonts
+\input optionfalse
+\par
+\input optiontrue
+\bye

Using a text editor, create a text document named content.md with the following content:

-
``Is this a code span?'' ``Or a quote?''
+
``Is this a code span?'' ``Or a quote?''

Next, invoke LuaTeX from the terminal:

-
texlua <CLI␣PATHNAME> codeSpans=false -- content.md optionfalse.tex
-texlua <CLI␣PATHNAME> -- content.md optiontrue.tex
-luatex document.tex
-

where <CLI␣PATHNAME> corresponds to the location of the Lua CLI script file, such as ~/texmf/scripts/markdown/markdown-cli.lua on UN*X systems or C:\Users\<YOUR␣USERNAME>\texmf\scripts\markdown\markdown-cli.lua on Windows systems. Use the command kpsewhich markdown-cli.lua to locate the Lua CLI script file using Kpathsea.

+
texlua ⟨CLI pathname⟩ codeSpans=false -- content.md optionfalse.tex
+texlua ⟨CLI pathname⟩ -- content.md optiontrue.tex
+luatex document.tex
+

where ⟨CLI pathname⟩ corresponds to the location of the Lua CLI script file, such as ~/texmf/scripts/markdown/markdown-cli.lua on UN*X systems or C:\Users\Your username\texmf\scripts\markdown\markdown-cli.lua on Windows systems. Use the command kpsewhich markdown-cli.lua to locate the Lua CLI script file using Kpathsea.

A PDF document named document.pdf should be produced and contain the following text:

“Is this a code span?” “Or a quote?”

-

Is this a code span?''Or a quote?''

+

Is this a code span?''Or a quote?’’

-
Plain TeX example
+
Plain TeX Example

Using a text editor, create a text document named document.tex with the following content:

-
\input markdown
-
-\markdownBegin
-``This is a code span.''
-``This is no longer a code span.''
-\markdownEnd
-
-\def\markdownOptionCodeSpans{false}
-\markdownBegin
-``This is a quote.''
-``This is another quote.''
-\markdownEnd
-
-\bye
+
\input markdown
+
+\markdownBegin
+``This is a code span.''
+``This is no longer a code span.''
+\markdownEnd
+
+\def\markdownOptionCodeSpans{false}
+\markdownBegin
+``This is a quote.''
+``This is another quote.''
+\markdownEnd
+
+\bye

Next, invoke LuaTeX from the terminal:

-
luatex document.tex
+
luatex document.tex

A PDF document named document.pdf should be produced and contain the following text:

-

This is a code span.''This is no longer a code span.''

+

This is a code span.''This is no longer a code span.’’

“This is a quote.” “This is another quote.”

-
LaTeX example
+
LaTeX Example

Using a text editor, create a text document named document.tex with the following content:

-
\documentclass{article}
-\usepackage{markdown}
-\begin{document}
-
-\begin{markdown}
-``This is a code span.''
-``This is no longer a code span.''
-\end{markdown}
-
-\begin{markdown*}{codeSpans=false}
-``This is a quote.''
-``This is another quote.''
-\end{markdown*}
-
-\end{document}
+
\documentclass{article}
+\usepackage{markdown}
+\begin{document}
+
+\begin{markdown}
+``This is a code span.''
+``This is no longer a code span.''
+\end{markdown}
+
+\begin{markdown*}{codeSpans=false}
+``This is a quote.''
+``This is another quote.''
+\end{markdown*}
+
+\end{document}

Next, invoke LuaTeX from the terminal:

-
lualatex document.tex
+
lualatex document.tex

A PDF document named document.pdf should be produced and contain the following text:

-

This is a code span.''This is no longer a code span.''

+

This is a code span.''This is no longer a code span.’’

“This is a quote.” “This is another quote.”

-
ConTeXt example
+
ConTeXt Example

Using a text editor, create a text document named document.tex with the following content:

-
\usemodule[t][markdown]
-\starttext
-
-\startmarkdown
-``This is a code span.''
-``This is no longer a code span.''
-\stopmarkdown
-
-\def\markdownOptionCodeSpans{false}
-\startmarkdown
-``This is a quote.''
-``This is another quote.''
-\stopmarkdown
-
-\stoptext
+
\usemodule[t][markdown]
+\starttext
+
+\startmarkdown
+``This is a code span.''
+``This is no longer a code span.''
+\stopmarkdown
+
+\def\markdownOptionCodeSpans{false}
+\startmarkdown
+``This is a quote.''
+``This is another quote.''
+\stopmarkdown
+
+\stoptext

Next, invoke LuaTeX from the terminal:

-
context document.tex
+
context document.tex

A PDF document named document.pdf should be produced and contain the following text:

-

This is a code span.''This is no longer a code span.''

+

This is a code span.''This is no longer a code span.’’

“This is a quote.” “This is another quote.”

-
2.1.2.2.8 Option contentBlocks
+

2.2.1.9 Option contentBlocks

contentBlocks (default value: false)
true

Enable the iA Writer content blocks syntax extension:

-
http://example.com/minard.jpg (Napoleon's
-  disastrous Russian campaign of 1812)
-/Flowchart.png "Engineering Flowchart"
-/Savings Account.csv 'Recent Transactions'
-/Example.swift
-/Lorem Ipsum.txt
+
@@ -1254,33 +1367,33 @@ The TeXbook [@knuth:tex, p. 123 and 130] was written by @knuth:tex.
-
LaTeX example
+
LaTeX Example

Using a text editor, create a text document named table.csv with the following content:

Name,Surname,Born
 Albert,Einstein,1879
 Marie,Curie,1867
 Thomas,Edison,1847

Create also a text document named markdown-languages.json with the following content:

-
{
-  "tex": "LaTeX"
-}
+
{
+  "tex": "LaTeX"
+}

Create also a text document named code.tex with the following content:

-
This is an example code listing in \LaTeX.
+
This is an example code listing in \LaTeX.

Create also a text document named part.md with the following content:

-
This is a *transcluded markdown document*.
+
This is a *transcluded markdown document*.

Create also a text document named document.tex with the following content:

-
\documentclass{article}
-\usepackage{minted}
-\usepackage[contentBlocks]{markdown}
-\begin{document}
-\begin{markdown}
-/table.csv  (An example table)
-/code.tex   (An example code listing)
-/part.md    (A file transclusion example)
-\end{markdown}
-\end{document}
+
\documentclass{article}
+\usepackage{minted}
+\usepackage[contentBlocks]{markdown}
+\begin{document}
+\begin{markdown}
+/table.csv  (An example table)
+/code.tex   (An example code listing)
+/part.md    (A file transclusion example)
+\end{markdown}
+\end{document}

Next, invoke LuaTeX from the terminal:

-
lualatex --shell-escape document.tex
+
lualatex --shell-escape document.tex

A PDF document named document.pdf should be produced and contain the following text:

@@ -1310,37 +1423,37 @@ Thomas,Edison,1847

Table 1: An example table

-
This is an example code listing in \LaTeX.
+

This is a transcluded markdown document.

-
ConTeXt example
+
ConTeXt Example

Using a text editor, create a text document named table.csv with the following content:

Name,Surname,Born
 Albert,Einstein,1879
 Marie,Curie,1867
 Thomas,Edison,1847

Create also a text document named markdown-languages.json with the following content:

-
{
-  "tex": "ConTeXt"
-}
+
{
+  "tex": "ConTeXt"
+}

Create also a text document named code.tex with the following content:

-
This is an example code listing in \ConTeXt.
+
This is an example code listing in \ConTeXt.

Create also a text document named part.md with the following content:

-
This is a *transcluded markdown document*.
+
This is a *transcluded markdown document*.

Create also a text document named document.tex with the following content:

-
\usemodule[t][markdown]
-\def\markdownOptionContentBlocks{true}
-\definetyping [ConTeXt]
-\setuptyping  [ConTeXt] [option=TEX]
-\starttext
-\startmarkdown
-/table.csv  (An example table)
-/code.tex   (An example code listing)
-/part.md    (A file transclusion example)
-\stopmarkdown
-\stoptext
+
\usemodule[t][markdown]
+\def\markdownOptionContentBlocks{true}
+\definetyping [ConTeXt]
+\setuptyping  [ConTeXt] [option=TEX]
+\starttext
+\startmarkdown
+/table.csv  (An example table)
+/code.tex   (An example code listing)
+/part.md    (A file transclusion example)
+\stopmarkdown
+\stoptext

Next, invoke LuaTeX from the terminal:

-
context document.tex
+
context document.tex

A PDF document named document.pdf should be produced and contain the following text:

@@ -1370,45 +1483,45 @@ Thomas,Edison,1847

Table 1: An example table

-
This is an example code listing in \ConTeXt.
+

This is a transcluded markdown document.

-
2.1.2.2.9 Option contentBlocksLanguageMap
+

2.2.1.10 Option contentBlocksLanguageMap

contentBlocksLanguageMap (default value: "markdown-languages.json")

The filename of the JSON file that maps filename extensions to programming language names in the iA Writer content blocks.

-
LaTeX example
+
LaTeX Example

Using a text editor, create a text document named table.csv with the following content:

Name,Surname,Born
 Albert,Einstein,1879
 Marie,Curie,1867
 Thomas,Edison,1847

Create also a text document named language-map.json with the following content:

-
{
-  "tex": "LaTeX"
-}
+
{
+  "tex": "LaTeX"
+}

Create also a text document named code.tex with the following content:

-
This is an example code listing in \LaTeX.
+
This is an example code listing in \LaTeX.

Create also a text document named part.md with the following content:

-
This is a *transcluded markdown document*.
+
This is a *transcluded markdown document*.

Create also a text document named document.tex with the following content:

-
\documentclass{article}
-\usepackage{minted}
-\usepackage[contentBlocks]{markdown}
-\markdownSetup{
-  contentBlocksLanguageMap = {language-map.json},
-}
-\begin{document}
-\begin{markdown}
-/table.csv  (An example table)
-/code.tex   (An example code listing)
-/part.md    (A file transclusion example)
-\end{markdown}
-\end{document}
+
\documentclass{article}
+\usepackage{minted}
+\usepackage[contentBlocks]{markdown}
+\markdownSetup{
+  contentBlocksLanguageMap = {language-map.json},
+}
+\begin{document}
+\begin{markdown}
+/table.csv  (An example table)
+/code.tex   (An example code listing)
+/part.md    (A file transclusion example)
+\end{markdown}
+\end{document}

Next, invoke LuaTeX from the terminal:

-
lualatex --shell-escape document.tex
+
lualatex --shell-escape document.tex

A PDF document named document.pdf should be produced and contain the following text:

@@ -1438,38 +1551,38 @@ Thomas,Edison,1847

Table 1: An example table

-
This is an example code listing in \LaTeX.
+

This is a transcluded markdown document.

-
ConTeXt example
+
ConTeXt Example

Using a text editor, create a text document named table.csv with the following content:

Name,Surname,Born
 Albert,Einstein,1879
 Marie,Curie,1867
 Thomas,Edison,1847

Create also a text document named language-map.json with the following content:

-
{
-  "tex": "ConTeXt"
-}
+
{
+  "tex": "ConTeXt"
+}

Create also a text document named code.tex with the following content:

-
This is an example code listing in \ConTeXt.
+
This is an example code listing in \ConTeXt.

Create also a text document named part.md with the following content:

-
This is a *transcluded markdown document*.
+
This is a *transcluded markdown document*.

Create also a text document named document.tex with the following content:

-
\usemodule[t][markdown]
-\def\markdownOptionContentBlocks{true}
-\def\markdownOptionContentBlocksLanguageMap{language-map.json}
-\definetyping [ConTeXt]
-\setuptyping  [ConTeXt] [option=TEX]
-\starttext
-\startmarkdown
-/table.csv  (An example table)
-/code.tex   (An example code listing)
-/part.md    (A file transclusion example)
-\stopmarkdown
-\stoptext
-

Next, invoke LuaTeX from the terminal:

-
context document.tex
+
\usemodule[t][markdown]
+\def\markdownOptionContentBlocks{true}
+\def\markdownOptionContentBlocksLanguageMap{language-map.json}
+\definetyping [ConTeXt]
+\setuptyping  [ConTeXt] [option=TEX]
+\starttext
+\startmarkdown
+/table.csv  (An example table)
+/code.tex   (An example code listing)
+/part.md    (A file transclusion example)
+\stopmarkdown
+\stoptext
+

Next, invoke LuaTeX from the terminal:

+
context document.tex

A PDF document named document.pdf should be produced and contain the following text:

@@ -1499,26 +1612,26 @@ Thomas,Edison,1847

Table 1: An example table

-
This is an example code listing in \ConTeXt.
+

This is a transcluded markdown document.

-
2.1.2.2.10 Option definitionLists
+

2.2.1.11 Option definitionLists

definitionLists (default value: false)
true

Enable the pandoc definition list syntax extension:

-
Term 1
-
-:   Definition 1
-
-Term 2 with *inline markup*
-
-:   Definition 2
-
-        { some code, part of Definition 2 }
-
-    Third paragraph of definition 2.
+
@@ -1529,27 +1642,27 @@ Term 2 with *inline markup*
-
LaTeX example
-

Using a text editor, create a text document named document.tex with the following content:

-
\documentclass{article}
-\usepackage[definitionLists]{markdown}
-\begin{document}
-\begin{markdown}
-Term 1
-
-:   Definition 1
-
-Term 2 with *inline markup*
-
-:   Definition 2
-
-        { some code, part of Definition 2 }
-
-    Third paragraph of definition 2.
-\end{markdown}
-\end{document}
-

Next, invoke LuaTeX from the terminal:

-
lualatex document.tex
+
LaTeX Example
+

Using a text editor, create a text document named document.tex with the following content:

+
\documentclass{article}
+\usepackage[definitionLists]{markdown}
+\begin{document}
+\begin{markdown}
+Term 1
+
+:   Definition 1
+
+Term 2 with *inline markup*
+
+:   Definition 2
+
+        { some code, part of Definition 2 }
+
+    Third paragraph of definition 2.
+\end{markdown}
+\end{document}
+

Next, invoke LuaTeX from the terminal:

+
lualatex document.tex

A PDF document named document.pdf should be produced and contain the following text:

@@ -1563,27 +1676,27 @@ Term 2 with *inline markup*
-
ConTeXt example
-

Using a text editor, create a text document named document.tex with the following content:

-
\usemodule[t][markdown]
-\def\markdownOptionDefinitionLists{true}
-\starttext
-\startmarkdown
-Term 1
-
-:   Definition 1
-
-Term 2 with *inline markup*
-
-:   Definition 2
-
-        { some code, part of Definition 2 }
-
-    Third paragraph of definition 2.
-\stopmarkdown
-\stoptext
-

Next, invoke LuaTeX from the terminal:

-
context document.tex
+
ConTeXt Example
+

Using a text editor, create a text document named document.tex with the following content:

+
\usemodule[t][markdown]
+\def\markdownOptionDefinitionLists{true}
+\starttext
+\startmarkdown
+Term 1
+
+:   Definition 1
+
+Term 2 with *inline markup*
+
+:   Definition 2
+
+        { some code, part of Definition 2 }
+
+    Third paragraph of definition 2.
+\stopmarkdown
+\stoptext
+

Next, invoke LuaTeX from the terminal:

+
context document.tex

A PDF document named document.pdf should be produced and contain the following text:

@@ -1597,28 +1710,28 @@ Term 2 with *inline markup*
-
2.1.2.2.11 Option fencedCode
+

2.2.1.12 Option fencedCode

fencedCode (default value: false)
true

Enable the commonmark fenced code block extension:

-
~~~ js
-if (a > 3) {
-    moveShip(5 * gravity, DOWN);
-}
-~~~~~~
-
-  ``` html
-  <pre>
-    <code>
-      // Some comments
-      line 1 of code
-      line 2 of code
-      line 3 of code
-    </code>
-  </pre>
-  ```
+
@@ -1629,113 +1742,113 @@ if (a > 3) {
-
LaTeX example
-

Using a text editor, create a text document named document.tex with the following content:

-
\documentclass{article}
-\usepackage{minted}
-\usepackage[fencedCode]{markdown}
-\begin{document}
-\begin{markdown}
-~~~ js
-if (a > 3) {
-    moveShip(5 * gravity, DOWN);
-}
-~~~~~~
-
-  ``` html
-  <pre>
-    <code>
-      // Some comments
-      line 1 of code
-      line 2 of code
-      line 3 of code
-    </code>
-  </pre>
-  ```
-\end{markdown}
-\end{document}
-

Next, invoke LuaTeX from the terminal:

-
lualatex --shell-escape document.tex
-

A PDF document named document.pdf should be produced and contain the following text:

-
-
if (a > 3) {
-    moveShip(5 * gravity, DOWN);
-}
-
<pre>
-  <code>
-    // Some comments
-    line 1 of code
-    line 2 of code
-    line 3 of code
-  </code>
-</pre>
-
-
ConTeXt example
-

Using a text editor, create a text document named document.tex with the following content:

-
\usemodule[t][markdown]
-\def\markdownOptionFencedCode{true}
-\definetyping [js]
-\definetyping [html]
-\setuptyping  [html] [option=XML]
-\starttext
-\startmarkdown
-~~~ js
-if (a > 3) {
-    moveShip(5 * gravity, DOWN);
-}
-~~~~~~
-
-  ``` html
-  <pre>
-    <code>
-      // Some comments
-      line 1 of code
-      line 2 of code
-      line 3 of code
-    </code>
-  </pre>
-  ```
-\stopmarkdown
-\stoptext
-

Next, invoke LuaTeX from the terminal:

-
context document.tex
-

A PDF document named document.pdf should be produced and contain the following text:

-
-
if (a > 3) {
-    moveShip(5 * gravity, DOWN);
-}
-
<pre>
-  <code>
-    // Some comments
-    line 1 of code
-    line 2 of code
-    line 3 of code
-  </code>
-</pre>
-
-
2.1.2.2.12 Option footnotes
+
LaTeX Example
+

Using a text editor, create a text document named document.tex with the following content:

+
\documentclass{article}
+\usepackage{minted}
+\usepackage[fencedCode]{markdown}
+\begin{document}
+\begin{markdown}
+~~~ js
+if (a > 3) {
+    moveShip(5 * gravity, DOWN);
+}
+~~~~~~
+
+  ``` html
+  <pre>
+    <code>
+      // Some comments
+      line 1 of code
+      line 2 of code
+      line 3 of code
+    </code>
+  </pre>
+  ```
+\end{markdown}
+\end{document}
+

Next, invoke LuaTeX from the terminal:

+
lualatex --shell-escape document.tex
+

A PDF document named document.pdf should be produced and contain the following text:

+
+ + +
+
ConTeXt Example
+

Using a text editor, create a text document named document.tex with the following content:

+
\usemodule[t][markdown]
+\def\markdownOptionFencedCode{true}
+\definetyping [js]
+\definetyping [html]
+\setuptyping  [html] [option=XML]
+\starttext
+\startmarkdown
+~~~ js
+if (a > 3) {
+    moveShip(5 * gravity, DOWN);
+}
+~~~~~~
+
+  ``` html
+  <pre>
+    <code>
+      // Some comments
+      line 1 of code
+      line 2 of code
+      line 3 of code
+    </code>
+  </pre>
+  ```
+\stopmarkdown
+\stoptext
+

Next, invoke LuaTeX from the terminal:

+
context document.tex
+

A PDF document named document.pdf should be produced and contain the following text:

+
+ + +
+

2.2.1.13 Option footnotes

footnotes (default value: false)
true

Enable the pandoc footnote syntax extension:

-
Here is a footnote reference,[^1] and another.[^longnote]
-
-[^1]: Here is the footnote.
-
-[^longnote]: Here's one with multiple blocks.
-
-    Subsequent paragraphs are indented to show that they
-belong to the previous footnote.
-
-        { some.code }
-
-    The whole paragraph can be indented, or just the
-    first line.  In this way, multi-paragraph footnotes
-    work like multi-paragraph list items.
-
-This paragraph won't be part of the note, because it
-isn't indented.
+
@@ -1746,79 +1859,79 @@ isn't indented.
-
LaTeX example
-

Using a text editor, create a text document named document.tex with the following content:

-
\documentclass{article}
-\usepackage[footnotes]{markdown}
-\begin{document}
-\begin{markdown}
-Here is a footnote reference,[^1] and another.[^longnote]
-
-[^1]: Here is the footnote.
-
-[^longnote]: Here's one with multiple blocks.
-
-    Subsequent paragraphs are indented to show that they
-belong to the previous footnote.
-
-        { some.code }
-
-    The whole paragraph can be indented, or just the
-    first line.  In this way, multi-paragraph footnotes
-    work like multi-paragraph list items.
-
-This paragraph won't be part of the note, because it
-isn't indented.
-\end{markdown}
-\end{document}
-

Next, invoke LuaTeX from the terminal:

-
lualatex document.tex
-

A PDF document named document.pdf should be produced and contain the following text:

-
-

Here is a footnote reference,1 and another.2

-

This paragraph won't be part of the note, because it isn't indented.

-
-
ConTeXt example
-

Using a text editor, create a text document named document.tex with the following content:

-
\usemodule[t][markdown]
-\def\markdownOptionFootnotes{true}
-\starttext
-\startmarkdown
-Here is a footnote reference,[^1] and another.[^longnote]
-
-[^1]: Here is the footnote.
-
-[^longnote]: Here's one with multiple blocks.
-
-    Subsequent paragraphs are indented to show that they
-belong to the previous footnote.
-
-        { some.code }
-
-    The whole paragraph can be indented, or just the
-    first line.  In this way, multi-paragraph footnotes
-    work like multi-paragraph list items.
-
-This paragraph won't be part of the note, because it
-isn't indented.
-\stopmarkdown
-\stoptext
-

Next, invoke LuaTeX from the terminal:

-
context document.tex
-

A PDF document named document.pdf should be produced and contain the following text:

-
-

Here is a footnote reference,3 and another.4

-

This paragraph won't be part of the note, because it isn't indented.

-
-
2.1.2.2.13 Option hashEnumerators
+
LaTeX Example
+

Using a text editor, create a text document named document.tex with the following content:

+
\documentclass{article}
+\usepackage[footnotes]{markdown}
+\begin{document}
+\begin{markdown}
+Here is a footnote reference,[^1] and another.[^longnote]
+
+[^1]: Here is the footnote.
+
+[^longnote]: Here's one with multiple blocks.
+
+    Subsequent paragraphs are indented to show that they
+belong to the previous footnote.
+
+        { some.code }
+
+    The whole paragraph can be indented, or just the
+    first line.  In this way, multi-paragraph footnotes
+    work like multi-paragraph list items.
+
+This paragraph won't be part of the note, because it
+isn't indented.
+\end{markdown}
+\end{document}
+

Next, invoke LuaTeX from the terminal:

+
lualatex document.tex
+

A PDF document named document.pdf should be produced and contain the following text:

+
+

Here is a footnote reference,1 and another.2

+

This paragraph won’t be part of the note, because it isn’t indented.

+
+
ConTeXt Example
+

Using a text editor, create a text document named document.tex with the following content:

+
\usemodule[t][markdown]
+\def\markdownOptionFootnotes{true}
+\starttext
+\startmarkdown
+Here is a footnote reference,[^1] and another.[^longnote]
+
+[^1]: Here is the footnote.
+
+[^longnote]: Here's one with multiple blocks.
+
+    Subsequent paragraphs are indented to show that they
+belong to the previous footnote.
+
+        { some.code }
+
+    The whole paragraph can be indented, or just the
+    first line.  In this way, multi-paragraph footnotes
+    work like multi-paragraph list items.
+
+This paragraph won't be part of the note, because it
+isn't indented.
+\stopmarkdown
+\stoptext
+

Next, invoke LuaTeX from the terminal:

+
context document.tex
+

A PDF document named document.pdf should be produced and contain the following text:

+
+

Here is a footnote reference,3 and another.4

+

This paragraph won’t be part of the note, because it isn’t indented.

+
+

2.2.1.14 Option hashEnumerators

hashEnumerators (default value: false)
true

Enable the use of hash symbols (#) as ordered item list markers:

-
#. Bird
-#. McHale
-#. Parish
+
@@ -1829,27 +1942,27 @@ isn't indented.
-
LaTeX example
-

Using a text editor, create a text document named document.tex with the following content:

-
\documentclass{article}
-\usepackage{markdown}
-\begin{document}
-
-\begin{markdown}
-#. Bird
-#. McHale
-#. Parish
-\end{markdown}
-
-\begin{markdown*}{hashEnumerators}
-#. Bird
-#. McHale
-#. Parish
-\end{markdown*}
-
-\end{document}
-

Next, invoke LuaTeX from the terminal:

-
lualatex document.tex
+
LaTeX Example
+

Using a text editor, create a text document named document.tex with the following content:

+
\documentclass{article}
+\usepackage{markdown}
+\begin{document}
+
+\begin{markdown}
+. Bird
+. McHale
+. Parish
+\end{markdown}
+
+\begin{markdown*}{hashEnumerators}
+. Bird
+. McHale
+. Parish
+\end{markdown*}
+
+\end{document}
+

Next, invoke LuaTeX from the terminal:

+
lualatex document.tex

A PDF document named document.pdf should be produced and contain the following text:

. Bird

@@ -1861,27 +1974,27 @@ isn't indented.
  • Parish
  • -
    ConTeXt example
    -

    Using a text editor, create a text document named document.tex with the following content:

    -
    \usemodule[t][markdown]
    -\starttext
    -
    -\startmarkdown
    -#. Bird
    -#. McHale
    -#. Parish
    -\stopmarkdown
    -
    -\def\markdownOptionHashEnumerators{true}
    -\startmarkdown
    -#. Bird
    -#. McHale
    -#. Parish
    -\stopmarkdown
    -
    -\stoptext
    -

    Next, invoke LuaTeX from the terminal:

    -
    context document.tex
    +
    ConTeXt Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    +
    \usemodule[t][markdown]
    +\starttext
    +
    +\startmarkdown
    +. Bird
    +. McHale
    +. Parish
    +\stopmarkdown
    +
    +\def\markdownOptionHashEnumerators{true}
    +\startmarkdown
    +. Bird
    +. McHale
    +. Parish
    +\stopmarkdown
    +
    +\stoptext
    +

    Next, invoke LuaTeX from the terminal:

    +
    context document.tex

    A PDF document named document.pdf should be produced and contain the following text:

    . Bird

    @@ -1893,7 +2006,30 @@ isn't indented.
  • Parish
  • -
    2.1.2.2.14 Option html
    +

    2.2.1.15 Option headerAttributes

    +
    +
    headerAttributes (default value: false)
    +
    +
    true
    +

    Enable the assignment of HTML attributes to headings:

    + +

    These HTML attributes have currently no effect other than enabling content slicing.

    +
    +
    +
    +
    +
    false
    +

    Disable the assignment of HTML attributes to headings.

    +
    +
    +
    +
    +

    2.2.1.16 Option html

    html (default value: false)
    @@ -1910,273 +2046,296 @@ isn't indented.

    When the option is enabled, HTML entities are currently incorrectly parsed. See the corresponding issue in the package repository.

    -
    Lua module example
    -

    Using a text editor, create a text document named document.tex with the following content:

    -
    \input markdown
    -\input lmfonts
    -\directlua{
    -  local markdown = require("markdown")
    -  local convert = markdown.new()
    -  local newline = [[^^J^^J]]
    -  local input =
    -    "<div>*There is no block tag support.*</div>"        .. newline ..
    -    "*There is no <inline tag="tag"></inline> support.*" .. newline ..
    -    "_There is no <!-- comment --> support._"            .. newline ..
    -    "_There is no <? HTML instruction ?> support._"
    -  tex.sprint(convert(input)) }
    -\par
    -\directlua{
    -  local markdown = require("markdown")
    -  local convert = markdown.new({html = true})
    -  local input =
    -    "<div>*There is block tag support.*</div>"        .. newline ..
    -    "*There is <inline tag="tag"></inline> support.*" .. newline ..
    -    "_There is <!-- comment --> support._"            .. newline ..
    -    "_There is <? HTML instruction ?> support._"
    -  tex.sprint(convert(input)) }
    -\bye
    +
    Lua Module Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    +
    \input markdown
    +\input lmfonts
    +\directlua{
    +  local markdown = require("markdown")
    +  local convert = markdown.new()
    +  local newline = [[^^J^^J]]
    +  local input =
    +    "<div>*There is no block tag support.*</div>"        .. newline ..
    +    "*There is no <inline tag="tag"></inline> support.*" .. newline ..
    +    "_There is no <!-- comment --> support._"            .. newline ..
    +    "_There is no <? HTML instruction ?> support._"
    +  tex.sprint(convert(input)) }
    +\par
    +\directlua{
    +  local markdown = require("markdown")
    +  local convert = markdown.new({html = true})
    +  local input =
    +    "<div>*There is block tag support.*</div>"        .. newline ..
    +    "*There is <inline tag="tag"></inline> support.*" .. newline ..
    +    "_There is <!-- comment --> support._"            .. newline ..
    +    "_There is <? HTML instruction ?> support._"
    +  tex.sprint(convert(input)) }
    +\bye

    Then, invoke LuaTeX from the terminal:

    -
    luatex document.tex
    +
    luatex document.tex

    A PDF document named document.pdf should be produced and contain the following text:

    -

    <div>There is no block tag support.</div> There is no <inline tag=”tag”></inline> support. There is no <!-- comment --> support. There is no <? HTML instruction ?> support.

    +

    <div>There is no block tag support.</div> There is no <inline tag=”tag”></inline> support. There is no <!– comment –> support. There is no <? HTML instruction ?> support.

    There is support. There is support. There is support.

    -
    Lua CLI example
    +
    Lua CLI Example

    Using a text editor, create a text document named document.tex with the following content:

    -
    \input markdown
    -\input lmfonts
    -\input optionfalse
    -\par
    -\input optiontrue
    -\bye
    +
    \input markdown
    +\input lmfonts
    +\input optionfalse
    +\par
    +\input optiontrue
    +\bye

    Using a text editor, create a text document named content.md with the following content:

    -
    <div>
    -*Is there block tag support?*
    -</div>
    -*Is there <inline tag="tag"></inline> support?*
    -_Is there <!-- comment --> support?_
    -_Is there <? HTML instruction ?> support?_
    +
    <div>
    +*Is there block tag support?*
    +</div>
    +*Is there <inline tag="tag"></inline> support?*
    +_Is there <!-- comment --> support?_
    +_Is there <? HTML instruction ?> support?_

    Next, invoke LuaTeX from the terminal:

    -
    texlua <CLI␣PATHNAME> -- content.md optionfalse.tex
    -texlua <CLI␣PATHNAME> html=true -- content.md optiontrue.tex
    -luatex document.tex
    -

    where <CLI␣PATHNAME> corresponds to the location of the Lua CLI script file, such as ~/texmf/scripts/markdown/markdown-cli.lua on UN*X systems or C:\Users\<YOUR␣USERNAME>\texmf\scripts\markdown\markdown-cli.lua on Windows systems. Use the command kpsewhich markdown-cli.lua to locate the Lua CLI script file using Kpathsea.

    +
    texlua ⟨CLI pathname⟩ -- content.md optionfalse.tex
    +texlua ⟨CLI pathname⟩ html=true -- content.md optiontrue.tex
    +luatex document.tex
    +

    where ⟨CLI pathname⟩ corresponds to the location of the Lua CLI script file, such as ~/texmf/scripts/markdown/markdown-cli.lua on UN*X systems or C:\Users\Your username\texmf\scripts\markdown\markdown-cli.lua on Windows systems. Use the command kpsewhich markdown-cli.lua to locate the Lua CLI script file using Kpathsea.

    A PDF document named document.pdf should be produced and contain the following text:

    -

    <div>Is there block tag support?</div> Is there <inline tag=”tag”></inline> support? Is there <!-- comment --> support? Is there <? HTML instruction ?> support?

    +

    <div>Is there block tag support?</div> Is there <inline tag=”tag”></inline> support? Is there <!– comment –> support? Is there <? HTML instruction ?> support?

    Is there support? Is there support? Is there support?

    -
    Plain TeX example
    -

    Using a text editor, create a text document named document.tex with the following content:

    -
    \input markdown
    -\input lmfonts
    -
    -\markdownBegin
    -<div>
    -*There is no block tag support.*
    -</div>
    -*There is no <inline tag="tag"></inline> support.*
    -_There is no <!-- comment --> support._
    -_There is no <? HTML instruction ?> support._
    -\markdownEnd
    -
    -\def\markdownOptionHtml{true}
    -\markdownBegin
    -<div>
    -*There is block tag support.*
    -</div>
    -*There is <inline tag="tag"></inline> support.*
    -_There is <!-- comment --> support._
    -_There is <? HTML instruction ?> support._
    -\markdownEnd
    -
    -\bye
    -

    Next, invoke LuaTeX from the terminal:

    -
    luatex document.tex
    -

    A PDF document named document.pdf should be produced and contain the following text:

    -
    -

    <div>There is no block tag support.</div> There is no <inline tag=”tag”></inline> support. There is no <!-- comment --> support. There is no <? HTML instruction ?> support.

    +
    Plain TeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    <div>There is no block tag support.</div> There is no <inline tag=”tag”></inline> support. There is no <!– comment –> support. There is no <? HTML instruction ?> support.

    There is support. There is support. There is support.

    -
    LaTeX example
    -

    Using a text editor, create a text document named document.tex with the following content:

    -
    \documentclass{article}
    -\usepackage{markdown}
    -\begin{document}
    -
    -\begin{markdown}
    -<div>
    -*There is no block tag support.*
    -</div>
    -*There is no <inline tag="tag"></inline> support.*
    -_There is no <!-- comment --> support._
    -_There is no <? HTML instruction ?> support._
    -\end{markdown}
    -
    -\begin{markdown*}{html}
    -<div>
    -*There is block tag support.*
    -</div>
    -*There is <inline tag="tag"></inline> support.*
    -_There is <!-- comment --> support._
    -_There is <? HTML instruction ?> support._
    -\end{markdown*}
    -
    -\end{document}
    -

    Next, invoke LuaTeX from the terminal:

    -
    lualatex document.tex
    -

    A PDF document named document.pdf should be produced and contain the following text:

    -
    -

    <div>There is no block tag support.</div> There is no <inline tag=”tag”></inline> support. There is no <!-- comment --> support. There is no <? HTML instruction ?> support.

    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    <div>There is no block tag support.</div> There is no <inline tag=”tag”></inline> support. There is no <!– comment –> support. There is no <? HTML instruction ?> support.

    There is support. There is support. There is support.

    -
    ConTeXt example
    -

    Using a text editor, create a text document named document.tex with the following content:

    -
    \usemodule[t][markdown]
    -\starttext
    -
    -\startmarkdown
    -<div>
    -*There is no block tag support.*
    -</div>
    -*There is no <inline tag="tag"></inline> support.*
    -_There is no <!-- comment --> support._
    -_There is no <? HTML instruction ?> support._
    -\stopmarkdown
    -
    -\def\markdownOptionHtml{true}
    -\startmarkdown
    -<div>
    -*There is block tag support.*
    -</div>
    -*There is <inline tag="tag"></inline> support.*
    -_There is <!-- comment --> support._
    -_There is <? HTML instruction ?> support._
    -\stopmarkdown
    -
    -\stoptext
    -

    Next, invoke LuaTeX from the terminal:

    -
    context document.tex
    -

    A PDF document named document.pdf should be produced and contain the following text:

    -
    -

    <div>There is no block tag support.</div> There is no <inline tag=”tag”></inline> support. There is no <!-- comment --> support. There is no <? HTML instruction ?> support.

    +
    ConTeXt Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    <div>There is no block tag support.</div> There is no <inline tag=”tag”></inline> support. There is no <!– comment –> support. There is no <? HTML instruction ?> support.

    There is support. There is support. There is support.

    -
    2.1.2.2.15 Option hybrid
    +

    2.2.1.17 Option hybrid

    hybrid (default value: true)
    true
    -

    Disable the escaping of special plain TeX characters, which makes it possible to intersperse your markdown markup with TeX code. The intended usage is in documents prepared manually by a human author. In such documents, it can often be desirable to mix TeX and markdown markup freely.

    +

    Disable the escaping of special plain TeX characters, which makes it possible to intersperse your markdown markup with TeX code. The intended usage is in documents prepared manually by a human author. In such documents, it can often be desirable to mix TeX and markdown markup freely.

    false
    -

    Enable the escaping of special plain TeX characters outside verbatim environments, so that they are not interpretted by TeX. This is encouraged when typesetting automatically generated content or markdown documents that were not prepared with this package in mind.

    +

    Enable the escaping of special plain TeX characters outside verbatim environments, so that they are not interpretted by TeX. This is encouraged when typesetting automatically generated content or markdown documents that were not prepared with this package in mind.

    -
    Lua module example
    -

    Using a text editor, create a text document named document.tex with the following content:

    -
    \input markdown
    -\input lmfonts
    -\directlua{
    -  local markdown = require("markdown")
    -  local convert_safe = markdown.new()
    -  local convert_unsafe = markdown.new({hybrid = true})
    -  local input = [[$\noexpand\sqrt{-1}$ *equals* $i$.]]
    -  tex.sprint(convert_safe(input) .. " " .. convert_unsafe(input)) }
    -\bye
    +
    Lua Module Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    +

    Then, invoke LuaTeX from the terminal:

    -
    luatex document.tex
    +

    A PDF document named document.pdf should be produced and contain the following text:

    -

    $\sqrt {-1}$ equals $i$. √-̅1̅ equals i.

    +

    $\sqrt {-1}$ equals $i$.

    +

    √-̅1̅ equals i.

    -
    Lua CLI example
    +
    Lua CLI Example

    Using a text editor, create a text document named document.tex with the following content:

    -
    \input markdown
    -\input lmfonts
    -\input optionfalse
    -\input optiontrue
    -\bye
    +

    Using a text editor, create a text document named content.md with the following content:

    -
    $\sqrt{-1}$ *equals* $i$.
    +

    Next, invoke LuaTeX from the terminal:

    -
    texlua <CLI␣PATHNAME> -- content.md optionfalse.tex
    -texlua <CLI␣PATHNAME> hybrid=true -- content.md optiontrue.tex
    -luatex document.tex
    -

    where <CLI␣PATHNAME> corresponds to the location of the Lua CLI script file, such as ~/texmf/scripts/markdown/markdown-cli.lua on UN*X systems or C:\Users\<YOUR␣USERNAME>\texmf\scripts\markdown\markdown-cli.lua on Windows systems. Use the command kpsewhich markdown-cli.lua to locate the Lua CLI script file using Kpathsea.

    + +

    where ⟨CLI pathname⟩ corresponds to the location of the Lua CLI script file, such as ~/texmf/scripts/markdown/markdown-cli.lua on UN*X systems or C:\Users\Your username\texmf\scripts\markdown\markdown-cli.lua on Windows systems. Use the command kpsewhich markdown-cli.lua to locate the Lua CLI script file using Kpathsea.

    A PDF document named document.pdf should be produced and contain the following text:

    -

    $\sqrt {-1}$ equals $i$. √-̅1̅ equals i.

    +

    $\sqrt {-1}$ equals $i$.

    +

    √-̅1̅ equals i.

    -
    Plain TeX example
    +
    Plain TeX Example

    Using a text editor, create a text document named document.tex with the following content:

    -
    \input markdown
    -\input lmfonts
    -\markdownBegin
    -$\sqrt{-1}$ *equals* $i$.
    -\markdownEnd
    -\def\markdownOptionHybrid{true}
    -\markdownBegin
    -$\sqrt{-1}$ *equals* $i$.
    -\markdownEnd
    -\bye
    +

    Next, invoke LuaTeX from the terminal:

    -
    luatex document.tex
    +

    A PDF document named document.pdf should be produced and contain the following text:

    -

    $\sqrt {-1}$ equals $i$. √-̅1̅ equals i.

    +

    $\sqrt {-1}$ equals $i$.

    +

    √-̅1̅ equals i.

    -
    LaTeX example
    +
    LaTeX Example

    Using a text editor, create a text document named document.tex with the following content:

    -
    \documentclass{article}
    -\usepackage{markdown}
    -\begin{document}
    -\begin{markdown}
    -$\sqrt{-1}$ *equals* $i$.
    -\end{markdown}
    -\begin{markdown*}{hybrid}
    -$\sqrt{-1}$ *equals* $i$.
    -\end{markdown*}
    -\end{document}
    +

    Next, invoke LuaTeX from the terminal:

    -
    lualatex document.tex
    +

    A PDF document named document.pdf should be produced and contain the following text:

    -

    $\sqrt {-1}$ equals $i$. √-̅1̅ equals i.

    +

    $\sqrt {-1}$ equals $i$.

    +

    √-̅1̅ equals i.

    -
    ConTeXt example
    +
    ConTeXt Example

    Using a text editor, create a text document named document.tex with the following content:

    -
    \usemodule[t][markdown]
    -\starttext
    -\startmarkdown
    -$\sqrt{-1}$ *equals* $i$.
    -\stopmarkdown
    -\def\markdownOptionHybrid{true}
    -\startmarkdown
    -$\sqrt{-1}$ *equals* $i$.
    -\stopmarkdown
    -\stoptext
    +

    Next, invoke LuaTeX from the terminal:

    -
    context document.tex
    +

    A PDF document named document.pdf should be produced and contain the following text:

    -

    $\sqrt {-1}$ equals $i$. √-̅1̅ equals i.

    +

    $\sqrt {-1}$ equals $i$.

    +

    √-̅1̅ equals i.

    -
    2.1.2.2.16 Option inlineFootnotes
    +

    2.2.1.18 Option inlineFootnotes

    inlineFootnotes (default value: false)
    true

    Enable the pandoc inline footnote syntax extension:

    -
    Here is an inline note.^[Inlines notes are easier to
    -write, since you don't have to pick an identifier and
    -move down to type the note.]
    +
    @@ -2187,42 +2346,42 @@ move down to type the note.]
    -
    LaTeX example
    +
    LaTeX Example

    Using a text editor, create a text document named document.tex with the following content:

    -
    \documentclass{article}
    -\usepackage[footnotes, inlineFootnotes]{markdown}
    -\begin{document}
    -\begin{markdown}
    -Here is an inline note.^[Inlines notes are easier to
    -write, since you don't have to pick an identifier and
    -move down to type the note.]
    -\end{markdown}
    -\end{document}
    +

    Next, invoke LuaTeX from the terminal:

    -
    lualatex document.tex
    +

    A PDF document named document.pdf should be produced and contain the following text:

    -

    Here is an inline note.5

    +

    Here is an inline note.5

    -
    ConTeXt example
    +
    ConTeXt Example

    Using a text editor, create a text document named document.tex with the following content:

    -
    \usemodule[t][markdown]
    -\def\markdownOptionFootnotes{true}
    -\def\markdownOptionInlineFootnotes{true}
    -\starttext
    -\startmarkdown
    -Here is an inline note.^[Inlines notes are easier to
    -write, since you don't have to pick an identifier and
    -move down to type the note.]
    -\stopmarkdown
    -\stoptext
    +

    Next, invoke LuaTeX from the terminal:

    -
    context document.tex
    +

    A PDF document named document.pdf should be produced and contain the following text:

    -

    Here is an inline note.6

    +

    Here is an inline note.6

    -
    2.1.2.2.17 Option preserveTabs
    +

    2.2.1.19 Option preserveTabs

    preserveTabs (default value: false)
    @@ -2239,12 +2398,149 @@ move down to type the note.]

    This option is currently non-functional. See the corresponding issue in the package repository.

    -
    2.1.2.2.18 Option smartEllipses
    +

    2.2.1.20 Option slice

    +
    +
    slice (default value: ^ $)
    +

    Two space-separated selectors that specify the slice of a document that will be processed, whereas the remainder of the document will be ignored. The following selectors are recognized:

    +
      +
    • The circumflex (^) selects the beginning of a document.
    • +
    • The dollar sign ($) selects the end of a document.
    • +
    • ^identifier⟩ selects the beginning of a section with the HTML attribute #identifier⟩.
    • +
    • $identifier⟩ selects the end of a section with the HTML attribute #identifier⟩.
    • +
    • identifier⟩ corresponds to ^identifier⟩ for the first selector and to $identifier⟩ for the second selector.
    • +
    +

    Specifying only a single selector, ⟨identifier⟩, is equivalent to specifying the two selectors ⟨identifier⟩ ⟨identifier⟩, which is equivalent to ^identifier$identifier⟩.

    +
    +
    +
    Plain TeX Example
    +

    Using a text editor, create a text document named hamlet.md with the following content:

    + +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    The Tragedy of Hamlet

    +

    Shakespeare’s longest play.

    +

    Act I

    +

    Hamlet talks to ghost.

    +

    Act III

    +

    Hamlet kills Polonius.

    +

    Act V

    +

    Hamlet dies.

    +
    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    The Tragedy of Hamlet

    +

    Shakespeare’s longest play.

    +

    Act I

    +

    Hamlet talks to ghost.

    +

    Act III

    +

    Hamlet kills Polonius.

    +

    Act V

    +

    Hamlet dies.

    +
    +
    ConTeXt Example
    +

    Using a text editor, create a text document named hamlet.md with the following content:

    + +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    The Tragedy of Hamlet

    +

    Shakespeare’s longest play.

    +

    Act I

    +

    Hamlet talks to ghost.

    +

    Act III

    +

    Hamlet kills Polonius.

    +

    Act V

    +

    Hamlet dies.

    +
    +

    2.2.1.21 Option smartEllipses

    smartEllipses (default value: false)
    true
    -

    Convert any ellipses in the input to the \markdownRendererEllipsis TeX macro.

    +

    Convert any ellipses in the input to the \markdownRendererEllipsis TeX macro.

    @@ -2255,223 +2551,223 @@ move down to type the note.]
    -
    Lua module example
    -

    Using a text editor, create a text document named document.tex with the following content:

    -
    \input markdown
    -\def\markdownRendererEllipsis{. . .}
    -\input lmfonts
    -\directlua{
    -  local markdown = require("markdown")
    -  local convert = markdown.new()
    -  input = "These are just three regular dots ..."
    -  tex.sprint(convert(input)) }
    -\par
    -\directlua{
    -  local markdown = require("markdown")
    -  local convert = markdown.new({smartEllipses = true})
    -  input = "... and this is a victorian ellipsis."
    -  tex.sprint(convert(input)) }
    -\bye
    +
    Lua Module Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    +

    Then, invoke LuaTeX from the terminal:

    -
    luatex document.tex
    +

    A PDF document named document.pdf should be produced and contain the following text:

    -

    These are just three regular dots ...

    +

    These are just three regular dots …

    . . . and this is a victorian ellipsis.

    -
    Lua CLI example
    +
    Lua CLI Example

    Using a text editor, create a text document named document.tex with the following content:

    -
    \input markdown
    -\def\markdownRendererEllipsis{. . .}
    -\input lmfonts
    -\input optionfalse
    -\par
    -\input optiontrue
    -\bye
    +

    Using a text editor, create a text document named content.md with the following content:

    -
    Are these just three regular dots, a victorian ellipsis, or ... ?
    +

    Next, invoke LuaTeX from the terminal:

    -
    texlua <CLI␣PATHNAME> -- content.md optionfalse.tex
    -texlua <CLI␣PATHNAME> smartEllipses=true -- content.md optiontrue.tex
    -luatex document.tex
    -

    where <CLI␣PATHNAME> corresponds to the location of the Lua CLI script file, such as ~/texmf/scripts/markdown/markdown-cli.lua on UN*X systems or C:\Users\<YOUR␣USERNAME>\texmf\scripts\markdown\markdown-cli.lua on Windows systems. Use the command kpsewhich markdown-cli.lua to locate the Lua CLI script file using Kpathsea.

    + +

    where ⟨CLI pathname⟩ corresponds to the location of the Lua CLI script file, such as ~/texmf/scripts/markdown/markdown-cli.lua on UN*X systems or C:\Users\Your username\texmf\scripts\markdown\markdown-cli.lua on Windows systems. Use the command kpsewhich markdown-cli.lua to locate the Lua CLI script file using Kpathsea.

    A PDF document named document.pdf should be produced and contain the following text:

    -

    Are these just three regular dots, a victorian ellipsis, or ... ?

    +

    Are these just three regular dots, a victorian ellipsis, or … ?

    Are these just three regular dots, a victorian ellipsis, or . . . ?

    -
    Plain TeX example
    +
    Plain TeX Example

    Using a text editor, create a text document named document.tex with the following content:

    -
    \input markdown
    -\def\markdownRendererEllipsis{. . .}
    -
    -\markdownBegin
    -These are just three regular dots ...
    -\markdownEnd
    -
    -\def\markdownOptionSmartEllipses{true}
    -\markdownBegin
    -... and this is a victorian ellipsis.
    -\markdownEnd
    -
    -\bye
    +

    Next, invoke LuaTeX from the terminal:

    -
    luatex document.tex
    +

    A PDF document named document.pdf should be produced and contain the following text:

    -

    These are just three regular dots ...

    +

    These are just three regular dots …

    . . . and this is a victorian ellipsis.

    -
    LaTeX example
    -

    Using a text editor, create a text document named document.tex with the following content:

    -
    \documentclass{article}
    -\usepackage{markdown}
    -\markdownSetup{
    -  renderers = {
    -    ellipsis = {. . .} }}
    -\begin{document}
    -
    -\begin{markdown}
    -These are just three regular dots ...
    -\end{markdown}
    -
    -\begin{markdown*}{smartEllipses}
    -... and this is a victorian ellipsis.
    -\end{markdown*}
    -
    -\end{document}
    -

    Next, invoke LuaTeX from the terminal:

    -
    lualatex document.tex
    -

    A PDF document named document.pdf should be produced and contain the following text:

    -
    -

    These are just three regular dots ...

    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    These are just three regular dots …

    . . . and this is a victorian ellipsis.

    -
    ConTeXt example
    +
    ConTeXt Example

    Using a text editor, create a text document named document.tex with the following content:

    -
    \usemodule[t][markdown]
    -\def\markdownRendererEllipsis{. . .}
    -\starttext
    -
    -\startmarkdown
    -These are just three regular dots ...
    -\stopmarkdown
    -
    -\def\markdownOptionSmartEllipses{true}
    -\startmarkdown
    -... and this is a victorian ellipsis.
    -\stopmarkdown
    -
    -\stoptext
    +

    Next, invoke LuaTeX from the terminal:

    -
    context document.tex
    +

    A PDF document named document.pdf should be produced and contain the following text:

    -

    These are just three regular dots ...

    +

    These are just three regular dots …

    . . . and this is a victorian ellipsis.

    -
    2.1.2.2.19 Option startNumber
    +

    2.2.1.22 Option startNumber

    startNumber (default value: true)
    true
    -

    Make the number in the first item of an ordered lists significant. The item numbers will be passed to the \markdownRendererOlItemWithNumber TeX macro.

    +

    Make the number in the first item of an ordered lists significant. The item numbers will be passed to the \markdownRendererOlItemWithNumber TeX macro.

    false
    -

    Ignore the numbers in the ordered list items. Each item will only produce a \markdownRendererOlItem TeX macro.

    +

    Ignore the numbers in the ordered list items. Each item will only produce a \markdownRendererOlItem TeX macro.

    -
    LaTeX example
    -

    Using a text editor, create a text document named document.tex with the following content:

    -
    \documentclass{article}
    -\usepackage{markdown}
    -\begin{document}
    -
    -\begin{markdown}
    -The following list respects the numbers specified in the markup:
    -
    -3. third item
    -4. fourth item
    -5. fifth item
    -\end{markdown}
    -
    -\begin{markdown*}{startNumber=false}
    -The following list does not respect the numbers specified in the
    -markup:
    -
    -3. third item
    -4. fourth item
    -5. fifth item
    -\end{markdown*}
    -
    -\end{document}
    -

    Next, invoke LuaTeX from the terminal:

    -
    lualatex document.tex
    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    +

    A PDF document named document.pdf should be produced and contain the following text:

    The following list respects the numbers specified in the markup:

    -
      +
      1. third item
      2. fourth item
      3. fifth item

      The following list does not respect the numbers specified in the markup:

      -
        +
        1. third item
        2. fourth item
        3. fifth item
    -
    ConTeXt example
    -

    Using a text editor, create a text document named document.tex with the following content:

    -
    \usemodule[t][markdown]
    -\starttext
    -
    -\startmarkdown
    -The following list respects the numbers specified in the markup:
    -
    -3. third item
    -4. fourth item
    -5. fifth item
    -\stopmarkdown
    -
    -\def\markdownOptionStartNumber{false}
    -\startmarkdown
    -The following list respects the numbers specified in the markup:
    -
    -3. third item
    -4. fourth item
    -5. fifth item
    -\stopmarkdown
    -\stoptext
    -

    Next, invoke LuaTeX from the terminal:

    -
    context document.tex
    +
    ConTeXt Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    +

    A PDF document named document.pdf should be produced and contain the following text:

    The following list respects the numbers specified in the markup:

    -
      +
      1. third item
      2. fourth item
      3. fifth item

      The following list does not respect the numbers specified in the markup:

      -
        +
        1. third item
        2. fourth item
        3. fifth item
    -
    2.1.2.2.20 Option tightLists
    +

    2.2.1.23 Option tightLists

    tightLists (default value: true)
    true
    -

    Lists whose bullets do not consist of multiple paragraphs will be passed to the \markdownRendererOlBeginTight, \markdownRendererOlEndTight, \markdownRendererUlBeginTight, \markdownRendererUlEndTight, \markdownRendererDlBeginTight, and \markdownRendererDlEndTight TeX macros.

    +

    Lists whose bullets do not consist of multiple paragraphs will be passed to the \markdownRendererOlBeginTight, \markdownRendererOlEndTight, \markdownRendererUlBeginTight, \markdownRendererUlEndTight, \markdownRendererDlBeginTight, and \markdownRendererDlEndTight TeX macros.

    @@ -2482,39 +2778,39 @@ The following list respects the numbers specified in the markup:
    -
    LaTeX example
    -

    Using a text editor, create a text document named document.tex with the following content:

    -
    \documentclass{article}
    -\usepackage{markdown}
    -\begin{document}
    -
    -\begin{markdown}
    -The following list is tight:
    -
    -  - first item
    -  - second item
    -  - third item
    -
    -The following list is loose:
    -
    -  - first item
    -  - second item that spans
    -
    -    multiple paragraphs
    -  - third item
    -\end{markdown}
    -
    -\begin{markdown*}{tightLists=false}
    -The following list is now also loose:
    -
    -  - first item
    -  - second item
    -  - third item
    -\end{markdown*}
    -
    -\end{document}
    -

    Next, invoke LuaTeX from the terminal:

    -
    lualatex document.tex
    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    +

    A PDF document named document.pdf should be produced and contain the following text:

    The following list is tight:

    @@ -2537,134 +2833,2114 @@ multiple paragraphs
  • third item

  • -
    2.1.2.2.21 Option underscores
    +

    2.2.1.24 Option underscores

    underscores (default value: true)
    true

    Both underscores and asterisks can be used to denote emphasis and strong emphasis:

    -
    *single asterisks*
    -_single underscores_
    -**double asterisks**
    -__double underscores__
    +
    false
    -

    Only asterisks can be used to denote emphasis and strong emphasis. This makes it easy to write math with the option without the need to constantly escape subscripts.

    +

    Only asterisks can be used to denote emphasis and strong emphasis. This makes it easy to write math with the hybrid option without the need to constantly escape subscripts.

    -
    Plain TeX example
    +
    Plain TeX Example

    Using a text editor, create a text document named document.tex with the following content:

    -
    \input markdown
    -\def\markdownOptionHybrid{true}
    -
    -\markdownBegin
    -This is _emphasized text_ and this is a math subscript: $m\_n$.
    -\markdownEnd
    -
    -\def\markdownOptionUnderscores{false}
    -\markdownBegin
    -This is *emphasized text* and this is a math subscript: $m_n$.
    -\markdownEnd
    -
    -\bye
    +

    Next, invoke LuaTeX from the terminal:

    -
    luatex document.tex
    +

    A PDF document named document.pdf should be produced and contain the following text:

    This is emphasized text and this is a math subscript: mₙ.

    This is emphasized text and this is a math subscript: mₙ.

    -
    LaTeX example
    +
    LaTeX Example

    Using a text editor, create a text document named document.tex with the following content:

    -
    \documentclass{article}
    -\usepackage[hybrid]{markdown}
    -\begin{document}
    -
    -\begin{markdown}
    -This is _emphasized text_ and this is a math subscript: $m\_n$.
    -\end{markdown}
    -
    -\begin{markdown*}{underscores=false}
    -This is *emphasized text* and this is a math subscript: $m_n$.
    -\end{markdown*}
    -
    -\end{document}
    +

    Next, invoke LuaTeX from the terminal:

    -
    lualatex document.tex
    +

    A PDF document named document.pdf should be produced and contain the following text:

    This is emphasized text and this is a math subscript: mₙ.

    This is emphasized text and this is a math subscript: mₙ.

    -
    ConTeXt example
    +
    ConTeXt Example

    Using a text editor, create a text document named document.tex with the following content:

    -
    \usemodule[t][markdown]
    -\def\markdownOptionHybrid{true}
    -\starttext
    -
    -\startmarkdown
    -This is _emphasized text_ and this is a math subscript: $m\_n$.
    -\stopmarkdown
    -
    -\def\markdownOptionUnderscores{false}
    -\startmarkdown
    -This is *emphasized text* and this is a math subscript: $m_n$.
    -\stopmarkdown
    -
    -\stoptext
    +

    Next, invoke LuaTeX from the terminal:

    -
    context document.tex
    +

    A PDF document named document.pdf should be produced and contain the following text:

    This is emphasized text and this is a math subscript: mₙ.

    This is emphasized text and this is a math subscript: mₙ.

    -

    2.2 Plain TeX

    -

    The plain TeX macro package provides TeX commands for typesetting markdown documents that invoke the Lua parser in the background. Beside TeX commands that correspond to the Lua options, the macro package also provides commands corresponding to additional plain TeX-specific options, and so-called token renderer commands that define how the individual markdown elements will be typeset.

    -

    2.2.1 Interfaces

    - -

    2.2.2 Options

    - -

    2.2.3 Token renderers

    - -

    2.3 LaTeX

    -

    The LaTeX macro package provides additional syntactic sugar on top of the plain TeX macro package and provides sane default definitions of the token renderers.

    - -

    2.3.1 Interfaces

    - -

    2.3.2 Options

    - -

    2.3.3 Token renderers

    - -

    2.4 ConTeXt

    -

    The ConTeXt macro package provides additional syntactic sugar on top of the plain TeX macro package and provides sane default definitions of the token renderers.

    -

    2.4.1 Interfaces

    - -

    2.4.2 Options

    - -

    2.4.3 Token renderers

    - -
    +

    2.2.2 Plain TeX

    +

    Plain TeX options control the communication between the TeX interface and the markdown Lua module. They are supported by all higher-level interfaces of the Markdown package, i.e. the plain TeX, LaTeX and ConTeXt interfaces.

    +

    2.2.2.1 File and Directory Names

    +

    The plain TeX interface provides the following commands that you can use to specify the location of temporary files produced during the conversion from Markdown to TeX:

    +
      +
    • \markdownOptionHelperScriptFileName,
    • +
    • \markdownOptionInputTempFileName,
    • +
    • \markdownOptionOutputTempFileName,
    • +
    • \markdownOptionErrorTempFileName,
    • +
    • \markdownOptionOutputDir, and
    • +
    • \markdownOptionCacheDir.
    • +
    +

    Using a text editor, create a folder named output-directory and a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A text document named temporary-input.md should be produced in the folder named output-directory and contain the following text:

    +
    +

    Hello *world*!

    +
    +

    A folder named output-directory/cache-directory should also be produced and contain fragments of the converted markdown document. LuaTeX does not need other temporary files to perform the conversion from markdown to TeX. To produce the remaining temporary files, invoke pdfTeX from the terminal:

    + +

    Text documents named helper-script.lua, and temporary-output.md should be produced in the folder named output-directory. The document named helper-script.lua will contain Lua code that was executed to convert markdown to plain TeX. The document named temporary-output.tex will contain the input markdown document converted to TeX.

    +

    No document named error-output.txt should be produced in the folder named output-directory. This document would only be produced if an error had occured while executing the Lua code. If this happens, please file a bug.

    +

    2.2.2.2 Package Documentation

    +

    The \markdownOptionStripPercentSigns macro controls whether a percent sign (%) at the beginning of a line will be discarded when reading Markdown input from a TeX document. This enables the use of markdown when writing TeX package documentation using the Doc LaTeX package by Frank Mittelbach.

    +

    Using a text editor, create a text document named document.dtx with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the text “Hello world!”

    +

    2.3 Markdown Tokens

    +

    A key feature of the Markdown package is the support for manipulating markdown tokens, such as headings, emphasized text, links, and lists, in TeX. Instead of reducing TeX to a PDF document producer, the Markdown package allows the user to specify how every markdown token should be processed and rendered.

    +

    2.3.1 Token Renderers

    +

    Token renderers are user-defined TeX macros, which render markdown tokens. In this section, I will describe the individual token renderers.

    +

    2.3.1.1 Interblock Separator Renderer

    +

    The \markdownRendererInterblockSeparator macro represents a separator between two markdown block elements. The macro receives no arguments.

    +
    Plain TeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    Hello world!

    +

    (The end of a block)

    +

    Foo bar!

    +
    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    Hello world!

    +

    (The end of a block)

    +

    Foo bar!

    +
    +
    ConTeXt Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    Hello world!

    +

    (The end of a block)

    +

    Foo bar!

    +
    +

    2.3.1.2 Line Break Renderer

    +

    The \markdownRendererLineBreak macro represents a forced line break. The macro receives no arguments.

    +
    Plain TeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Using a text editor, create a text document named example.md with the following content. Note the two spaces at the end of the first line, which specify a hard linebreak. Due to the limitations of the TeX input processor, hard linebreaks would be ignored if we typed them directly into the document.tex document.

    +
    Hello world!  
    _Foo_ bar!
    +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    Hello world!

    +

    (A forced linebreak)

    +

    Foo bar!

    +
    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Using a text editor, create a text document named example.md with the following content. Note the two spaces at the end of the first line, which specify a hard linebreak. Due to the limitations of the TeX input processor, hard linebreaks would be ignored if we typed them directly into the document.tex document.

    +
    Hello world!  
    _Foo_ bar!
    +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    Hello world!

    +

    (A forced linebreak)

    +

    Foo bar!

    +
    +
    ConTeXt Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Using a text editor, create a text document named example.md with the following content. Note the two spaces at the end of the first line, which specify a hard linebreak. Due to the limitations of the TeX input processor, hard linebreaks would be ignored if we typed them directly into the document.tex document.

    +
    Hello world!  
    _Foo_ bar!
    +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    Hello world!

    +

    (A forced linebreak)

    +

    Foo bar!

    +
    +

    2.3.1.3 Ellipsis Renderer

    +

    The \markdownRendererEllipsis macro replaces any occurance of ASCII ellipses in the input text. This macro will only be produced, when the smartEllipses option is true. The macro receives no arguments.

    +
    Plain TeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    The secret word is SHAZAM!

    +
    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    The secret word is SHAZAM!

    +
    +
    ConTeXt Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    Hello world!

    +

    (The end of a block)

    +

    Foo bar!

    +
    +

    2.3.1.4 Non-Breaking Space Renderer

    +

    The \markdownRendererNbsp macro represents a non-breaking space.

    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.bib with the following content:

    + +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX and BibTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    The TeXbook [1, p.·123·and·130] is good.

    +

    References

    +

    [1] Donald Ervin Knuth. The TeXbook, volume A of Computers and typesetting. Addison-Wesley, 1984.

    +
    +

    2.3.1.5 Special Character Renderers

    +

    The following macros replace any special plain TeX characters, including the active pipe character (|) of ConTeXt, in the input text:

    +
      +
    • \markdownRendererAmpersand replaces the ampersand (&).
    • +
    • \markdownRendererBackslash replaces the backslash (\).
    • +
    • \markdownRendererCircumflex replaces the circumflex (^).
    • +
    • \markdownRendererDollarSign replaces the dollar sign ($).
    • +
    • \markdownRendererHash replaces the hash sign (#).
    • +
    • \markdownRendererLeftBrace replaces the left brace ({).
    • +
    • \markdownRendererPercentSign replaces the percent sign (%).
    • +
    • \markdownRendererPipe replaces the pipe character (|).
    • +
    • \markdownRendererRightBrace replaces the right brace (}).
    • +
    • \markdownRendererTilde replaces the tilde (~).
    • +
    • \markdownRendererUnderscore replaces the underscore (_).
    • +
    +
    Plain TeX Example
    +

    Using a text editor, create a text document named document.tex with the following content. We will make the tilde behave as if it were written in TeX, where it represents a non-breaking space.

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text, where the middot (·) denotes a non-breakable space:

    +
    +

    Bartel·Leendert van·der·Waerden

    +
    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content. We will make the tilde behave as if it were written in TeX, where it represents a non-breaking space.

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text, where the middot (·) denotes a non-breakable space:

    +
    +

    Bartel·Leendert van·der·Waerden

    +
    +
    ConTeXt Example
    +

    Using a text editor, create a text document named document.tex with the following content. We will make the tilde behave as if it were written in TeX, where it represents a non-breaking space.

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text, where the middot (·) denotes a non-breakable space:

    +
    +

    Bartel·Leendert van·der·Waerden

    +
    +

    2.3.1.6 Code Span Renderer

    +

    The \markdownRendererCodeSpan macro represents inlined code span in the input text. It receives a single argument that corresponds to the inlined code span.

    +
    Plain TeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    $\sqrt{-1}$ *equals* $i$.

    +

    $\sqrt{-1}$ equals $i$.

    +

    √-̅1̅ equals i.

    +
    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    $\sqrt{-1}$ *equals* $i$.

    +

    $\sqrt{-1}$ equals $i$.

    +

    √-̅1̅ equals i.

    +
    +
    ConTeXt Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    $\sqrt{-1}$ *equals* $i$.

    +

    $\sqrt{-1}$ equals $i$.

    +

    √-̅1̅ equals i.

    +
    + +

    The \markdownRendererLink macro represents a hyperlink. It receives four arguments: the label, the fully escaped uri that can be directly typeset, the raw uri that can be used outside typesetting, and the title of the link.

    +
    Plain TeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    Please visit the link https://ctan.org/ titled the Comprehensive TeX Archive Network.

    +
    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    Please visit the link https://ctan.org/ titled the Comprehensive TeX Archive Network.

    +
    +
    ConTeXt Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    Please visit the link https://ctan.org/ titled the Comprehensive TeX Archive Network.

    +
    +

    2.3.1.8 Image Renderer

    +

    The \markdownRendererImage macro represents an image. It receives four arguments: the label, the fully escaped uri that can be directly typeset, the raw uri that can be used outside typesetting, and the title of the link.

    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following content. This assumes that you use a Unix-like operating system with Bourne or Bourne again shell as the default shell of the current user. It also assumes that the md5sum, wget, and convert binaries are installed and that the TeX engine has shell access.

    +
    +

    +
    +

    2.3.1.9 Content Block Renderers

    +

    The \markdownRendererContentBlock macro represents an iA Writer content block. It receives four arguments: the local file or online image filename extension cast to the lower case, the fully escaped uri that can be directly typeset, the raw uri that can be used outside typesetting, and the title of the content block.

    +

    The \markdownRendererContentBlockOnlineImage macro represents an iA Writer online image content block. The macro receives the same arguments as \markdownRendererContentBlock.

    +

    The \markdownRendererContentBlockCode macro represents an iA Writer content block that was recognized as a file in a known programming language by its filename extension s. If any markdown-languages.json file found by contains a record (k, v), then a non-online-image content block with the filename extension s, s:lower() = k is considered to be in a known programming language v. The macro receives five arguments: the local file name extension s cast to the lower case, the language v, the fully escaped uri that can be directly typeset, the raw uri that can be used outside typesetting, and the title of the content block.

    +

    Note that you will need to place place a markdown-languages.json file inside your working directory or inside your local TeX directory structure. In this file, you will define a mapping between filename extensions and the language names recognized by your favorite syntax highlighter; there may exist other creative uses beside syntax highlighting. The Languages.json file provided by Anton Sotkov is a good starting point.

    +
    Plain TeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Create also a text document named markdown-languages.json with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    This is document.tex, the document that we are currently typesetting.

    +

    This is the JavaScript Object Notation (JSON) document markdown-languages.json, the mapping between filename extensions and programming language names.

    +

    This is the image https://tug.org/tugboat/noword.jpg, the logotype of TUGboat.

    +
    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    This is document.tex, the document that we are currently typesetting.

    +

    This is the JavaScript Object Notation (JSON) document markdown-languages.json, the mapping between filename extensions and programming language names.

    +

    This is the image https://tug.org/tugboat/noword.jpg, the logotype of TUGboat.

    +
    +
    ConTeXt Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Create also a text document named markdown-languages.json with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    This is document.tex, the document that we are currently typesetting.

    +

    This is the JavaScript Object Notation (JSON) document markdown-languages.json, the mapping between filename extensions and programming language names.

    +

    This is the image https://tug.org/tugboat/noword.jpg, the logotype of TUGboat.

    +
    +

    2.3.1.10 Bullet List Renderers

    +

    The \markdownRendererUlBegin macro represents the beginning of a bulleted list that contains an item with several paragraphs of text (the list is not tight). The macro receives no arguments.

    +

    The \markdownRendererUlBeginTight macro represents the beginning of a bulleted list that contains no item with several paragraphs of text (the list is tight). This macro will only be produced, when the tightLists option is false. The macro receives no arguments.

    +

    The \markdownRendererUlItem macro represents an item in a bulleted list. The macro receives no arguments.

    +

    The \markdownRendererUlItemEnd macro represents the end of an item in a bulleted list. The macro receives no arguments.

    +

    The \markdownRendererUlEnd macro represents the end of a bulleted list that contains an item with several paragraphs of text (the list is not tight). The macro receives no arguments.

    +

    The \markdownRendererUlEndTight macro represents the end of a bulleted list that contains no item with several paragraphs of text (the list is tight). This macro will only be produced, when the tightLists option is false. The macro receives no arguments.

    +
    Plain TeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    This is a tight list (the first item, the second item, and the third item).

    +

    This is a loose list:

    +
      +
    • This is the first item.

    • +
    • This is the second item.

    • +
    • This is the third item.

    • +
    +
    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    This is a tight list (the first item, the second item, and the third item).

    +

    This is a loose list:

    +
      +
    • This is the first item.

    • +
    • This is the second item.

    • +
    • This is the third item.

    • +
    +
    +
    ConTeXt Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    This is a tight list (the first item, the second item, and the third item).

    +

    This is a loose list:

    +
      +
    • This is the first item.

    • +
    • This is the second item.

    • +
    • This is the third item.

    • +
    +
    +

    2.3.1.11 Ordered List Renderers

    +

    The \markdownRendererOlBegin macro represents the beginning of an ordered list that contains an item with several paragraphs of text (the list is not tight). The macro receives no arguments.

    +

    The \markdownRendererOlBeginTight macro represents the beginning of an ordered list that contains no item with several paragraphs of text (the list is tight). This macro will only be produced, when the tightLists option is false. The macro receives no arguments.

    +

    The \markdownRendererOlItem macro represents an item in an ordered list. This macro will only be produced, when the startNumber option is false. The macro receives no arguments.

    +

    The \markdownRendererOlItemEnd macro represents the end of an item in an ordered list. The macro receives no arguments.

    +

    The \markdownRendererOlItemWithNumber macro represents an item in an ordered list. This macro will only be produced, when the startNumber option is true. The macro receives no arguments.

    +

    The \markdownRendererOlEnd macro represents the end of an ordered list that contains an item with several paragraphs of text (the list is not tight). The macro receives no arguments.

    +

    The \markdownRendererOlEndTight macro represents the end of an ordered list that contains no item with several paragraphs of text (the list is tight). This macro will only be produced, when the tightLists option is false. The macro receives no arguments.

    +
    Plain TeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    This is a tight list (the first item, the second item, and the third item).

    +

    This is a loose list:

    +
      +
    1. This is the first item.

    2. +
    3. This is the second item.

    4. +
    5. This is the third item.

    6. +
    +
    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    This is a tight list (the first item, the second item, and the third item).

    +

    This is a loose list:

    +
      +
    1. This is the first item.

    2. +
    3. This is the second item.

    4. +
    5. This is the third item.

    6. +
    +
    +
    ConTeXt Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    This is a tight list (the first item, the second item, and the third item).

    +

    This is a loose list:

    +
      +
    1. This is the first item.

    2. +
    3. This is the second item.

    4. +
    5. This is the third item.

    6. +
    +
    +

    2.3.1.12 Definition List Renderers

    +

    The following macros are only produced, when the definitionLists option is true.

    +

    The \markdownRendererDlBegin macro represents the beginning of a definition list that contains an item with several paragraphs of text (the list is not tight). The macro receives no arguments.

    +

    The \markdownRendererDlBeginTight macro represents the beginning of a definition list that contains an item with several paragraphs of text (the list is not tight). This macro will only be produced, when the tightLists option is false. The macro receives no arguments.

    +

    The \markdownRendererDlItem macro represents a term in a definition list. The macro receives a single argument that corresponds to the term being defined.

    +

    The \markdownRendererDlItemEnd macro represents the end of a list of definitions for a single term.

    +

    The \markdownRendererDlDefinitionBegin macro represents the beginning of a definition in a definition list. There can be several definitions for a single term.

    +

    The \markdownRendererDlDefinitionEnd macro represents the end of a definition in a definition list. There can be several definitions for a single term.

    +

    The \markdownRendererDlEnd macro represents the end of a definition list that contains an item with several paragraphs of text (the list is not tight). The macro receives no arguments.

    +

    The \markdownRendererDlEndTight macro represents the end of a definition list that contains no item with several paragraphs of text (the list is tight). This macro will only be produced, when the tightLists option is false. The macro receives no arguments.

    +
    Plain TeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    +
    \input markdown
    +\def\markdownOptionDefinitionLists{true}
    +\def\markdownOptionTightLists{true}
    +
    +\def\markdownRendererInterblockSeparator{%
    +  :%
    +  \def\markdownRendererInterblockSeparator{\par}%
    +}
    +\def\markdownRendererDlBeginTight{%
    +  \begingroup
    +  \parindent=0pt
    +}
    +\def\markdownRendererDlItem#1{%
    +  \par{\bf#1}%
    +  \def\markdownRendererDlDefinitionEnd{%
    +    ,
    +    \def\markdownRendererDlDefinitionEnd{%
    +      , and
    +      \def\markdownRendererDlDefinitionEnd{.}%
    +    }%
    +  }%
    +}
    +\def\markdownRendererDlItemEnd{}
    +\def\markdownRendererDlDefinitionBegin{\par--\kern 0.5em}
    +\def\markdownRendererDlEndTight{\endgroup}
    +
    +\markdownBegin
    +This is a tight definition list
    +
    +Coffee
    +:   black hot drink
    +:   prepared from roasted coffee beans
    +:   one of the most traded agricultural commodities in the world
    +
    +Milk
    +:   white cold drink
    +:   nutrient-rich
    +:   produced on an industrial scale
    +\markdownEnd
    +
    +\def\markdownRendererInterblockSeparator{%
    +  \def\markdownRendererInterblockSeparator{\par}%
    +}
    +\def\markdownRendererDlBegin{}
    +\def\markdownRendererDlItem#1{%
    +  . #1 is a
    +  \def\markdownRendererDlDefinitionBegin{%
    +    \def\markdownRendererDlDefinitionBegin{%
    +      ,
    +      \def\markdownRendererDlDefinitionBegin{, and }%
    +    }%
    +  }%
    +}
    +\def\markdownRendererDlItemEnd{}
    +\def\markdownRendererDlDefinitionEnd{}
    +\def\markdownRendererDlEnd{.}
    +
    +\markdownBegin
    +This is a loose definition list
    +
    +Coffee
    +
    +:   black hot drink
    +
    +:   prepared from roasted coffee beans
    +
    +:   one of the most traded agricultural commodities in the world
    +
    +Milk
    +
    +:   white cold drink
    +
    +:   nutrient-rich
    +
    +:   produced on an industrial scale
    +\markdownEnd
    +
    +\bye
    +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    This is a tight definition list:

    +

    Coffee

    +
      +
    • black hot drink,
    • +
    • prepared from roasted coffee beans, and
    • +
    • one of the most traded agricultural commodities in the world.
    • +
    +

    Milk

    +
      +
    • white cold drink,
    • +
    • nutrient-rich, and
    • +
    • produced on an industrial scale.
    • +
    +

    This is a loose definition list. Coffee is a black hot drink, prepared from roasted coffee beans, and one of the most traded agricultural commodities in the world. Milk is a white cold drink, nutrient-rich, and produced on an industrial scale.

    +
    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    This is a tight definition list:

    +

    Coffee

    +
      +
    • black hot drink,
    • +
    • prepared from roasted coffee beans, and
    • +
    • one of the most traded agricultural commodities in the world.
    • +
    +

    Milk

    +
      +
    • white cold drink,
    • +
    • nutrient-rich, and
    • +
    • produced on an industrial scale.
    • +
    +

    This is a loose definition list. Coffee is a black hot drink, prepared from roasted coffee beans, and one of the most traded agricultural commodities in the world. Milk is a white cold drink, nutrient-rich, and produced on an industrial scale.

    +
    +
    ConTeXt Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    +
    \usemodule[t][markdown]
    +\def\markdownOptionDefinitionLists{true}
    +\def\markdownOptionTightLists{true}
    +\starttext
    +
    +\def\markdownRendererInterblockSeparator{%
    +  :%
    +  \def\markdownRendererInterblockSeparator{\par}%
    +}
    +\def\markdownRendererDlBeginTight{}
    +\def\markdownRendererDlItem#1{%
    +  \par{\bf#1}%
    +  \startitemize
    +  \def\markdownRendererDlDefinitionEnd{%
    +    ,
    +    \def\markdownRendererDlDefinitionEnd{%
    +      , and
    +      \def\markdownRendererDlDefinitionEnd{.}%
    +    }%
    +  }%
    +}
    +\def\markdownRendererDlItemEnd{\stopitemize}
    +\def\markdownRendererDlDefinitionBegin{\item}
    +\def\markdownRendererDlEndTight{}
    +
    +\startmarkdown
    +This is a tight definition list
    +
    +Coffee
    +:   black hot drink
    +:   prepared from roasted coffee beans
    +:   one of the most traded agricultural commodities in the world
    +
    +Milk
    +:   white cold drink
    +:   nutrient-rich
    +:   produced on an industrial scale
    +\stopmarkdown
    +
    +\def\markdownRendererInterblockSeparator{%
    +  \def\markdownRendererInterblockSeparator{\par}%
    +}
    +\def\markdownRendererDlBegin{}
    +\def\markdownRendererDlItem#1{%
    +  . #1 is a
    +  \def\markdownRendererDlDefinitionBegin{%
    +    \def\markdownRendererDlDefinitionBegin{%
    +      ,
    +      \def\markdownRendererDlDefinitionBegin{, and }%
    +    }%
    +  }%
    +}
    +\def\markdownRendererDlItemEnd{}
    +\def\markdownRendererDlDefinitionEnd{}
    +\def\markdownRendererDlEnd{.}
    +
    +\startmarkdown
    +This is a loose definition list
    +
    +Coffee
    +
    +:   black hot drink
    +
    +:   prepared from roasted coffee beans
    +
    +:   one of the most traded agricultural commodities in the world
    +
    +Milk
    +
    +:   white cold drink
    +
    +:   nutrient-rich
    +
    +:   produced on an industrial scale
    +\stopmarkdown
    +
    +\stoptext
    +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    This is a tight definition list:

    +

    Coffee

    +
      +
    • black hot drink,
    • +
    • prepared from roasted coffee beans, and
    • +
    • one of the most traded agricultural commodities in the world.
    • +
    +

    Milk

    +
      +
    • white cold drink,
    • +
    • nutrient-rich, and
    • +
    • produced on an industrial scale.
    • +
    +

    This is a loose definition list. Coffee is a black hot drink, prepared from roasted coffee beans, and one of the most traded agricultural commodities in the world. Milk is a white cold drink, nutrient-rich, and produced on an industrial scale.

    +
    +

    2.3.1.13 Emphasis Renderers

    +

    The \markdownRendererEmphasis macro represents an emphasized span of text. The macro receives a single argument that corresponds to the emphasized span of text.

    +
    Plain TeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    This is emphasis.

    +

    This is strong emphasis.

    +
    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    This is emphasis.

    +

    This is strong emphasis.

    +
    +
    ConTeXt Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    This is emphasis.

    +

    This is strong emphasis.

    +
    +

    The \markdownRendererStrongEmphasis macro represents a strongly emphasized span of text. The macro receives a single argument that corresponds to the emphasized span of text.

    +

    2.3.1.14 Block Quote Renderers

    +

    The \markdownRendererBlockQuoteBegin macro represents the beginning of a block quote. The macro receives no arguments.

    +
    Plain TeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    A quote from William Shakespeare’s King Lear:

    +
    +

    This is the excellent foppery of the world that when we are sick in fortune—often the surfeit of our own behavior—we make guilty of our disasters the sun, the moon, and the stars […]

    +
    +
    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    A quote from William Shakespeare’s King Lear:

    +
    +

    This is the excellent foppery of the world that when we are sick in fortune—often the surfeit of our own behavior—we make guilty of our disasters the sun, the moon, and the stars […]

    +
    +
    +
    ConTeXt Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    A quote from William Shakespeare’s King Lear:

    +
    +

    This is the excellent foppery of the world that when we are sick in fortune—often the surfeit of our own behavior—we make guilty of our disasters the sun, the moon, and the stars […]

    +
    +
    +

    The \markdownRendererBlockQuoteEnd macro represents the end of a block quote. The macro receives no arguments.

    +

    2.3.1.15 Code Block Renderers

    +

    The \markdownRendererInputVerbatim macro represents a code block. The macro receives a single argument that corresponds to the filename of a file contaning the code block contents.

    +

    The \markdownRendererInputFencedCode macro represents a fenced code block. This macro will only be produced, when the fencedCode option is true. The macro receives two arguments that correspond to the filename of a file contaning the code block contents and to the code fence infostring.

    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text except for the filename, which may differ:

    +
    +

    The following code is contained in file ./_markdown_document/882453149edcf288976647f6fe147ada.verbatim:

    + +

    The following code in Python contained in file ./_markdown_document/cf2a96e2120cef5b1fae5fea36fcc27b.verbatim:

    + +
    +

    2.3.1.16 Heading Renderers

    +

    The \markdownRendererHeadingOne macro represents a first level heading. The macro receives a single argument that corresponds to the heading text.

    +

    The \markdownRendererHeadingTwo macro represents a second level heading. The macro receives a single argument that corresponds to the heading text.

    +

    The \markdownRendererHeadingThree macro represents a third level heading. The macro receives a single argument that corresponds to the heading text.

    +

    The \markdownRendererHeadingFour macro represents a fourth level heading. The macro receives a single argument that corresponds to the heading text.

    +

    The \markdownRendererHeadingFive macro represents a fifth level heading. The macro receives a single argument that corresponds to the heading text.

    +

    The \markdownRendererHeadingSix macro represents a sixth level heading. The macro receives a single argument that corresponds to the heading text.

    +
    Plain TeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    65536

    +
    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    65536

    +
    +
    ConTeXt Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    65536

    +
    +

    2.3.1.17 Horizontal Rule Renderer

    +

    The \markdownRendererHorizontalRule macro represents a horizontal rule. The macro receives no arguments.

    +
    Plain TeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    This is the first page.

    +
    +

    This is the second page.

    +
    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    This is the first page.

    +
    +

    This is the second page.

    +
    +
    ConTeXt Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    This is the first page.

    +
    +

    This is the second page.

    +
    +

    2.3.1.18 Footnote Renderer

    +

    The \markdownRendererFootnote macro represents a footnote. This macro will only be produced, when the footnotes option is true. The macro receives a single argument that corresponds to the footnote text.

    +
    Plain TeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    This is some text (and this is a footnote) and this is some other text (and this is some other footnote).

    +
    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    This is some text (and this is a footnote) and this is some other text (and this is some other footnote).

    +
    +
    ConTeXt Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    This is some text (and this is a footnote) and this is some other text (and this is some other footnote).

    +
    +

    2.3.1.19 Parenthesized Citations Renderer

    +

    The \markdownRendererCite macro represents a string of one or more parenthetical citations. This macro will only be produced, when the citations option is true. The macro receives the parameter {number of citations} followed by {prenote}{postnote}{name} repeated ⟨number of citations⟩ times. The ⟨suppress author⟩ parameter is either the token -, when the author’s name is to be suppressed, or + otherwise.

    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    This is a parenthesized citation abrahams90 with a prefix see and a postfix pp. > 12, and a citation eijkhout91 with a postfix pp. 34.

    +
    +

    2.3.1.20 Text Citations Renderer

    +

    The \markdownRendererTextCite macro represents a string of one or more text citations. This macro will only be produced, when the citations option is true. The macro receives parameters in the same format as the \markdownRendererCite macro.

    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    This is a text citation abrahams90 with a postfix pp. 12, and a citation eijkhout91 with a prefix also.

    +
    +

    2.3.2 Token Renderer Prototypes

    +

    By default, token renderers point to package-defined TeX macros, further referred to as prototypes, which provide useful default definitions.

    +
    Plain TeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    Packages can specify token renderer prototypes.

    +

    User-defined token renderers take precedence.

    +
    +
    LaTeX Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    Packages can specify token renderer prototypes.

    +

    User-defined token renderers take precedence.

    +
    +
    ConTeXt Example
    +

    Using a text editor, create a text document named document.tex with the following content:

    + +

    Next, invoke LuaTeX from the terminal:

    + +

    A PDF document named document.pdf should be produced and contain the following text:

    +
    +

    Packages can specify token renderer prototypes.

    +

    User-defined token renderers take precedence.

    +
    +

      -
    1. Here is the footnote.

    2. -
    3. Here's one with multiple blocks.

      +
    4. Here is the footnote.

    5. +
    6. Here’s one with multiple blocks.

      Subsequent paragraphs are indented to show that they belong to the previous footnote.

      { some.code }
      -

      The whole paragraph can be indented, or just the first line. In this way, multi-paragraph footnotes work like multi-paragraph list items.

    7. -
    8. Here is the footnote.

    9. -
    10. Here's one with multiple blocks.

      +

      The whole paragraph can be indented, or just the first line. In this way, multi-paragraph footnotes work like multi-paragraph list items.

    11. +
    12. Here is the footnote.

    13. +
    14. Here’s one with multiple blocks.

      Subsequent paragraphs are indented to show that they belong to the previous footnote.

      { some.code }
      -

      The whole paragraph can be indented, or just the first line. In this way, multi-paragraph footnotes work like multi-paragraph list items.

    15. -
    16. Inlines notes are easier to write, since you don't have to pick an identifier and move down to type the note.

    17. -
    18. Inlines notes are easier to write, since you don't have to pick an identifier and move down to type the note.

    19. +

      The whole paragraph can be indented, or just the first line. In this way, multi-paragraph footnotes work like multi-paragraph list items.

      +
    20. Inlines notes are easier to write, since you don’t have to pick an identifier and move down to type the note.

    21. +
    22. Inlines notes are easier to write, since you don’t have to pick an identifier and move down to type the note.

    -
    + diff --git a/Master/texmf-dist/doc/generic/markdown/markdown.md b/Master/texmf-dist/doc/generic/markdown/markdown.md index 7bbfc7fa4f1..ddd8c67dcdb 100644 --- a/Master/texmf-dist/doc/generic/markdown/markdown.md +++ b/Master/texmf-dist/doc/generic/markdown/markdown.md @@ -2,6 +2,7 @@ --- title: Markdown Package User Manual author: Vít Novotný +date: v\markdownVersion{} (\markdownLastModified{}) --- @@ -9,12 +10,12 @@ author: Vít Novotný Introduction ============ -The [Markdown package][pkg] converts [markdown][] markup to TeX commands. The -functionality is provided both as a Lua module, and as plain TeX, LaTeX, and -ConTeXt macro packages that can be used to directly typeset TeX documents +The [Markdown package][pkg] converts [markdown][] markup to \TeX{} commands. The +functionality is provided both as a Lua module and as plain \TeX{}, \LaTeX{}, and +\Hologo{ConTeXt} macro packages that can be used to directly typeset \TeX documents containing markdown markup. Unlike other convertors, the Markdown package makes it easy to redefine how each and every markdown element is rendered. -Creative abuse of the markdown syntax is encouraged. +Creative abuse of the markdown syntax is encouraged. ;-) [markdown]: https://daringfireball.net/projects/markdown/basics/ (Daring Fireball: Markdown Basics) @@ -23,9 +24,9 @@ Creative abuse of the markdown syntax is encouraged. This document is a user manual for the [Markdown package][pkg]. It provides -beginner tutorials and code examples. For an in-depth description of the -package requirements, interfaces, and implementation, please refer to the -[technical documentation][techdoc]. +tutorials and code examples. For an in-depth description of the package +requirements, interfaces, and implementation, please refer to the [technical +documentation][techdoc]. [techdoc]: http://mirrors.ctan.org/macros/generic/markdown/markdown.pdf (A Markdown Interpreter for TeX) @@ -34,19 +35,19 @@ package requirements, interfaces, and implementation, please refer to the Requirements ------------ -The package requires a working TeX distribution. [TeX Live][] ≥ 2013 is known to -work and so are recent installation of [MikTeX][]. If you are using a minimal -installation of a TeX distribution, please consult the +The package requires a working \TeX{} distribution. [\TeX{} Live][tl] ≥ 2013 is +known to work and so are recent installation of [Mik\TeX{}][mik]. If you are +using a minimal installation of a \TeX{} distribution, please consult the [technical documentation][techdoc] for a detailed list of required packages. - [TeX Live]: https://www.tug.org/texlive/ (TeX Live - TeX Users Group) - [MikTeX]: https://miktex.org/ (Home - MiKTeXorg) + [tl]: https://www.tug.org/texlive/ (TeX Live - TeX Users Group) + [mik]: https://miktex.org/ (Home - MiKTeXorg) Installation ------------ -The package comes pre-installed with [TeX Live][] ≥ 2016 and with recent -installations of [MikTeX][]. Unless you explicitly wish to use the latest +The package comes pre-installed with [\TeX{} Live][tl] ≥ 2016 and with recent +installations of [MikTeX][mik]. Unless you explicitly wish to use the latest version of the package, you are encouraged to skip this step. To install the package, first download the package from the repository @@ -55,7 +56,7 @@ using Git: git clone https://github.com/witiko/markdown `````` Next, enter the directory named `markdown` and interpret the file named -`markdown.ins` file using a Unicode-aware TeX engine, such as XeTeX or +`markdown.ins` file using a Unicode-aware \TeX{} engine, such as XeTeX or LuaTeX: ``` sh cd markdown @@ -63,16 +64,17 @@ luatex markdown.ins `````` This should produce the following files: - * `markdown.lua` – the Lua module, - * `markdown-cli.lua` – the Lua command-line interface, - * `markdown.tex` – the plain TeX macro package, - * `markdown.sty` – the LaTeX package, and - * `t-markdown.tex` – the ConTeXt module. + * `markdown.lua`, the Lua module, + * `markdown-cli.lua`, the Lua command-line interface, + * `markdown.tex`, the plain \TeX{} macro package, + * `markdown.sty`, the \LaTeX{} package, and + * `t-markdown.tex`, the \Hologo{ConTeXt} module. -### Local installation +### Local Installation -To perform a local installation, place the above files into your TeX directory -structure. This is generally where the individual files should be placed: +To perform a local installation, place the above files into your \TeX{} +directory structure. This is generally where the individual files should be +placed: * `/tex/luatex/markdown/markdown.lua` * `/scripts/markdown/markdown-cli.lua` @@ -80,23 +82,23 @@ structure. This is generally where the individual files should be placed: * `/tex/latex/markdown/markdown.sty` * `/tex/context/third/markdown/t-markdown.tex` -where `` corresponds to a root of your TeX distribution, such as +where `` corresponds to a root of your \TeX{} distribution, such as `/usr/share/texmf` and `~/texmf` on UN\*X systems or -`C:\Users\\texmf` on Windows systems. When in doubt, -consult the manual of your TeX distribution. +`C:\Users\`\meta{Your username}`\texmf` on Windows systems. When in doubt, +consult the manual of your \TeX{} distribution. -### Portable installation ### +### Portable Installation Alternatively, you can also store the above files in the same folder as your -TeX document and distribute them together. This way your document can be -portably typeset on legacy TeX distributions. +\TeX{} document and distribute them together. This way your document can be +portably typeset on legacy \TeX{} distributions. -First document +First Document -------------- In this section, we will take the necessary steps to typeset our first markdown -document in TeX. This will serve as our first hands-on experience with the +document in \TeX{}. This will serve as our first hands-on experience with the package and also as a reassurance that the package has been correctly installed. ### Using Lua @@ -109,7 +111,7 @@ following content: \bye ``````` -#### Using the Lua module +#### Using the Lua Module Using a text editor, create a text document named `hello.lua` with the following content: @@ -133,7 +135,7 @@ texlua hello.lua > hello.tex pdftex document.tex `````` -#### Using the Lua CLI +#### Using the Lua Command-Line Interface Using a text editor, create a text document named `hello.md` with the following content: @@ -142,12 +144,12 @@ Hello *world*! `````` Next, invoke LuaTeX from the terminal: ``` sh -texlua -- hello.md hello.tex +texlua ⟨CLI pathname⟩ -- hello.md hello.tex luatex document.tex `````` -where `` corresponds to the location of the Lua CLI script file, +where \meta{CLI pathname} corresponds to the location of the Lua CLI script file, such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or -`C:\Users\\texmf\scripts\markdown\markdown-cli.lua` on Windows +`C:\Users\`\meta{Your username}`\texmf\scripts\markdown\markdown-cli.lua` on Windows systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI script file using [Kpathsea][]. @@ -156,11 +158,11 @@ script file using [Kpathsea][]. A PDF document named `document.pdf` should be produced and contain the text “Hello *world*!” Invoking pdfTeX should have the same effect: ``` sh -texlua -- hello.md hello.tex +texlua ⟨CLI pathname⟩ -- hello.md hello.tex pdftex document.tex `````` -### Using plain TeX +### Using Plain \TeX{} Using a text editor, create a text document named `document.tex` with the following content: @@ -181,7 +183,7 @@ A PDF document named `document.pdf` should be produced and contain the text pdftex --shell-escape document.tex ``````` -### Using LaTeX +### Using \LaTeX{} Using a text editor, create a text document named `document.tex` with the following content: @@ -221,7 +223,7 @@ lualatex latex.tex `````` to see the effect of your changes. -### Using ConTeXt +### Using \Hologo{ConTeXt} Using a text editor, create a text document named `document.tex` with the following content: @@ -263,3240 +265,14 @@ to see the effect of your changes. Examples ======== -This section will show how to use the package by example. - - -Lua ---- - -The Lua part of the package makes it possible to convert a markdown document -into TeX commands and typeset it later when convenient. Although the typical -user will not find this terribly useful and will instead use the plain TeX, -LaTeX, and ConTeXt macro packages to convert and typeset the markdown documents -in a single step, they will still benefit from learning the options that -control the behavior of the Lua parser. - - -### Interfaces - -The Lua part of the package exposes two interfaces – the `markdown` Lua module, -and the Lua command-line interface (CLI). - -#### The Lua module - -The `markdown` Lua module exposes the `new(options)` method, which creates a -converter function from markdown to TeX. The properties of the converter -function are specified by the Lua table `options`. The parameter is optional; -when unspecified, the behaviour will be the same as if `options` were an empty -table. - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\input lmfonts -\input example -\bye -``````` -Using a text editor, create a text document named `example.lua` with the -following content: -``` lua -#!/usr/bin/env texlua -local kpse = require("kpse") -kpse.set_program_name("luatex") -local markdown = require("markdown") -local convert_safe = markdown.new() -local convert_unsafe = markdown.new({hybrid = true}) -local input = [[$\sqrt{-1}$ *equals* $i$.]] -print(convert_safe(input) .. " " .. convert_unsafe(input)) -``````` -Next, invoke LuaTeX from the terminal: -``` sh -texlua example.lua > example.tex -luatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the text -“\$\\sqrt{-1}\$ *equals* \$i\$. √-̅1̅ *equals* $i$.” Invoking pdfTeX should have -the same effect: -``` sh -texlua example.lua > example.tex -pdftex document.tex -`````` - -*** - -Rather than use the `texlua` interpreter, we can also access the `markdown` Lua -module directly from our document. Using a text editor, create a text document -named `document.tex` with the following content: -``` tex -\input markdown -\input lmfonts -\directlua{ - local markdown = require("markdown") - local convert_safe = markdown.new() - local convert_unsafe = markdown.new({hybrid = true}) - local input = [[$\noexpand\sqrt{-1}$ *equals* $i$.]] - tex.sprint(convert_safe(input) .. " " .. convert_unsafe(input)) } -\bye -``````` -Next, invoke LuaTeX from the terminal: -``` sh -luatex document.tex -``````` -A PDF document named `document.pdf` should be produced and contain the text -“\$\\sqrt {-1}\$ *equals* \$i\$. √-̅1̅ *equals* $i$.” In this case, we cannot -use pdfTeX, because pdfTeX does not define the `\directlua` TeX command. - -#### The Lua CLI - -The Lua command-line interface (CLI) accepts the same options as the `markdown` -Lua module, but now the options are specified as command-line parameters. - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\input lmfonts -\input safe\ \input unsafe -\bye -``````` -Using a text editor, create a text document named `example.md` with the -following content: -``` md -$\sqrt{-1}$ *equals* $i$. -`````` -Next, invoke LuaTeX from the terminal: -``` sh -texlua -- example.md safe.tex -texlua hybrid=true -- example.md unsafe.tex -luatex document.tex -`````` -where `` corresponds to the location of the Lua CLI script file, -such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or -`C:\Users\\texmf\scripts\markdown\markdown-cli.lua` on Windows -systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI -script file using [Kpathsea][]. - -A PDF document named `document.pdf` should be produced and contain the text -“\$\\sqrt{-1}\$ *equals* \$i\$. √-̅1̅ *equals* $i$.” Invoking pdfTeX should have -the same effect: -``` sh -texlua -- example.md safe.tex -texlua hybrid=true -- example.md unsafe.tex -pdftex document.tex -`````` - - -### Options - -This section will cover the options recognized by the Lua interface. The -interfaces of the plain TeX, LaTeX, and ConTeXt macro packages recognize these -options as well, in addition to their own options. - - -#### File and Directory Names - - -##### Option `cacheDir` - -`cacheDir` (default value: `"."`) - -: A path to the directory containing auxiliary cache files. If the last - segment of the path does not exist, it will be created by the Lua - command-line and plain TeX implementations. The Lua implementation expects - that the entire path already exists. - - When iteratively writing and typesetting a markdown document, the cache - files are going to accumulate over time. You are advised to clean the - cache directory every now and then, or to set it to a temporary filesystem - (such as `/tmp` on UN*X systems), which gets periodically emptied. - - -###### Lua module example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\directlua{ - local markdown = require("markdown") - local convert = markdown.new({cacheDir = "cache"}) - local input = "Hello *world*!" - tex.sprint(convert(input)) } -\bye -``````` -Create an empty directory named `cache` next to our text document. Then, invoke -LuaTeX from the terminal: -``` sh -luatex document.tex -``````` -A PDF document named `document.pdf` should be produced and contain the text -“Hello *world*!” Several cache files of the Markdown package will also be -produced in the `cache` directory as we requested using the `cacheDir` option. - -###### Lua CLI example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\input hello -\bye -``````` -Using a text editor, create a text document named `hello.md` with the -following content: -``` md -Hello *world*! -`````` -Next, invoke LuaTeX from the terminal: -``` sh -texlua cacheDir=cache -- hello.md hello.tex -luatex document.tex -``````` -where `` corresponds to the location of the Lua CLI script file, -such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or -`C:\Users\\texmf\scripts\markdown\markdown-cli.lua` on Windows -systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI -script file using [Kpathsea][]. - -A PDF document named `document.pdf` should be produced and contain the text -“Hello *world*!” A directory named `cache` containing several cache files of -the Markdown package will also be produced as we requested using the `cacheDir` -option. - -###### Plain TeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\def\markdownOptionCacheDir{cache} -\markdownBegin -Hello *world*! -\markdownEnd -\bye -``````` -Next, invoke LuaTeX from the terminal: -``` sh -luatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the text “Hello -*world*!” A directory named `cache` containing several cache files of the -Markdown package will also be produced as we requested using the `cacheDir` -option. - -###### LaTeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\documentclass{article} -\usepackage[cacheDir=cache]{markdown} -\begin{document} -\begin{markdown} -Hello *world*! -\end{markdown} -\end{document} -``````` -Next, invoke LuaTeX from the terminal: -``` sh -lualatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the text “Hello -*world*!” A directory named `cache` containing several cache files of the -Markdown package will also be produced as we requested using the `cacheDir` -option. - -###### ConTeXt example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\usemodule[t][markdown] -\def\markdownOptionCacheDir{cache} -\starttext -\startmarkdown -Hello *world*! -\stopmarkdown -\stoptext -``````` -Next, invoke LuaTeX from the terminal: -``` sh -context document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the text “Hello -*world*!” A directory named `cache` containing several cache files of the -Markdown package will also be produced as we requested using the `cacheDir` -option. - - -#### Parser Options - - -##### Option `blankBeforeBlockquote` - -`blankBeforeBlockquote` (default value: `false`) - -: true - - : Require a blank line between a paragraph and the following blockquote. - - false - - : Do not require a blank line between a paragraph and the following - blockquote. - - -###### Lua module example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\input lmfonts -\directlua{ - local markdown = require("markdown") - local newline = [[^^J^^J]] - local convert, input - - convert = markdown.new() - input = "A paragraph." .. newline .. - "> A quote." .. newline - tex.sprint(convert(input)) - - convert = markdown.new({blankBeforeBlockquote = true}) - input = "A paragraph." .. newline .. - "> Not a quote." .. newline - tex.sprint(convert(input)) } -\bye -``````` -Then, invoke LuaTeX from the terminal: -``` sh -luatex document.tex -``````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> A paragraph. -> -> > A quote. -> -> A paragraph > Not a quote. - -###### Lua CLI example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\input lmfonts -\input optionfalse -\input optiontrue -\bye -``````` -Using a text editor, create a text document named `content.md` with the -following content: -``` md -A paragraph. -> A quote? -`````` -Next, invoke LuaTeX from the terminal: -``` sh -texlua -- content.md optionfalse.tex -texlua blankBeforeBlockquote=true -- content.md optiontrue.tex -luatex document.tex -``````` -where `` corresponds to the location of the Lua CLI script file, -such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or -`C:\Users\\texmf\scripts\markdown\markdown-cli.lua` on Windows -systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI -script file using [Kpathsea][]. - -A PDF document named `document.pdf` should be produced and contain the -following text: - -> A paragraph. -> -> > A quote? -> -> A paragraph. > A quote? - -###### Plain TeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown - -\markdownBegin -A paragraph. -> A quote. -\markdownEnd - -\def\markdownOptionBlankBeforeBlockquote{true} -\markdownBegin -A paragraph. -> Not a quote. -\markdownEnd - -\bye -``````` -Next, invoke LuaTeX from the terminal: -``` sh -luatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> A paragraph. -> -> > A quote. -> -> A paragraph > Not a quote. - -###### LaTeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\documentclass{article} -\usepackage{markdown} -\begin{document} - -\begin{markdown} -A paragraph. -> A quote. -\end{markdown} - -\begin{markdown*}{blankBeforeBlockquote} -A paragraph. -> Not a quote. -\end{markdown*} - -\end{document} -``````` -Next, invoke LuaTeX from the terminal: -``` sh -lualatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> A paragraph. -> -> > A quote. -> -> A paragraph > Not a quote. - -###### ConTeXt example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\usemodule[t][markdown] -\starttext +In this section, I will describe the individual parts of the Markdown package. +Each part will be shown by example, leaving the implementation details to the +[technical documentation][techdoc]. -\startmarkdown -A paragraph. -> A quote. -\stopmarkdown - -\def\markdownOptionBlankBeforeBlockquote{true} -\startmarkdown -A paragraph. -> Not a quote. -\stopmarkdown - -\stoptext -``````` -Next, invoke LuaTeX from the terminal: -``` sh -context document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> A paragraph. -> -> > A quote. -> -> A paragraph > Not a quote. - - -##### Option `blankBeforeCodeFence` - -`blankBeforeCodeFence` (default value: `false`) - -: true - - : Require a blank line between a paragraph and the following fenced code - block. - - false - - : Do not require a blank line between a paragraph and the following - fenced code block. - - -###### Lua module example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\input lmfonts -\directlua{ - local markdown = require("markdown") - local newline = [[^^J^^J]] - local convert, input - - convert = markdown.new({fencedCode = true}) - input = "A paragraph." .. newline .. - "```" .. newline .. - "A code fence." .. newline .. - "```" .. newline - tex.sprint(convert(input)) - - convert = markdown.new({ - fencedCode = true, blankBeforeCodeFence = true}) - input = "A paragraph." .. newline .. - "```" .. newline .. - "Not a code fence." .. newline .. - "```" .. newline - tex.sprint(convert(input)) } -\bye -``````` -Then, invoke LuaTeX from the terminal: -``` sh -luatex document.tex -``````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> A paragraph. -> -> ``` -> A code fence. -> ``` -> -> A paragraph. ``` Not a code fence. ``` - -###### Lua CLI example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\input lmfonts -\input optionfalse -\input optiontrue -\bye -``````` -Using a text editor, create a text document named `content.md` with the -following content: -```` md -A paragraph. -``` -A code fence? -``` -``````` -Next, invoke LuaTeX from the terminal: -``` sh -texlua fencedCode=true -- content.md optionfalse.tex -texlua fencedCode=true blankBeforeCodeFence=true -- content.md optiontrue.tex -luatex document.tex -``````` -where `` corresponds to the location of the Lua CLI script file, -such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or -`C:\Users\\texmf\scripts\markdown\markdown-cli.lua` on Windows -systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI -script file using [Kpathsea][]. - -A PDF document named `document.pdf` should be produced and contain the -following text: - -> A paragraph. -> -> ``` -> A code fence? -> ``` -> -> A paragraph. ``` A code fence? ``` - -###### Plain TeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -```` tex -\input markdown -\def\markdownOptionFencedCode{true} - -\markdownBegin -A paragraph. -``` -A code fence. -``` -\markdownEnd - -\def\markdownOptionBlankBeforeCodeFence{true} -\markdownBegin -A paragraph. -``` -Not a code fence. -``` -\markdownEnd - -\bye -```````` -Next, invoke LuaTeX from the terminal: -``` sh -luatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> A paragraph. -> -> ``` -> A code fence. -> ``` -> -> A paragraph. ``` Not a code fence. ``` - -###### LaTeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -```` tex -\documentclass{article} -\usepackage[fencedCode]{markdown} -\begin{document} - -\begin{markdown} -A paragraph. -``` -A code fence. -``` -\end{markdown} - -\begin{markdown*}{blankBeforeCodeFence} -A paragraph. -``` -Not a code fence. -``` -\end{markdown*} - -\end{document} -```````` -Next, invoke LuaTeX from the terminal: -``` sh -lualatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> A paragraph. -> -> ``` -> A code fence. -> ``` -> -> A paragraph. ``` Not a code fence. ``` - -###### ConTeXt example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -```` tex -\usemodule[t][markdown] -\def\markdownOptionFencedCode{true} -\starttext - -\startmarkdown -A paragraph. -``` -A code fence. -``` -\stopmarkdown - -\def\markdownOptionBlankBeforeCodeFence{true} -\startmarkdown -A paragraph. -``` -Not a code fence. -``` -\stopmarkdown - -\stoptext -```````` -Next, invoke LuaTeX from the terminal: -``` sh -context document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> A paragraph. -> -> ``` -> A code fence. -> ``` -> -> A paragraph. ``` Not a code fence. ``` - - -##### Option `blankBeforeHeading` - -`blankBeforeHeading` (default value: `false`) - -: true - - : Require a blank line between a paragraph and the following header. - - false - - : Do not require a blank line between a paragraph and the following - header. - - -###### Lua module example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\input lmfonts -\def\markdownRendererHeadingOne#1{{\bf #1}\par} -\directlua{ - local markdown = require("markdown") - local newline = [[^^J^^J]] - local convert, input - - convert = markdown.new() - input = "A paragraph." .. newline .. - "A heading." .. newline .. - "==========" .. newline - tex.sprint(convert(input)) - - convert = markdown.new({blankBeforeHeading = true}) - input = "A paragraph." .. newline .. - "Not a heading." .. newline .. - "==============" .. newline - tex.sprint(convert(input)) } -\bye -``````` -Then, invoke LuaTeX from the terminal: -``` sh -luatex document.tex -``````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> A paragraph. -> -> A heading. -> ========== -> -> A paragraph. Not a heading. ============== - -###### Lua CLI example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\input lmfonts -\input optionfalse -\input optiontrue -\bye -``````` -Using a text editor, create a text document named `content.md` with the -following content: -``` md -A paragraph. -A heading? -========== -`````` -Next, invoke LuaTeX from the terminal: -``` sh -texlua -- content.md optionfalse.tex -texlua blankBeforeHeading=true -- content.md optiontrue.tex -luatex document.tex -``````` -where `` corresponds to the location of the Lua CLI script file, -such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or -`C:\Users\\texmf\scripts\markdown\markdown-cli.lua` on Windows -systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI -script file using [Kpathsea][]. - -A PDF document named `document.pdf` should be produced and contain the -following text: - -> A paragraph. -> -> A heading? -> ========== -> -> A paragraph. A heading? ========== - -###### Plain TeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown - -\markdownBegin -A paragraph. -A heading. -========== -\markdownEnd - -\def\markdownOptionBlankBeforeHeading{true} -\markdownBegin -A paragraph. -Not a heading. -============== -\markdownEnd - -\bye -``````` -Next, invoke LuaTeX from the terminal: -``` sh -luatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> A paragraph. -> -> A heading. -> ========== -> -> A paragraph. Not a heading. ============== - -###### LaTeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\documentclass{article} -\usepackage{markdown} -\begin{document} - -\begin{markdown} -A paragraph. -A heading. -========== -\end{markdown} - -\begin{markdown*}{blankBeforeHeading} -A paragraph. -Not a heading. -============== -\end{markdown*} - -\end{document} -``````` -Next, invoke LuaTeX from the terminal: -``` sh -lualatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> A paragraph. -> -> A heading. -> ========== -> -> A paragraph. Not a heading. ============== - -###### ConTeXt example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\usemodule[t][markdown] -\starttext - -\startmarkdown -A paragraph. -A heading. -========== -\stopmarkdown - -\def\markdownOptionBlankBeforeHeading{true} -\startmarkdown -A paragraph. -Not a heading. -============== -\stopmarkdown - -\stoptext -```````` -Next, invoke LuaTeX from the terminal: -``` sh -context document.tex -````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> A paragraph. -> -> A heading. -> ========== -> -> A paragraph. Not a heading. ============== - - -##### Option `breakableBlockquotes` - -`breakableBlockquotes` (default value: `false`) - -: true - - : A blank line separates block quotes. - - false - - : Blank lines in the middle of a block quote are ignored. - - -###### Lua module example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\input lmfonts -\def\markdownRendererHeadingOne#1{{\bf #1}\par} -\directlua{ - local markdown = require("markdown") - local newline = [[^^J^^J]] - local convert, input - - convert = markdown.new() - input = "> A single" .. newline .. newline .. - "> block quote." .. newline - tex.sprint(convert(input)) - - convert = markdown.new({breakableBlockquotes = true}) - input = "> A block quote." .. newline .. newline .. - "> Another block quote." .. newline - tex.sprint(convert(input)) } -\bye -``````` -Then, invoke LuaTeX from the terminal: -``` sh -luatex document.tex -``````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> > A single block quote. -> -> > A block quote. -> -> > Another block quote. - -###### Lua CLI example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\input lmfonts -\input optionfalse -\input optiontrue -\bye -``````` -Using a text editor, create a text document named `content.md` with the -following content: -``` md -> A single block quote - -> or two block quotes? -`````` -Next, invoke LuaTeX from the terminal: -``` sh -texlua -- content.md optionfalse.tex -texlua breakableBlockquotes=true -- content.md optiontrue.tex -luatex document.tex -``````` -where `` corresponds to the location of the Lua CLI script file, -such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or -`C:\Users\\texmf\scripts\markdown\markdown-cli.lua` on Windows -systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI -script file using [Kpathsea][]. - -A PDF document named `document.pdf` should be produced and contain the -following text: - -> > A single block quote or two block quotes? -> -> > A single block quote -> -> > or two block quotes? - -###### Plain TeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown - -\markdownBegin -> A single - -> block quote. -\markdownEnd - -\def\markdownOptionBreakableBlockquotes{true} -\markdownBegin -> A block quote. - -> Another block quote. -\markdownEnd - -\bye -``````` -Next, invoke LuaTeX from the terminal: -``` sh -luatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> > A single block quote. -> -> > A block quote. -> -> > Another block quote. - -###### LaTeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\documentclass{article} -\usepackage{markdown} -\begin{document} - -\begin{markdown} -> A single - -> block quote. -\end{markdown} - -\begin{markdown*}{breakableBlockquotes} -> A block quote. - -> Another block quote. -\end{markdown*} - -\end{document} -``````` -Next, invoke LuaTeX from the terminal: -``` sh -lualatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> > A single block quote. -> -> > A block quote. -> -> > Another block quote. - -###### ConTeXt example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\usemodule[t][markdown] -\starttext - -\startmarkdown -> A single - -> block quote. -\stopmarkdown - -\def\markdownOptionBreakableBlockquotes{true} -\startmarkdown -> A block quote. - -> Another block quote. -\stopmarkdown - -\stoptext -```````` -Next, invoke LuaTeX from the terminal: -``` sh -context document.tex -````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> > A single block quote. -> -> > A block quote. -> -> > Another block quote. - - -##### Option `citationNbsps` - -`citationNbsps` (default value: `true`) - -: true - - : Replace regular spaces with non-breakable spaces inside the prenotes - and postnotes of citations produced via the pandoc citation syntax - extension. - - false - - : Do not replace regular spaces with non-breakable spaces inside the - prenotes and postnotes of citations produced via the pandoc citation - syntax extension. - - -###### LaTeX example {.unnumbered} - -Using a text editor, create a text document named `document.bib` with the -following content: -``` bib -@book{knuth:tex, - author = "Knuth, Donald Ervin", - title = "The \TeX book, volume A of Computers and typesetting", - publisher = "Addison-Wesley", - year = "1984" } -``````` -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\documentclass{article} -\usepackage[citations]{markdown} -\begin{document} - -\begin{markdown} -The TeXbook [@knuth:tex, p. 123 and 130] is good. -\end{markdown} - -\begin{markdown*}{citationNbsps = false} -The TeXbook [@knuth:tex, p. 123 and 130] is good. -\end{markdown*} - -\bibliographystyle{plain} -\bibliography{document.bib} -\end{document} -``````` -Next, invoke LuaTeX and BibTeX from the terminal: -``` sh -lualatex document.tex -bibtex document.aux -lualatex document.tex -lualatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text, where the middot (`·`) denotes a non-breakable space: - -> The TeXbook [1, p.·123·and·130] is good. -> -> The TeXbook [1, p. 123 and 130] is good. -> -> ### References -> [1] Donald·Ervin Knuth. _The TeXbook, volume A of Computers and typesetting._ -> Addison-Wesley, 1984. - - -##### Option `citations` - -`citations` (default value: `false`) - -: true - - : Enable the pandoc citation syntax extension: - - ``` md - Here is a simple parenthetical citation [@doe99] and here - is a string of several [see @doe99, pp. 33-35; also - @smith04, chap. 1]. - - A parenthetical citation can have a [prenote @doe99] and - a [@smith04 postnote]. The name of the author can be - suppressed by inserting a dash before the name of an - author as follows [-@smith04]. - - Here is a simple text citation @doe99 and here is - a string of several @doe99 [pp. 33-35; also @smith04, - chap. 1]. Here is one with the name of the author - suppressed -@doe99. - `````` - -: false - - : Disable the pandoc citation syntax extension. - - -###### LaTeX example {.unnumbered} - -Using a text editor, create a text document named `document.bib` with the -following content: -``` bib -@book{knuth:tex, - author = "Knuth, Donald Ervin", - title = "The \TeX book, volume A of Computers and typesetting", - publisher = "Addison-Wesley", - year = "1984" } -``````` -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\documentclass{article} -\usepackage[backend=biber]{biblatex} -\addbibresource{document.bib} -\usepackage[citations]{markdown} -\begin{document} - -\begin{markdown} -The TeXbook [@knuth:tex, p. 123 and 130] was written by @knuth:tex. -\end{markdown} - -\printbibliography -\end{document} -``````` -Next, invoke LuaTeX and Biber from the terminal: -``` sh -lualatex document.tex -biber document.bcf -lualatex document.tex -lualatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> The TeXbook [1, p.·123 and 130] was written by Knuth [1]. -> -> ### References -> [1] Donald Ervin Knuth. _The TeXbook, volume A of Computers and typesetting._ -> Addison-Wesley, 1984. - - -##### Option `codeSpans` - -`codeSpans` (default value: `true`) - -: true - - : Enable the code span syntax: - - ~~~ md - Use the `printf()` function. - ``There is a literal backtick (`) here.`` - ~~~ - -: false - - : Disable the code span syntax. This allows you to easily - use the quotation mark ligatures in texts that do not contain code - spans: - - ~~~ - ``This is a quote.'' - ~~~~~~ - - -###### Lua module example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\input lmfonts -\directlua{ - local markdown = require("markdown") - local convert = markdown.new() - local input = - "``This is a code span.'' " .. - "``This is no longer a code span.''" - tex.sprint(convert(input)) } -\par -\directlua{ - local markdown = require("markdown") - local convert = markdown.new({codeSpans = false}) - local input = - "``This is a quote.'' " .. - "``This is another quote.''" - tex.sprint(convert(input)) } -\bye -``````` -Then, invoke LuaTeX from the terminal: -``` sh -luatex document.tex -``````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> ``This is a code span.'' ``This is no longer a code span.'' -> -> “This is a quote.” “This is another quote.” - -###### Lua CLI example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\input lmfonts -\input optionfalse -\par -\input optiontrue -\bye -``````` -Using a text editor, create a text document named `content.md` with the -following content: -``` md -``Is this a code span?'' ``Or a quote?'' -`````` -Next, invoke LuaTeX from the terminal: -``` sh -texlua codeSpans=false -- content.md optionfalse.tex -texlua -- content.md optiontrue.tex -luatex document.tex -``````` -where `` corresponds to the location of the Lua CLI script file, -such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or -`C:\Users\\texmf\scripts\markdown\markdown-cli.lua` on Windows -systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI -script file using [Kpathsea][]. - -A PDF document named `document.pdf` should be produced and contain the -following text: - -> “Is this a code span?” “Or a quote?” -> -> ``Is this a code span?'' ``Or a quote?'' - -###### Plain TeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown - -\markdownBegin -``This is a code span.'' -``This is no longer a code span.'' -\markdownEnd - -\def\markdownOptionCodeSpans{false} -\markdownBegin -``This is a quote.'' -``This is another quote.'' -\markdownEnd - -\bye -``````` -Next, invoke LuaTeX from the terminal: -``` sh -luatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> ``This is a code span.'' ``This is no longer a code span.'' -> -> “This is a quote.” “This is another quote.” - -###### LaTeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\documentclass{article} -\usepackage{markdown} -\begin{document} - -\begin{markdown} -``This is a code span.'' -``This is no longer a code span.'' -\end{markdown} - -\begin{markdown*}{codeSpans=false} -``This is a quote.'' -``This is another quote.'' -\end{markdown*} - -\end{document} -``````` -Next, invoke LuaTeX from the terminal: -``` sh -lualatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> ``This is a code span.'' ``This is no longer a code span.'' -> -> “This is a quote.” “This is another quote.” - -###### ConTeXt example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\usemodule[t][markdown] -\starttext - -\startmarkdown -``This is a code span.'' -``This is no longer a code span.'' -\stopmarkdown - -\def\markdownOptionCodeSpans{false} -\startmarkdown -``This is a quote.'' -``This is another quote.'' -\stopmarkdown - -\stoptext -```````` -Next, invoke LuaTeX from the terminal: -``` sh -context document.tex -````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> ``This is a code span.'' ``This is no longer a code span.'' -> -> “This is a quote.” “This is another quote.” - - -##### Option `contentBlocks` - -`contentBlocks` (default value: `false`) - -: true - - : Enable the - iA Writer content blocks syntax extension: - - ``` md - http://example.com/minard.jpg (Napoleon's - disastrous Russian campaign of 1812) - /Flowchart.png "Engineering Flowchart" - /Savings Account.csv 'Recent Transactions' - /Example.swift - /Lorem Ipsum.txt - `````` - -: false - - : Disable the - iA Writer content blocks syntax extension. - - -###### LaTeX example {.unnumbered} - -Using a text editor, create a text document named `table.csv` with the -following content: -``` csv -Name,Surname,Born -Albert,Einstein,1879 -Marie,Curie,1867 -Thomas,Edison,1847 -``````` -Create also a text document named `markdown-languages.json` with the following -content: -``` js -{ - "tex": "LaTeX" -} -`````` -Create also a text document named `code.tex` with the following content: -``` tex -This is an example code listing in \LaTeX. -``````` -Create also a text document named `part.md` with the following content: -``` md -This is a *transcluded markdown document*. -`````` -Create also a text document named `document.tex` with the following content: -``` tex -\documentclass{article} -\usepackage{minted} -\usepackage[contentBlocks]{markdown} -\begin{document} -\begin{markdown} -/table.csv (An example table) -/code.tex (An example code listing) -/part.md (A file transclusion example) -\end{markdown} -\end{document} -``````` -Next, invoke LuaTeX from the terminal: -``` sh -lualatex --shell-escape document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> | Name | Surname | Born | -> | ------ | ---------| ---- | -> | Albert | Einstein | 1879 | -> | Marie | Curie | 1867 | -> | Thomas | Edison | 1847 | -> -> Table 1: An example table -> -> ``` tex -> This is an example code listing in \LaTeX. -> ``````` -> -> This is a *transcluded markdown document*. - -###### ConTeXt example {.unnumbered} - -Using a text editor, create a text document named `table.csv` with the -following content: -``` csv -Name,Surname,Born -Albert,Einstein,1879 -Marie,Curie,1867 -Thomas,Edison,1847 -``````` -Create also a text document named `markdown-languages.json` with the following -content: -``` js -{ - "tex": "ConTeXt" -} -`````` -Create also a text document named `code.tex` with the following content: -``` tex -This is an example code listing in \ConTeXt. -``````` -Create also a text document named `part.md` with the following content: -``` md -This is a *transcluded markdown document*. -`````` -Create also a text document named `document.tex` with the following content: -``` tex -\usemodule[t][markdown] -\def\markdownOptionContentBlocks{true} -\definetyping [ConTeXt] -\setuptyping [ConTeXt] [option=TEX] -\starttext -\startmarkdown -/table.csv (An example table) -/code.tex (An example code listing) -/part.md (A file transclusion example) -\stopmarkdown -\stoptext -```````` -Next, invoke LuaTeX from the terminal: -``` sh -context document.tex -````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> | Name | Surname | Born | -> | ------ | ---------| ---- | -> | Albert | Einstein | 1879 | -> | Marie | Curie | 1867 | -> | Thomas | Edison | 1847 | -> -> Table 1: An example table -> -> ``` tex -> This is an example code listing in \ConTeXt. -> ``````` -> -> This is a *transcluded markdown document*. - - -##### Option `contentBlocksLanguageMap` - -`contentBlocksLanguageMap` (default value: `"markdown-languages.json"`) - -: The filename of the JSON file that maps filename extensions to - programming language names in the iA Writer content blocks. - - -###### LaTeX example {.unnumbered} - -Using a text editor, create a text document named `table.csv` with the -following content: -``` csv -Name,Surname,Born -Albert,Einstein,1879 -Marie,Curie,1867 -Thomas,Edison,1847 -``````` -Create also a text document named `language-map.json` with the following -content: -``` js -{ - "tex": "LaTeX" -} -`````` -Create also a text document named `code.tex` with the following content: -``` tex -This is an example code listing in \LaTeX. -``````` -Create also a text document named `part.md` with the following content: -``` md -This is a *transcluded markdown document*. -`````` -Create also a text document named `document.tex` with the following content: -``` tex -\documentclass{article} -\usepackage{minted} -\usepackage[contentBlocks]{markdown} -\markdownSetup{ - contentBlocksLanguageMap = {language-map.json}, -} -\begin{document} -\begin{markdown} -/table.csv (An example table) -/code.tex (An example code listing) -/part.md (A file transclusion example) -\end{markdown} -\end{document} -``````` -Next, invoke LuaTeX from the terminal: -``` sh -lualatex --shell-escape document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> | Name | Surname | Born | -> | ------ | ---------| ---- | -> | Albert | Einstein | 1879 | -> | Marie | Curie | 1867 | -> | Thomas | Edison | 1847 | -> -> Table 1: An example table -> -> ``` tex -> This is an example code listing in \LaTeX. -> ``````` -> -> This is a *transcluded markdown document*. - -###### ConTeXt example {.unnumbered} - -Using a text editor, create a text document named `table.csv` with the -following content: -``` csv -Name,Surname,Born -Albert,Einstein,1879 -Marie,Curie,1867 -Thomas,Edison,1847 -``````` -Create also a text document named `language-map.json` with the following -content: -``` js -{ - "tex": "ConTeXt" -} -`````` -Create also a text document named `code.tex` with the following content: -``` tex -This is an example code listing in \ConTeXt. -``````` -Create also a text document named `part.md` with the following content: -``` md -This is a *transcluded markdown document*. -`````` -Create also a text document named `document.tex` with the following content: -``` tex -\usemodule[t][markdown] -\def\markdownOptionContentBlocks{true} -\def\markdownOptionContentBlocksLanguageMap{language-map.json} -\definetyping [ConTeXt] -\setuptyping [ConTeXt] [option=TEX] -\starttext -\startmarkdown -/table.csv (An example table) -/code.tex (An example code listing) -/part.md (A file transclusion example) -\stopmarkdown -\stoptext -```````` -Next, invoke LuaTeX from the terminal: -``` sh -context document.tex -````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> | Name | Surname | Born | -> | ------ | ---------| ---- | -> | Albert | Einstein | 1879 | -> | Marie | Curie | 1867 | -> | Thomas | Edison | 1847 | -> -> Table 1: An example table -> -> ``` tex -> This is an example code listing in \ConTeXt. -> ``````` -> -> This is a *transcluded markdown document*. - - -##### Option `definitionLists` - -`definitionLists` (default value: `false`) - -: true - - : Enable the pandoc definition list syntax extension: - - ``` md - Term 1 - - : Definition 1 - - Term 2 with *inline markup* - - : Definition 2 - - { some code, part of Definition 2 } - - Third paragraph of definition 2. - ````` - -: false - - : Disable the pandoc definition list syntax extension. - - -###### LaTeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\documentclass{article} -\usepackage[definitionLists]{markdown} -\begin{document} -\begin{markdown} -Term 1 - -: Definition 1 - -Term 2 with *inline markup* - -: Definition 2 - - { some code, part of Definition 2 } - - Third paragraph of definition 2. -\end{markdown} -\end{document} -``````` -Next, invoke LuaTeX from the terminal: -``` sh -lualatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> Term 1 -> -> : Definition 1 -> -> Term 2 with *inline markup* -> -> : Definition 2 -> -> { some code, part of Definition 2 } -> -> Third paragraph of definition 2. - -###### ConTeXt example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\usemodule[t][markdown] -\def\markdownOptionDefinitionLists{true} -\starttext -\startmarkdown -Term 1 - -: Definition 1 - -Term 2 with *inline markup* - -: Definition 2 - - { some code, part of Definition 2 } - - Third paragraph of definition 2. -\stopmarkdown -\stoptext -```````` -Next, invoke LuaTeX from the terminal: -``` sh -context document.tex -````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> Term 1 -> -> : Definition 1 -> -> Term 2 with *inline markup* -> -> : Definition 2 -> -> { some code, part of Definition 2 } -> -> Third paragraph of definition 2. - - -##### Option `fencedCode` - -`fencedCode` (default value: `false`) - -: true - - : Enable the commonmark fenced code block extension: - - ~~~~~~~~ md - ~~~ js - if (a > 3) { - moveShip(5 * gravity, DOWN); - } - ~~~~~~ - - ``` html -
    -            
    -              // Some comments
    -              line 1 of code
    -              line 2 of code
    -              line 3 of code
    -            
    -          
    - ``` - ~~~~~~~~~~~ - -: false - - : Disable the commonmark fenced code block extension. - - -###### LaTeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\documentclass{article} -\usepackage{minted} -\usepackage[fencedCode]{markdown} -\begin{document} -\begin{markdown} -~~~ js -if (a > 3) { - moveShip(5 * gravity, DOWN); -} -~~~~~~ - - ``` html -
    -    
    -      // Some comments
    -      line 1 of code
    -      line 2 of code
    -      line 3 of code
    -    
    -  
    - ``` -\end{markdown} -\end{document} -``````` -Next, invoke LuaTeX from the terminal: -``` sh -lualatex --shell-escape document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> ~~~ js -> if (a > 3) { -> moveShip(5 * gravity, DOWN); -> } -> ~~~~~~ -> -> ``` html ->
    ->   
    ->     // Some comments
    ->     line 1 of code
    ->     line 2 of code
    ->     line 3 of code
    ->   
    -> 
    -> ``` - -###### ConTeXt example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\usemodule[t][markdown] -\def\markdownOptionFencedCode{true} -\definetyping [js] -\definetyping [html] -\setuptyping [html] [option=XML] -\starttext -\startmarkdown -~~~ js -if (a > 3) { - moveShip(5 * gravity, DOWN); -} -~~~~~~ - - ``` html -
    -    
    -      // Some comments
    -      line 1 of code
    -      line 2 of code
    -      line 3 of code
    -    
    -  
    - ``` -\stopmarkdown -\stoptext -```````` -Next, invoke LuaTeX from the terminal: -``` sh -context document.tex -````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> ~~~ js -> if (a > 3) { -> moveShip(5 * gravity, DOWN); -> } -> ~~~~~~ -> -> ``` html ->
    ->   
    ->     // Some comments
    ->     line 1 of code
    ->     line 2 of code
    ->     line 3 of code
    ->   
    -> 
    -> ``` - - -##### Option `footnotes` - -`footnotes` (default value: `false`) - -: true - - : Enable the pandoc footnote syntax extension: - - ``` md - Here is a footnote reference,[^1] and another.[^longnote] - - [^1]: Here is the footnote. - - [^longnote]: Here's one with multiple blocks. - - Subsequent paragraphs are indented to show that they - belong to the previous footnote. - - { some.code } - - The whole paragraph can be indented, or just the - first line. In this way, multi-paragraph footnotes - work like multi-paragraph list items. - - This paragraph won't be part of the note, because it - isn't indented. - `````` - -: false - - : Disable the pandoc footnote syntax extension. - - -###### LaTeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\documentclass{article} -\usepackage[footnotes]{markdown} -\begin{document} -\begin{markdown} -Here is a footnote reference,[^1] and another.[^longnote] - -[^1]: Here is the footnote. - -[^longnote]: Here's one with multiple blocks. - - Subsequent paragraphs are indented to show that they -belong to the previous footnote. - - { some.code } - - The whole paragraph can be indented, or just the - first line. In this way, multi-paragraph footnotes - work like multi-paragraph list items. - -This paragraph won't be part of the note, because it -isn't indented. -\end{markdown} -\end{document} -``````` -Next, invoke LuaTeX from the terminal: -``` sh -lualatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> Here is a footnote reference,[^1] and another.[^longnote] -> -> [^1]: Here is the footnote. -> -> [^longnote]: Here's one with multiple blocks. -> -> Subsequent paragraphs are indented to show that they -> belong to the previous footnote. -> -> { some.code } -> -> The whole paragraph can be indented, or just the -> first line. In this way, multi-paragraph footnotes -> work like multi-paragraph list items. -> -> This paragraph won't be part of the note, because it -> isn't indented. - -###### ConTeXt example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\usemodule[t][markdown] -\def\markdownOptionFootnotes{true} -\starttext -\startmarkdown -Here is a footnote reference,[^1] and another.[^longnote] - -[^1]: Here is the footnote. - -[^longnote]: Here's one with multiple blocks. - - Subsequent paragraphs are indented to show that they -belong to the previous footnote. - - { some.code } - - The whole paragraph can be indented, or just the - first line. In this way, multi-paragraph footnotes - work like multi-paragraph list items. - -This paragraph won't be part of the note, because it -isn't indented. -\stopmarkdown -\stoptext -```````` -Next, invoke LuaTeX from the terminal: -``` sh -context document.tex -````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> Here is a footnote reference,[^1] and another.[^longnote] -> -> [^1]: Here is the footnote. -> -> [^longnote]: Here's one with multiple blocks. -> -> Subsequent paragraphs are indented to show that they -> belong to the previous footnote. -> -> { some.code } -> -> The whole paragraph can be indented, or just the -> first line. In this way, multi-paragraph footnotes -> work like multi-paragraph list items. -> -> This paragraph won't be part of the note, because it -> isn't indented. - - -##### Option `hashEnumerators` - -`hashEnumerators` (default value: `false`) - -: true - - : Enable the use of hash symbols (`#`) as ordered item list - markers: - - ``` md - #. Bird - #. McHale - #. Parish - `````` - -: false - - : Disable the use of hash symbols (`#`) as ordered item list - markers. - - -###### LaTeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\documentclass{article} -\usepackage{markdown} -\begin{document} - -\begin{markdown} -#. Bird -#. McHale -#. Parish -\end{markdown} - -\begin{markdown*}{hashEnumerators} -#. Bird -#. McHale -#. Parish -\end{markdown*} - -\end{document} -``````` -Next, invoke LuaTeX from the terminal: -``` sh -lualatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> . Bird -> ======== -> . McHale -> ======== -> . Parish -> ======== -> -> #. Bird -> #. McHale -> #. Parish - -###### ConTeXt example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\usemodule[t][markdown] -\starttext - -\startmarkdown -#. Bird -#. McHale -#. Parish -\stopmarkdown - -\def\markdownOptionHashEnumerators{true} -\startmarkdown -#. Bird -#. McHale -#. Parish -\stopmarkdown - -\stoptext -```````` -Next, invoke LuaTeX from the terminal: -``` sh -context document.tex -````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> . Bird -> ======== -> . McHale -> ======== -> . Parish -> ======== -> -> #. Bird -> #. McHale -> #. Parish - - -##### Option `html` - -`html` (default value: `false`) - -: true - - : Enable the recognition of HTML tags, block elements, comments, HTML - instructions, and entities in the input. Tags, block elements (along - with contents), HTML instructions, and comments will be ignored and - HTML entities will be replaced with the corresponding Unicode - codepoints. - -: false - - : Disable the recognition of HTML markup. Any HTML markup in the input - will be rendered as plain text. - - -When the option is enabled, HTML entities are currently incorrectly parsed. -See [the corresponding issue][issue-38] in the package repository. - - [issue-36]: https://github.com/Witiko/markdown/issues/36 - (HTML entities with the `html` Lua option enabled produce a Lua - parser error) - -###### Lua module example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\input lmfonts -\directlua{ - local markdown = require("markdown") - local convert = markdown.new() - local newline = [[^^J^^J]] - local input = - "
    *There is no block tag support.*
    " .. newline .. - "*There is no support.*" .. newline .. - "_There is no support._" .. newline .. - "_There is no support._" - tex.sprint(convert(input)) } -\par -\directlua{ - local markdown = require("markdown") - local convert = markdown.new({html = true}) - local input = - "
    *There is block tag support.*
    " .. newline .. - "*There is support.*" .. newline .. - "_There is support._" .. newline .. - "_There is support._" - tex.sprint(convert(input)) } -\bye -``````` -Then, invoke LuaTeX from the terminal: -``` sh -luatex document.tex -``````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> \
    There is no block tag support.\
    -> There is no \\ support. -> There is no \ support. -> There is no support. -> -> There is support. There is support. There is support. - -###### Lua CLI example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\input lmfonts -\input optionfalse -\par -\input optiontrue -\bye -``````` -Using a text editor, create a text document named `content.md` with the -following content: -``` html -
    -*Is there block tag support?* -
    -*Is there support?* -_Is there support?_ -_Is there support?_ -```````` -Next, invoke LuaTeX from the terminal: -``` sh -texlua -- content.md optionfalse.tex -texlua html=true -- content.md optiontrue.tex -luatex document.tex -``````` -where `` corresponds to the location of the Lua CLI script file, -such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or -`C:\Users\\texmf\scripts\markdown\markdown-cli.lua` on Windows -systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI -script file using [Kpathsea][]. - -A PDF document named `document.pdf` should be produced and contain the -following text: - -> \
    Is there block tag support?\
    -> Is there \\ support? -> Is there \ support? -> Is there support? -> -> Is there support? Is there support? Is there support? - -###### Plain TeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\input lmfonts - -\markdownBegin -
    -*There is no block tag support.* -
    -*There is no support.* -_There is no support._ -_There is no support._ -\markdownEnd - -\def\markdownOptionHtml{true} -\markdownBegin -
    -*There is block tag support.* -
    -*There is support.* -_There is support._ -_There is support._ -\markdownEnd - -\bye -``````` -Next, invoke LuaTeX from the terminal: -``` sh -luatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> \
    There is no block tag support.\
    -> There is no \\ support. -> There is no \ support. -> There is no support. -> -> There is support. There is support. There is support. - -###### LaTeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\documentclass{article} -\usepackage{markdown} -\begin{document} - -\begin{markdown} -
    -*There is no block tag support.* -
    -*There is no support.* -_There is no support._ -_There is no support._ -\end{markdown} - -\begin{markdown*}{html} -
    -*There is block tag support.* -
    -*There is support.* -_There is support._ -_There is support._ -\end{markdown*} - -\end{document} -``````` -Next, invoke LuaTeX from the terminal: -``` sh -lualatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> \
    There is no block tag support.\
    -> There is no \\ support. -> There is no \ support. -> There is no support. -> -> There is support. There is support. There is support. - -###### ConTeXt example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\usemodule[t][markdown] -\starttext - -\startmarkdown -
    -*There is no block tag support.* -
    -*There is no support.* -_There is no support._ -_There is no support._ -\stopmarkdown - -\def\markdownOptionHtml{true} -\startmarkdown -
    -*There is block tag support.* -
    -*There is support.* -_There is support._ -_There is support._ -\stopmarkdown - -\stoptext -```````` -Next, invoke LuaTeX from the terminal: -``` sh -context document.tex -````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> \
    There is no block tag support.\
    -> There is no \\ support. -> There is no \ support. -> There is no support. -> -> There is support. There is support. There is support. - - -##### Option `hybrid` - -`hybrid` (default value: `true`) - -: true - - : Disable the escaping of special plain TeX characters, which makes it - possible to intersperse your markdown markup with TeX code. The - intended usage is in documents prepared manually by a human author. - In such documents, it can often be desirable to mix TeX and markdown - markup freely. - -: false - - : Enable the escaping of special plain TeX characters outside verbatim - environments, so that they are not interpretted by TeX. This is - encouraged when typesetting automatically generated content or - markdown documents that were not prepared with this package in mind. - - -###### Lua module example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\input lmfonts -\directlua{ - local markdown = require("markdown") - local convert_safe = markdown.new() - local convert_unsafe = markdown.new({hybrid = true}) - local input = [[$\noexpand\sqrt{-1}$ *equals* $i$.]] - tex.sprint(convert_safe(input) .. " " .. convert_unsafe(input)) } -\bye -``````` -Then, invoke LuaTeX from the terminal: -``` sh -luatex document.tex -``````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> \$\\sqrt {-1}\$ *equals* \$i\$. -> √-̅1̅ *equals* $i$. - -###### Lua CLI example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\input lmfonts -\input optionfalse -\input optiontrue -\bye -``````` -Using a text editor, create a text document named `content.md` with the -following content: -``` md -$\sqrt{-1}$ *equals* $i$. -`````` -Next, invoke LuaTeX from the terminal: -``` sh -texlua -- content.md optionfalse.tex -texlua hybrid=true -- content.md optiontrue.tex -luatex document.tex -``````` -where `` corresponds to the location of the Lua CLI script file, -such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or -`C:\Users\\texmf\scripts\markdown\markdown-cli.lua` on Windows -systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI -script file using [Kpathsea][]. - -A PDF document named `document.pdf` should be produced and contain the -following text: - -> \$\\sqrt {-1}\$ *equals* \$i\$. -> √-̅1̅ *equals* $i$. - -###### Plain TeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\input lmfonts -\markdownBegin -$\sqrt{-1}$ *equals* $i$. -\markdownEnd -\def\markdownOptionHybrid{true} -\markdownBegin -$\sqrt{-1}$ *equals* $i$. -\markdownEnd -\bye -``````` -Next, invoke LuaTeX from the terminal: -``` sh -luatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> \$\\sqrt {-1}\$ *equals* \$i\$. -> √-̅1̅ *equals* $i$. - -###### LaTeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\documentclass{article} -\usepackage{markdown} -\begin{document} -\begin{markdown} -$\sqrt{-1}$ *equals* $i$. -\end{markdown} -\begin{markdown*}{hybrid} -$\sqrt{-1}$ *equals* $i$. -\end{markdown*} -\end{document} -``````` -Next, invoke LuaTeX from the terminal: -``` sh -lualatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> \$\\sqrt {-1}\$ *equals* \$i\$. -> √-̅1̅ *equals* $i$. - -###### ConTeXt example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\usemodule[t][markdown] -\starttext -\startmarkdown -$\sqrt{-1}$ *equals* $i$. -\stopmarkdown -\def\markdownOptionHybrid{true} -\startmarkdown -$\sqrt{-1}$ *equals* $i$. -\stopmarkdown -\stoptext -```````` -Next, invoke LuaTeX from the terminal: -``` sh -context document.tex -````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> \$\\sqrt {-1}\$ *equals* \$i\$. -> √-̅1̅ *equals* $i$. - - -##### Option `inlineFootnotes` - -`inlineFootnotes` (default value: `false`) - -: true - - : Enable the pandoc inline footnote syntax extension: - - ``` md - Here is an inline note.^[Inlines notes are easier to - write, since you don't have to pick an identifier and - move down to type the note.] - `````` - -: false - - : Disable the pandoc inline footnote syntax extension. - - -###### LaTeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\documentclass{article} -\usepackage[footnotes, inlineFootnotes]{markdown} -\begin{document} -\begin{markdown} -Here is an inline note.^[Inlines notes are easier to -write, since you don't have to pick an identifier and -move down to type the note.] -\end{markdown} -\end{document} -``````` -Next, invoke LuaTeX from the terminal: -``` sh -lualatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> Here is an inline note.^[Inlines notes are easier to -> write, since you don't have to pick an identifier and -> move down to type the note.] - -###### ConTeXt example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\usemodule[t][markdown] -\def\markdownOptionFootnotes{true} -\def\markdownOptionInlineFootnotes{true} -\starttext -\startmarkdown -Here is an inline note.^[Inlines notes are easier to -write, since you don't have to pick an identifier and -move down to type the note.] -\stopmarkdown -\stoptext -```````` -Next, invoke LuaTeX from the terminal: -``` sh -context document.tex -````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> Here is an inline note.^[Inlines notes are easier to -> write, since you don't have to pick an identifier and -> move down to type the note.] - - -##### Option `preserveTabs` - -`preserveTabs` (default value: `false`) - -: true - - : Preserve all tabs in the input. - -: false - - : Convert any tabs in the input to spaces. - - -This option is currently non-functional. See [the corresponding -issue][issue-38] in the package repository. - - [issue-38]: https://github.com/Witiko/markdown/issues/38 - (Tabs are stripped even with the `preserveTabs=true` - Lua option enabled) - - -##### Option `smartEllipses` - -`smartEllipses` (default value: `false`) - -: true - - : Convert any ellipses in the input to the - `\markdownRendererEllipsis` TeX macro. - -: false - - : Preserve all ellipses in the input. - - -###### Lua module example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\def\markdownRendererEllipsis{. . .} -\input lmfonts -\directlua{ - local markdown = require("markdown") - local convert = markdown.new() - input = "These are just three regular dots ..." - tex.sprint(convert(input)) } -\par -\directlua{ - local markdown = require("markdown") - local convert = markdown.new({smartEllipses = true}) - input = "... and this is a victorian ellipsis." - tex.sprint(convert(input)) } -\bye -``````` -Then, invoke LuaTeX from the terminal: -``` sh -luatex document.tex -``````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> These are just three regular dots ... -> -> . . . and this is a victorian ellipsis. - -###### Lua CLI example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\def\markdownRendererEllipsis{. . .} -\input lmfonts -\input optionfalse -\par -\input optiontrue -\bye -``````` -Using a text editor, create a text document named `content.md` with the -following content: -``` md -Are these just three regular dots, a victorian ellipsis, or ... ? -`````` -Next, invoke LuaTeX from the terminal: -``` sh -texlua -- content.md optionfalse.tex -texlua smartEllipses=true -- content.md optiontrue.tex -luatex document.tex -``````` -where `` corresponds to the location of the Lua CLI script file, -such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or -`C:\Users\\texmf\scripts\markdown\markdown-cli.lua` on Windows -systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI -script file using [Kpathsea][]. - -A PDF document named `document.pdf` should be produced and contain the -following text: - -> Are these just three regular dots, a victorian ellipsis, or ... ? -> -> Are these just three regular dots, a victorian ellipsis, or . . . ? - -###### Plain TeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\def\markdownRendererEllipsis{. . .} - -\markdownBegin -These are just three regular dots ... -\markdownEnd - -\def\markdownOptionSmartEllipses{true} -\markdownBegin -... and this is a victorian ellipsis. -\markdownEnd - -\bye -``````` -Next, invoke LuaTeX from the terminal: -``` sh -luatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> These are just three regular dots ... -> -> . . . and this is a victorian ellipsis. - -###### LaTeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\documentclass{article} -\usepackage{markdown} -\markdownSetup{ - renderers = { - ellipsis = {. . .} }} -\begin{document} - -\begin{markdown} -These are just three regular dots ... -\end{markdown} - -\begin{markdown*}{smartEllipses} -... and this is a victorian ellipsis. -\end{markdown*} - -\end{document} -``````` -Next, invoke LuaTeX from the terminal: -``` sh -lualatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> These are just three regular dots ... -> -> . . . and this is a victorian ellipsis. - -###### ConTeXt example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\usemodule[t][markdown] -\def\markdownRendererEllipsis{. . .} -\starttext - -\startmarkdown -These are just three regular dots ... -\stopmarkdown - -\def\markdownOptionSmartEllipses{true} -\startmarkdown -... and this is a victorian ellipsis. -\stopmarkdown - -\stoptext -```````` -Next, invoke LuaTeX from the terminal: -``` sh -context document.tex -````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> These are just three regular dots ... -> -> . . . and this is a victorian ellipsis. - - -##### Option `startNumber` - -`startNumber` (default value: `true`) - -: true - - : Make the number in the first item of an ordered lists significant. The - item numbers will be passed to the - `\markdownRendererOlItemWithNumber` TeX macro. - -: false - - : Ignore the numbers in the ordered list items. Each item will only - produce a - `\markdownRendererOlItem` TeX macro. - - -###### LaTeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\documentclass{article} -\usepackage{markdown} -\begin{document} - -\begin{markdown} -The following list respects the numbers specified in the markup: - -3. third item -4. fourth item -5. fifth item -\end{markdown} - -\begin{markdown*}{startNumber=false} -The following list does not respect the numbers specified in the -markup: - -3. third item -4. fourth item -5. fifth item -\end{markdown*} - -\end{document} -``````` -Next, invoke LuaTeX from the terminal: -``` sh -lualatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> The following list respects the numbers specified in the markup: -> -> 3. third item -> 4. fourth item -> 5. fifth item -> -> The following list does not respect the numbers specified in the markup: -> -> 1. third item -> 2. fourth item -> 3. fifth item - -###### ConTeXt example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\usemodule[t][markdown] -\starttext - -\startmarkdown -The following list respects the numbers specified in the markup: - -3. third item -4. fourth item -5. fifth item -\stopmarkdown - -\def\markdownOptionStartNumber{false} -\startmarkdown -The following list respects the numbers specified in the markup: - -3. third item -4. fourth item -5. fifth item -\stopmarkdown -\stoptext -```````` -Next, invoke LuaTeX from the terminal: -``` sh -context document.tex -````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> The following list respects the numbers specified in the markup: -> -> 3. third item -> 4. fourth item -> 5. fifth item -> -> The following list does not respect the numbers specified in the markup: -> -> 1. third item -> 2. fourth item -> 3. fifth item - - -##### Option `tightLists` - -`tightLists` (default value: `true`) - -: true - - : Lists whose bullets do not consist of multiple paragraphs will be - passed to the - `\markdownRendererOlBeginTight`, `\markdownRendererOlEndTight`, - `\markdownRendererUlBeginTight`, `\markdownRendererUlEndTight`, - `\markdownRendererDlBeginTight`, and - `\markdownRendererDlEndTight` TeX macros. - -: false - - : Lists whose bullets do not consist of multiple paragraphs will be - treated the same way as lists that do consist of multiple paragraphs. - - -###### LaTeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\documentclass{article} -\usepackage{markdown} -\begin{document} - -\begin{markdown} -The following list is tight: - - - first item - - second item - - third item - -The following list is loose: - - - first item - - second item that spans - - multiple paragraphs - - third item -\end{markdown} - -\begin{markdown*}{tightLists=false} -The following list is now also loose: - - - first item - - second item - - third item -\end{markdown*} - -\end{document} -``````` -Next, invoke LuaTeX from the terminal: -``` sh -lualatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> The following list is tight: -> -> - first item -> - second item -> - third item -> -> The following list is loose: -> -> - first item -> - second item that spans -> -> multiple paragraphs -> - third item -> -> The following list is now also loose: -> -> - first item -> -> - second item -> -> - third item - - -##### Option `underscores` - -`underscores` (default value: `true`) - -: true - - : Both underscores and asterisks can be used to denote emphasis and - strong emphasis: - - ``` md - *single asterisks* - _single underscores_ - **double asterisks** - __double underscores__ - `````` - -: false - - : Only asterisks can be used to denote emphasis and strong emphasis. - This makes it easy to write math with the \Opt{hybrid} option - without the need to constantly escape subscripts. - - -###### Plain TeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\def\markdownOptionHybrid{true} - -\markdownBegin -This is _emphasized text_ and this is a math subscript: $m\_n$. -\markdownEnd - -\def\markdownOptionUnderscores{false} -\markdownBegin -This is *emphasized text* and this is a math subscript: $m_n$. -\markdownEnd - -\bye -``````` -Next, invoke LuaTeX from the terminal: -``` sh -luatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> This is _emphasized text_ and this is a math subscript: *mₙ*. -> -> This is _emphasized text_ and this is a math subscript: *mₙ*. - -###### LaTeX example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\documentclass{article} -\usepackage[hybrid]{markdown} -\begin{document} - -\begin{markdown} -This is _emphasized text_ and this is a math subscript: $m\_n$. -\end{markdown} - -\begin{markdown*}{underscores=false} -This is *emphasized text* and this is a math subscript: $m_n$. -\end{markdown*} - -\end{document} -``````` -Next, invoke LuaTeX from the terminal: -``` sh -lualatex document.tex -`````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> This is _emphasized text_ and this is a math subscript: *mₙ*. -> -> This is _emphasized text_ and this is a math subscript: *mₙ*. - -###### ConTeXt example {.unnumbered} - -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\usemodule[t][markdown] -\def\markdownOptionHybrid{true} -\starttext - -\startmarkdown -This is _emphasized text_ and this is a math subscript: $m\_n$. -\stopmarkdown - -\def\markdownOptionUnderscores{false} -\startmarkdown -This is *emphasized text* and this is a math subscript: $m_n$. -\stopmarkdown - -\stoptext -```````` -Next, invoke LuaTeX from the terminal: -``` sh -context document.tex -````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> This is _emphasized text_ and this is a math subscript: *mₙ*. -> -> This is _emphasized text_ and this is a math subscript: *mₙ*. - - -Plain TeX ---------- - -The plain TeX macro package provides TeX commands for typesetting markdown -documents that invoke the Lua parser in the background. Beside TeX commands -that correspond to the Lua options, the macro package also provides commands -corresponding to additional plain TeX-specific options, and so-called *token -renderer* commands that define how the individual markdown elements will be -typeset. - -### Interfaces - - - - -### Options - - - - -### Token renderers - - - - -LaTeX ------ - -The LaTeX macro package provides additional syntactic sugar on top of the plain -TeX macro package and provides sane default definitions of the token renderers. - - - -### Interfaces - - - - -### Options - - - - -### Token renderers - - - - -ConTeXt -------- - -The ConTeXt macro package provides additional syntactic sugar on top of the -plain TeX macro package and provides sane default definitions of the token -renderers. - -### Interfaces - - - -### Options - - - -### Token renderers + [techdoc]: http://mirrors.ctan.org/macros/generic/markdown/markdown.pdf + (A Markdown Interpreter for \TeX{}) - +/markdown-interfaces.md +/markdown-options.md +/markdown-tokens.md diff --git a/Master/texmf-dist/doc/generic/markdown/markdown.pdf b/Master/texmf-dist/doc/generic/markdown/markdown.pdf index 567f99aed14..b445d4cc577 100644 Binary files a/Master/texmf-dist/doc/generic/markdown/markdown.pdf and b/Master/texmf-dist/doc/generic/markdown/markdown.pdf differ diff --git a/Master/texmf-dist/scripts/markdown/markdown-cli.lua b/Master/texmf-dist/scripts/markdown/markdown-cli.lua index d5a65a518f4..0bc1754a39e 100644 --- a/Master/texmf-dist/scripts/markdown/markdown-cli.lua +++ b/Master/texmf-dist/scripts/markdown/markdown-cli.lua @@ -20,7 +20,7 @@ -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- --- Copyright (C) 2018 Vít Novotný +-- Copyright (C) 2016-2019 Vít Novotný -- -- This work may be distributed and/or modified under the -- conditions of the LaTeX Project Public License, either version 1.3 @@ -58,11 +58,11 @@ -- those in the standard .ins files. -- local metadata = { - version = "2.5.6", + version = "2.7.0", comment = "A module for the conversion from markdown to plain TeX", author = "John MacFarlane, Hans Hagen, Vít Novotný", copyright = {"2009-2016 John MacFarlane, Hans Hagen", - "2016-2018 Vít Novotný"}, + "2016-2019 Vít Novotný"}, license = "LPPL 1.3" } @@ -81,10 +81,12 @@ defaultOptions.definitionLists = false defaultOptions.fencedCode = false defaultOptions.footnotes = false defaultOptions.hashEnumerators = false +defaultOptions.headerAttributes = false defaultOptions.html = false defaultOptions.hybrid = false defaultOptions.inlineFootnotes = false defaultOptions.preserveTabs = false +defaultOptions.slice = "^ $" defaultOptions.smartEllipses = false defaultOptions.startNumber = true defaultOptions.tightLists = true diff --git a/Master/texmf-dist/source/generic/markdown/docstrip.cfg b/Master/texmf-dist/source/generic/markdown/docstrip.cfg index 11f5397ec77..a03b51c87b3 100644 --- a/Master/texmf-dist/source/generic/markdown/docstrip.cfg +++ b/Master/texmf-dist/source/generic/markdown/docstrip.cfg @@ -22,7 +22,7 @@ -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE^^J% -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.^^J% -- ^^J% --- Copyright (C) 2018 Vít Novotný^^J% +-- Copyright (C) 2016-2019 Vít Novotný^^J% -- ^^J% -- This work may be distributed and/or modified under the^^J% -- conditions of the LaTeX Project Public License, either version 1.3^^J% @@ -62,7 +62,7 @@ \let\luapostamble\empty \declarepreamble\texpreamble -Copyright (C) 2018 Vít Novotný +Copyright (C) 2016-2019 Vít Novotný This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 diff --git a/Master/texmf-dist/source/generic/markdown/markdown.dtx b/Master/texmf-dist/source/generic/markdown/markdown.dtx index 0222985095c..3897b1f0b6f 100644 --- a/Master/texmf-dist/source/generic/markdown/markdown.dtx +++ b/Master/texmf-dist/source/generic/markdown/markdown.dtx @@ -53,14 +53,25 @@ citations, definitionLists, fencedCode, + headerAttributes, hybrid, html, stripPercentSigns, - underscores=false]{markdown} + underscores=false, +]{markdown} \markdownSetup{ renderers = { codeSpan = {\inline{#1}}, - link = {#1\footnote{See \url{#3}.}}}} + link = {#1\footnote{See \url{#3}.}}, + headingFour = {% + \paragraph{#1}\leavevmode + \def\markdownRendererInterblockSeparator{% + \let\markdownRendererInterblockSeparator\par + }% + \noindent + }, + }, +} % Set up the catcodes. \catcode`\_=12 % We won't be typesetting math and Lua contains lots of `_`. @@ -476,12 +487,38 @@ table td { } } +.tex sub, .latex sub, .latex sup { + text-transform: uppercase; +} + +.tex sub, .latex sub { + vertical-align: -0.1ex; + margin-left: -0.1667em; + margin-right: -0.125em; +} + +.tex, .latex, .tex sub, .latex sub { + font-size: 1em; +} + +.latex sup { + font-size: 0.85em; + vertical-align: -0.35em; + margin-left: -0.36em; + margin-right: -0.15em; +} + +abbr { + font-variant: small-caps; +} + % %<*manual> --- title: Markdown Package User Manual author: Vít Novotný +date: v\markdownVersion{} (\markdownLastModified{}) --- % \fi @@ -492,12 +529,12 @@ author: Vít Novotný Introduction ============ -The [Markdown package][pkg] converts [markdown][] markup to TeX commands. The -functionality is provided both as a Lua module, and as plain TeX, LaTeX, and -ConTeXt macro packages that can be used to directly typeset TeX documents +The [Markdown package][pkg] converts [markdown][] markup to \TeX{} commands. The +functionality is provided both as a Lua module and as plain \TeX{}, \LaTeX{}, and +\Hologo{ConTeXt} macro packages that can be used to directly typeset \TeX documents containing markdown markup. Unlike other convertors, the Markdown package makes it easy to redefine how each and every markdown element is rendered. -Creative abuse of the markdown syntax is encouraged. +Creative abuse of the markdown syntax is encouraged. ;-) [markdown]: https://daringfireball.net/projects/markdown/basics/ (Daring Fireball: Markdown Basics) @@ -518,9 +555,9 @@ Creative abuse of the markdown syntax is encouraged. % \iffalse This document is a user manual for the [Markdown package][pkg]. It provides -beginner tutorials and code examples. For an in-depth description of the -package requirements, interfaces, and implementation, please refer to the -[technical documentation][techdoc]. +tutorials and code examples. For an in-depth description of the package +requirements, interfaces, and implementation, please refer to the [technical +documentation][techdoc]. [techdoc]: http://mirrors.ctan.org/macros/generic/markdown/markdown.pdf (A Markdown Interpreter for TeX) @@ -530,11 +567,11 @@ package requirements, interfaces, and implementation, please refer to the % \fi % \begin{macrocode} local metadata = { - version = "2.5.6", + version = "2.7.0", comment = "A module for the conversion from markdown to plain TeX", author = "John MacFarlane, Hans Hagen, Vít Novotný", copyright = {"2009-2016 John MacFarlane, Hans Hagen", - "2016-2018 Vít Novotný"}, + "2016-2019 Vít Novotný"}, license = "LPPL 1.3" } @@ -569,9 +606,9 @@ modules['markdown'] = metadata % % The \TeX{} implementation of the package draws inspiration from several % sources including the source code of \Hologo{LaTeX2e}, the \pkg{minted} -% package by Geoffrey M. Poore -- which likewise tackles the issue of +% package by Geoffrey M. Poore, which likewise tackles the issue of % interfacing with an external interpreter from \TeX{}, the \pkg{filecontents} -% package by Scott Pakin, and others. +% package by Scott Pakin and others. % % \end{markdown} % \iffalse @@ -581,19 +618,19 @@ modules['markdown'] = metadata Requirements ------------ -The package requires a working TeX distribution. [TeX Live][] ≥ 2013 is known to -work and so are recent installation of [MikTeX][]. If you are using a minimal -installation of a TeX distribution, please consult the +The package requires a working \TeX{} distribution. [\TeX{} Live][tl] ≥ 2013 is +known to work and so are recent installation of [Mik\TeX{}][mik]. If you are +using a minimal installation of a \TeX{} distribution, please consult the [technical documentation][techdoc] for a detailed list of required packages. - [TeX Live]: https://www.tug.org/texlive/ (TeX Live - TeX Users Group) - [MikTeX]: https://miktex.org/ (Home - MiKTeXorg) + [tl]: https://www.tug.org/texlive/ (TeX Live - TeX Users Group) + [mik]: https://miktex.org/ (Home - MiKTeXorg) Installation ------------ -The package comes pre-installed with [TeX Live][] ≥ 2016 and with recent -installations of [MikTeX][]. Unless you explicitly wish to use the latest +The package comes pre-installed with [\TeX{} Live][tl] ≥ 2016 and with recent +installations of [MikTeX][mik]. Unless you explicitly wish to use the latest version of the package, you are encouraged to skip this step. To install the package, first download the package from the repository @@ -602,7 +639,7 @@ using Git: git clone https://github.com/witiko/markdown `````` Next, enter the directory named `markdown` and interpret the file named -`markdown.ins` file using a Unicode-aware TeX engine, such as XeTeX or +`markdown.ins` file using a Unicode-aware \TeX{} engine, such as XeTeX or LuaTeX: ``` sh cd markdown @@ -610,16 +647,17 @@ luatex markdown.ins `````` This should produce the following files: - * `markdown.lua` – the Lua module, - * `markdown-cli.lua` – the Lua command-line interface, - * `markdown.tex` – the plain TeX macro package, - * `markdown.sty` – the LaTeX package, and - * `t-markdown.tex` – the ConTeXt module. + * `markdown.lua`, the Lua module, + * `markdown-cli.lua`, the Lua command-line interface, + * `markdown.tex`, the plain \TeX{} macro package, + * `markdown.sty`, the \LaTeX{} package, and + * `t-markdown.tex`, the \Hologo{ConTeXt} module. -### Local installation +### Local Installation -To perform a local installation, place the above files into your TeX directory -structure. This is generally where the individual files should be placed: +To perform a local installation, place the above files into your \TeX{} +directory structure. This is generally where the individual files should be +placed: * `/tex/luatex/markdown/markdown.lua` * `/scripts/markdown/markdown-cli.lua` @@ -627,16 +665,16 @@ structure. This is generally where the individual files should be placed: * `/tex/latex/markdown/markdown.sty` * `/tex/context/third/markdown/t-markdown.tex` -where `` corresponds to a root of your TeX distribution, such as +where `` corresponds to a root of your \TeX{} distribution, such as `/usr/share/texmf` and `~/texmf` on UN\*X systems or -`C:\Users\\texmf` on Windows systems. When in doubt, -consult the manual of your TeX distribution. +`C:\Users\`\meta{Your username}`\texmf` on Windows systems. When in doubt, +consult the manual of your \TeX{} distribution. -### Portable installation ### +### Portable Installation Alternatively, you can also store the above files in the same folder as your -TeX document and distribute them together. This way your document can be -portably typeset on legacy TeX distributions. +\TeX{} document and distribute them together. This way your document can be +portably typeset on legacy \TeX{} distributions. % %<*lua> @@ -845,6 +883,17 @@ local md5 = require("md5") % \begin{macrocode} \RequirePackage{csvsimple} % \end{macrocode} +% \par +% \begin{markdown} +% +% \pkg{gobble} +% +%: A package that provides the \m{\@gobblethree} \TeX{} command. +% +% \end{markdown} +% \begin{macrocode} +\RequirePackage{gobble} +% \end{macrocode} % \iffalse % %<*context> @@ -852,7 +901,7 @@ local md5 = require("md5") % \par % \begin{markdown} % -%### \Hologo{ConTeXt} prerequisites +%### \Hologo{ConTeXt} Prerequisites % The \Hologo{ConTeXt} part of the package requires that either the Mark II or % the Mark IV format is loaded, all the plain \TeX{} prerequisites (see % Section \ref{sec:texprerequisites}), and the following \Hologo{ConTeXt} @@ -881,11 +930,11 @@ local md5 = require("md5") % %<*manual> -First document +First Document -------------- In this section, we will take the necessary steps to typeset our first markdown -document in TeX. This will serve as our first hands-on experience with the +document in \TeX{}. This will serve as our first hands-on experience with the package and also as a reassurance that the package has been correctly installed. ### Using Lua @@ -898,7 +947,7 @@ following content: \bye ``````` -#### Using the Lua module +#### Using the Lua Module Using a text editor, create a text document named `hello.lua` with the following content: @@ -922,7 +971,7 @@ texlua hello.lua > hello.tex pdftex document.tex `````` -#### Using the Lua CLI +#### Using the Lua Command-Line Interface Using a text editor, create a text document named `hello.md` with the following content: @@ -931,12 +980,12 @@ Hello *world*! `````` Next, invoke LuaTeX from the terminal: ``` sh -texlua -- hello.md hello.tex +texlua ⟨CLI pathname⟩ -- hello.md hello.tex luatex document.tex `````` -where `` corresponds to the location of the Lua CLI script file, +where \meta{CLI pathname} corresponds to the location of the Lua CLI script file, such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or -`C:\Users\\texmf\scripts\markdown\markdown-cli.lua` on Windows +`C:\Users\`\meta{Your username}`\texmf\scripts\markdown\markdown-cli.lua` on Windows systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI script file using [Kpathsea][]. @@ -945,11 +994,11 @@ script file using [Kpathsea][]. A PDF document named `document.pdf` should be produced and contain the text “Hello *world*!” Invoking pdfTeX should have the same effect: ``` sh -texlua -- hello.md hello.tex +texlua ⟨CLI pathname⟩ -- hello.md hello.tex pdftex document.tex `````` -### Using plain TeX +### Using Plain \TeX{} Using a text editor, create a text document named `document.tex` with the following content: @@ -970,7 +1019,7 @@ A PDF document named `document.pdf` should be produced and contain the text pdftex --shell-escape document.tex ``````` -### Using LaTeX +### Using \LaTeX{} Using a text editor, create a text document named `document.tex` with the following content: @@ -1010,7 +1059,7 @@ lualatex latex.tex `````` to see the effect of your changes. -### Using ConTeXt +### Using \Hologo{ConTeXt} Using a text editor, create a text document named `document.tex` with the following content: @@ -1052,7 +1101,16 @@ to see the effect of your changes. Examples ======== -This section will show how to use the package by example. +In this section, I will describe the individual parts of the Markdown package. +Each part will be shown by example, leaving the implementation details to the +[technical documentation][techdoc]. + + [techdoc]: http://mirrors.ctan.org/macros/generic/markdown/markdown.pdf + (A Markdown Interpreter for \TeX{}) + +/markdown-interfaces.md +/markdown-options.md +/markdown-tokens.md % %<*lua> @@ -1066,19 +1124,28 @@ This section will show how to use the package by example. % % \iffalse % -%<*manual> +%<*manual-interfaces> -Lua ---- +Interfaces +---------- -The Lua part of the package makes it possible to convert a markdown document -into TeX commands and typeset it later when convenient. Although the typical -user will not find this terribly useful and will instead use the plain TeX, -LaTeX, and ConTeXt macro packages to convert and typeset the markdown documents -in a single step, they will still benefit from learning the options that -control the behavior of the Lua parser. +In this section, I will describe the individual interfaces exposed by the +Markdown package starting with the low-level Lua interfaces and all the way up +to the \LaTeX{} and \Hologo{ConTeXt} interfaces intended for the ordinary +user. -% +### Lua + +The Lua programming language is what drives the conversion from markdown to +\TeX{} in the Markdown package. Based on the [Lunamark][] Lua library by John +MacFarlane, the Lua implementation is largely independent on \TeX{}, and can be +used separately from typesetting a document. Lua provides two interfaces: a Lua +module and a command-line interface (CLI). + + [Lunamark]: https://github.com/jgm/lunamark + (Lua library for conversion between markup formats) + +% %<*lua> % \fi % @@ -1117,20 +1184,19 @@ local M = {metadata = metadata} % \end{markdown} % \iffalse % -%<*manual> +%<*manual-interfaces> -### Interfaces +#### Lua Module -The Lua part of the package exposes two interfaces – the `markdown` Lua module, -and the Lua command-line interface (CLI). +A Lua module is a software library that can be used from in other programs. +The `markdown` Lua module makes it possible to convert markdown to \TeX{} from +within Lua\TeX{} documents and Lua scripts. -#### The Lua module - -The `markdown` Lua module exposes the `new(options)` method, which creates a -converter function from markdown to TeX. The properties of the converter -function are specified by the Lua table `options`. The parameter is optional; -when unspecified, the behaviour will be the same as if `options` were an empty -table. +The `markdown` Lua module exposes the `new(`\meta{options}`)` method, which +creates a converter function from markdown to \TeX{}. The properties of the +converter function are specified by the Lua table `options`. The parameter is +optional; when unspecified, the behaviour will be the same as if \meta{options} +were an empty table. Using a text editor, create a text document named `document.tex` with the following content: @@ -1147,19 +1213,31 @@ following content: local kpse = require("kpse") kpse.set_program_name("luatex") local markdown = require("markdown") -local convert_safe = markdown.new() -local convert_unsafe = markdown.new({hybrid = true}) -local input = [[$\sqrt{-1}$ *equals* $i$.]] -print(convert_safe(input) .. " " .. convert_unsafe(input)) +local input, convert_safe, convert_unsafe, paragraph + +input = [[$\sqrt{-1}$ *equals* $i$.]] +convert_safe = markdown.new() +convert_unsafe = markdown.new({hybrid = true}) +paragraph = [[\par]] + +print( + convert_safe(input) .. paragraph .. + convert_unsafe(input) +) ``````` Next, invoke LuaTeX from the terminal: ``` sh texlua example.lua > example.tex luatex document.tex `````` -A PDF document named `document.pdf` should be produced and contain the text -“\$\\sqrt{-1}\$ *equals* \$i\$. √-̅1̅ *equals* $i$.” Invoking pdfTeX should have -the same effect: +A PDF document named `document.pdf` should be produced and contain the +following text: + +> \$\\sqrt{-1}\$ *equals* \$i\$. +> +> √-̅1̅ *equals* $i$. + +Invoking pdfTeX should have the same effect: ``` sh texlua example.lua > example.tex pdftex document.tex @@ -1175,31 +1253,52 @@ named `document.tex` with the following content: \input lmfonts \directlua{ local markdown = require("markdown") - local convert_safe = markdown.new() - local convert_unsafe = markdown.new({hybrid = true}) - local input = [[$\noexpand\sqrt{-1}$ *equals* $i$.]] - tex.sprint(convert_safe(input) .. " " .. convert_unsafe(input)) } + local input, convert_safe, convert_unsafe, paragraph + + input = [[$\string\sqrt{-1}$ *equals* $i$.]] + convert_safe = markdown.new() + convert_unsafe = markdown.new({hybrid = true}) + paragraph = [[\par]] + + tex.sprint( + convert_safe(input) .. paragraph .. + convert_unsafe(input) + ) +} \bye ``````` Next, invoke LuaTeX from the terminal: ``` sh luatex document.tex ``````` -A PDF document named `document.pdf` should be produced and contain the text -“\$\\sqrt {-1}\$ *equals* \$i\$. √-̅1̅ *equals* $i$.” In this case, we cannot -use pdfTeX, because pdfTeX does not define the `\directlua` TeX command. +A PDF document named `document.pdf` should be produced and contain the +following text: -#### The Lua CLI +> \$\\sqrt{-1}\$ *equals* \$i\$. +> +> √-̅1̅ *equals* $i$. + +In this case, we cannot use pdfTeX, because pdfTeX does not define the +`\directlua` \TeX{} command. + +#### Lua Command-Line Interface -The Lua command-line interface (CLI) accepts the same options as the `markdown` -Lua module, but now the options are specified as command-line parameters. +The Lua command-line interface (CLI) of the Markdown package makes the +functionality of the Lua module accessible from the command line. This makes +it possible to convert documents from markdown to \TeX{} manually without any +knowledge of the Lua programming language. + +The Lua command-line interface accepts the same options as the `markdown` Lua +module, but now the options are specified as command-line parameters. Using a text editor, create a text document named `document.tex` with the following content: ``` tex \input markdown \input lmfonts -\input safe\ \input unsafe +\input safe + +\input unsafe \bye ``````` Using a text editor, create a text document named `example.md` with the @@ -1209,26 +1308,31 @@ $\sqrt{-1}$ *equals* $i$. `````` Next, invoke LuaTeX from the terminal: ``` sh -texlua -- example.md safe.tex -texlua hybrid=true -- example.md unsafe.tex +texlua ⟨CLI pathname⟩ -- example.md safe.tex +texlua ⟨CLI pathname⟩ hybrid=true -- example.md unsafe.tex luatex document.tex `````` -where `` corresponds to the location of the Lua CLI script file, +where \meta{CLI pathname} corresponds to the location of the Lua CLI script file, such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or -`C:\Users\\texmf\scripts\markdown\markdown-cli.lua` on Windows +`C:\Users\`\meta{Your username}`\texmf\scripts\markdown\markdown-cli.lua` on Windows systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI script file using [Kpathsea][]. -A PDF document named `document.pdf` should be produced and contain the text -“\$\\sqrt{-1}\$ *equals* \$i\$. √-̅1̅ *equals* $i$.” Invoking pdfTeX should have -the same effect: +A PDF document named `document.pdf` should be produced and contain the +following text: + +> \$\\sqrt{-1}\$ *equals* \$i\$. +> +> √-̅1̅ *equals* $i$. + +Invoking pdfTeX should have the same effect: ``` sh -texlua -- example.md safe.tex -texlua hybrid=true -- example.md unsafe.tex +texlua ⟨CLI pathname⟩ -- example.md safe.tex +texlua ⟨CLI pathname⟩ hybrid=true -- example.md unsafe.tex pdftex document.tex `````` -% +% %<*lua> % \fi % \begin{markdown} @@ -1241,15 +1345,14 @@ pdftex document.tex % \end{markdown} % \iffalse % -%<*manual> +%<*manual-options> -### Options +## Options -This section will cover the options recognized by the Lua interface. The -interfaces of the plain TeX, LaTeX, and ConTeXt macro packages recognize these -options as well, in addition to their own options. +In this section, I will describe all the options recognized by the Markdown +package. -% +% %<*lua,lua-cli> % \fi % \begin{macrocode} @@ -1279,17 +1382,24 @@ local defaultOptions = {} % \par % \iffalse % -%<*manual> -% \fi -% \begin{markdown} +%<*manual-options> -#### File and Directory Names +### Lua +Lua options control the conversion from markdown to \TeX{}. They are supported +by all interfaces of the Markdown package starting with the low-level Lua +interfaces and all the way up to the \LaTeX{} and \Hologo{ConTeXt} interfaces. + +% \fi +% \begin{markdown} +% +%### File and Directory Names +% % \end{markdown} % \par % \iffalse -##### Option `cacheDir` +#### Option `cacheDir` `cacheDir` (default value: `"."`) @@ -1300,8 +1410,8 @@ local defaultOptions = {} % : A path to the directory containing auxiliary cache files. If the last segment of the path does not exist, it will be created by the Lua - command-line and plain TeX implementations. The Lua implementation expects - that the entire path already exists. + command-line and plain \TeX{} implementations. The Lua implementation + expects that the entire path already exists. When iteratively writing and typesetting a markdown document, the cache files are going to accumulate over time. You are advised to clean the @@ -1311,7 +1421,7 @@ local defaultOptions = {} % \end{markdown} % \iffalse -###### Lua module example {.unnumbered} +##### Lua Module Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -1333,7 +1443,7 @@ A PDF document named `document.pdf` should be produced and contain the text “Hello *world*!” Several cache files of the Markdown package will also be produced in the `cache` directory as we requested using the `cacheDir` option. -###### Lua CLI example {.unnumbered} +##### Lua CLI Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -1349,12 +1459,12 @@ Hello *world*! `````` Next, invoke LuaTeX from the terminal: ``` sh -texlua cacheDir=cache -- hello.md hello.tex +texlua ⟨CLI pathname⟩ cacheDir=cache -- hello.md hello.tex luatex document.tex ``````` -where `` corresponds to the location of the Lua CLI script file, +where \meta{CLI pathname} corresponds to the location of the Lua CLI script file, such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or -`C:\Users\\texmf\scripts\markdown\markdown-cli.lua` on Windows +`C:\Users\`\meta{Your username}`\texmf\scripts\markdown\markdown-cli.lua` on Windows systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI script file using [Kpathsea][]. @@ -1363,7 +1473,7 @@ A PDF document named `document.pdf` should be produced and contain the text the Markdown package will also be produced as we requested using the `cacheDir` option. -###### Plain TeX example {.unnumbered} +##### Plain \TeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -1384,7 +1494,7 @@ A PDF document named `document.pdf` should be produced and contain the text “H Markdown package will also be produced as we requested using the `cacheDir` option. -###### LaTeX example {.unnumbered} +##### \LaTeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -1406,7 +1516,7 @@ A PDF document named `document.pdf` should be produced and contain the text “H Markdown package will also be produced as we requested using the `cacheDir` option. -###### ConTeXt example {.unnumbered} +##### \Hologo{ConTeXt} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -1428,7 +1538,7 @@ A PDF document named `document.pdf` should be produced and contain the text “H Markdown package will also be produced as we requested using the `cacheDir` option. -% +% %<*lua,lua-cli> % \fi % \begin{macrocode} @@ -1437,17 +1547,17 @@ defaultOptions.cacheDir = "." % \par % \iffalse % -%<*manual> +%<*manual-options> % \fi % \begin{markdown} - -#### Parser Options - +% +%### Parser Options +% % \end{markdown} % \par % \iffalse -##### Option `blankBeforeBlockquote` +#### Option `blankBeforeBlockquote` `blankBeforeBlockquote` (default value: `false`) @@ -1467,7 +1577,7 @@ defaultOptions.cacheDir = "." % \end{markdown} % \iffalse -###### Lua module example {.unnumbered} +##### Lua Module Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -1503,7 +1613,7 @@ following text: > > A paragraph > Not a quote. -###### Lua CLI example {.unnumbered} +##### Lua CLI Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -1522,13 +1632,13 @@ A paragraph. `````` Next, invoke LuaTeX from the terminal: ``` sh -texlua -- content.md optionfalse.tex -texlua blankBeforeBlockquote=true -- content.md optiontrue.tex +texlua ⟨CLI pathname⟩ -- content.md optionfalse.tex +texlua ⟨CLI pathname⟩ blankBeforeBlockquote=true -- content.md optiontrue.tex luatex document.tex ``````` -where `` corresponds to the location of the Lua CLI script file, +where \meta{CLI pathname} corresponds to the location of the Lua CLI script file, such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or -`C:\Users\\texmf\scripts\markdown\markdown-cli.lua` on Windows +`C:\Users\`\meta{Your username}`\texmf\scripts\markdown\markdown-cli.lua` on Windows systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI script file using [Kpathsea][]. @@ -1541,7 +1651,7 @@ following text: > > A paragraph. > A quote? -###### Plain TeX example {.unnumbered} +##### Plain \TeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -1574,7 +1684,7 @@ following text: > > A paragraph > Not a quote. -###### LaTeX example {.unnumbered} +##### \LaTeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -1608,7 +1718,7 @@ following text: > > A paragraph > Not a quote. -###### ConTeXt example {.unnumbered} +##### \Hologo{ConTeXt} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -1642,7 +1752,7 @@ following text: > > A paragraph > Not a quote. -% +% %<*lua,lua-cli> % \fi % \begin{macrocode} @@ -1651,9 +1761,9 @@ defaultOptions.blankBeforeBlockquote = false % \par % \iffalse % -%<*manual> +%<*manual-options> -##### Option `blankBeforeCodeFence` +#### Option `blankBeforeCodeFence` `blankBeforeCodeFence` (default value: `false`) @@ -1675,7 +1785,7 @@ defaultOptions.blankBeforeBlockquote = false % \end{markdown} % \iffalse -###### Lua module example {.unnumbered} +##### Lua Module Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -1718,7 +1828,7 @@ following text: > > A paragraph. ``` Not a code fence. ``` -###### Lua CLI example {.unnumbered} +##### Lua CLI Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -1739,13 +1849,13 @@ A code fence? ``````` Next, invoke LuaTeX from the terminal: ``` sh -texlua fencedCode=true -- content.md optionfalse.tex -texlua fencedCode=true blankBeforeCodeFence=true -- content.md optiontrue.tex +texlua ⟨CLI pathname⟩ fencedCode=true -- content.md optionfalse.tex +texlua ⟨CLI pathname⟩ fencedCode=true blankBeforeCodeFence=true -- content.md optiontrue.tex luatex document.tex ``````` -where `` corresponds to the location of the Lua CLI script file, +where \meta{CLI pathname} corresponds to the location of the Lua CLI script file, such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or -`C:\Users\\texmf\scripts\markdown\markdown-cli.lua` on Windows +`C:\Users\`\meta{Your username}`\texmf\scripts\markdown\markdown-cli.lua` on Windows systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI script file using [Kpathsea][]. @@ -1760,7 +1870,7 @@ following text: > > A paragraph. ``` A code fence? ``` -###### Plain TeX example {.unnumbered} +##### Plain \TeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -1800,7 +1910,7 @@ following text: > > A paragraph. ``` Not a code fence. ``` -###### LaTeX example {.unnumbered} +##### \LaTeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -1840,7 +1950,7 @@ following text: > > A paragraph. ``` Not a code fence. ``` -###### ConTeXt example {.unnumbered} +##### \Hologo{ConTeXt} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -1881,7 +1991,7 @@ following text: > > A paragraph. ``` Not a code fence. ``` -% +% %<*lua,lua-cli> % \fi % \begin{macrocode} @@ -1890,9 +2000,9 @@ defaultOptions.blankBeforeCodeFence = false % \par % \iffalse % -%<*manual> +%<*manual-options> -##### Option `blankBeforeHeading` +#### Option `blankBeforeHeading` `blankBeforeHeading` (default value: `false`) @@ -1913,7 +2023,7 @@ defaultOptions.blankBeforeCodeFence = false % \end{markdown} % \iffalse -###### Lua module example {.unnumbered} +##### Lua Module Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -1953,7 +2063,7 @@ following text: > > A paragraph. Not a heading. ============== -###### Lua CLI example {.unnumbered} +##### Lua CLI Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -1973,13 +2083,13 @@ A heading? `````` Next, invoke LuaTeX from the terminal: ``` sh -texlua -- content.md optionfalse.tex -texlua blankBeforeHeading=true -- content.md optiontrue.tex +texlua ⟨CLI pathname⟩ -- content.md optionfalse.tex +texlua ⟨CLI pathname⟩ blankBeforeHeading=true -- content.md optiontrue.tex luatex document.tex ``````` -where `` corresponds to the location of the Lua CLI script file, +where \meta{CLI pathname} corresponds to the location of the Lua CLI script file, such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or -`C:\Users\\texmf\scripts\markdown\markdown-cli.lua` on Windows +`C:\Users\`\meta{Your username}`\texmf\scripts\markdown\markdown-cli.lua` on Windows systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI script file using [Kpathsea][]. @@ -1993,7 +2103,7 @@ following text: > > A paragraph. A heading? ========== -###### Plain TeX example {.unnumbered} +##### Plain \TeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -2029,7 +2139,7 @@ following text: > > A paragraph. Not a heading. ============== -###### LaTeX example {.unnumbered} +##### \LaTeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -2066,7 +2176,7 @@ following text: > > A paragraph. Not a heading. ============== -###### ConTeXt example {.unnumbered} +##### \Hologo{ConTeXt} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -2103,7 +2213,7 @@ following text: > > A paragraph. Not a heading. ============== -% +% %<*lua,lua-cli> % \fi % \begin{macrocode} @@ -2112,9 +2222,9 @@ defaultOptions.blankBeforeHeading = false % \par % \iffalse % -%<*manual> +%<*manual-options> -##### Option `breakableBlockquotes` +#### Option `breakableBlockquotes` `breakableBlockquotes` (default value: `false`) @@ -2134,7 +2244,7 @@ defaultOptions.blankBeforeHeading = false % \end{markdown} % \iffalse -###### Lua module example {.unnumbered} +##### Lua Module Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -2171,7 +2281,7 @@ following text: > > > Another block quote. -###### Lua CLI example {.unnumbered} +##### Lua CLI Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -2191,13 +2301,13 @@ following content: `````` Next, invoke LuaTeX from the terminal: ``` sh -texlua -- content.md optionfalse.tex -texlua breakableBlockquotes=true -- content.md optiontrue.tex +texlua ⟨CLI pathname⟩ -- content.md optionfalse.tex +texlua ⟨CLI pathname⟩ breakableBlockquotes=true -- content.md optiontrue.tex luatex document.tex ``````` -where `` corresponds to the location of the Lua CLI script file, +where \meta{CLI pathname} corresponds to the location of the Lua CLI script file, such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or -`C:\Users\\texmf\scripts\markdown\markdown-cli.lua` on Windows +`C:\Users\`\meta{Your username}`\texmf\scripts\markdown\markdown-cli.lua` on Windows systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI script file using [Kpathsea][]. @@ -2210,7 +2320,7 @@ following text: > > > or two block quotes? -###### Plain TeX example {.unnumbered} +##### Plain \TeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -2245,7 +2355,7 @@ following text: > > > Another block quote. -###### LaTeX example {.unnumbered} +##### \LaTeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -2281,7 +2391,7 @@ following text: > > > Another block quote. -###### ConTeXt example {.unnumbered} +##### \Hologo{ConTeXt} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -2317,7 +2427,7 @@ following text: > > > Another block quote. -% +% %<*lua,lua-cli> % \fi % \begin{macrocode} @@ -2326,9 +2436,9 @@ defaultOptions.breakableBlockquotes = false % \par % \iffalse % -%<*manual> +%<*manual-options> -##### Option `citationNbsps` +#### Option `citationNbsps` `citationNbsps` (default value: `true`) @@ -2352,7 +2462,7 @@ defaultOptions.breakableBlockquotes = false % \end{markdown} % \iffalse -###### LaTeX example {.unnumbered} +##### \LaTeX{} Example {.unnumbered} Using a text editor, create a text document named `document.bib` with the following content: @@ -2361,7 +2471,8 @@ following content: author = "Knuth, Donald Ervin", title = "The \TeX book, volume A of Computers and typesetting", publisher = "Addison-Wesley", - year = "1984" } + year = "1984" +} ``````` Using a text editor, create a text document named `document.tex` with the following content: @@ -2400,7 +2511,7 @@ following text, where the middot (`·`) denotes a non-breakable space: > [1] Donald·Ervin Knuth. _The TeXbook, volume A of Computers and typesetting._ > Addison-Wesley, 1984. -% +% %<*lua,lua-cli> % \fi % \begin{macrocode} @@ -2409,9 +2520,9 @@ defaultOptions.citationNbsps = true % \par % \iffalse % -%<*manual> +%<*manual-options> -##### Option `citations` +#### Option `citations` `citations` (default value: `false`) @@ -2447,7 +2558,7 @@ defaultOptions.citationNbsps = true % \end{markdown} % \iffalse -###### LaTeX example {.unnumbered} +##### \LaTeX{} Example {.unnumbered} Using a text editor, create a text document named `document.bib` with the following content: @@ -2456,7 +2567,8 @@ following content: author = "Knuth, Donald Ervin", title = "The \TeX book, volume A of Computers and typesetting", publisher = "Addison-Wesley", - year = "1984" } + year = "1984" +} ``````` Using a text editor, create a text document named `document.tex` with the following content: @@ -2487,10 +2599,10 @@ following text: > The TeXbook [1, p.·123 and 130] was written by Knuth [1]. > > ### References -> [1] Donald Ervin Knuth. _The TeXbook, volume A of Computers and typesetting._ +> [1] Donald Ervin Knuth. _The \TeX{}book, volume A of Computers and typesetting._ > Addison-Wesley, 1984. -% +% %<*lua,lua-cli> % \fi % \begin{macrocode} @@ -2499,9 +2611,9 @@ defaultOptions.citations = false % \par % \iffalse % -%<*manual> +%<*manual-options> -##### Option `codeSpans` +#### Option `codeSpans` `codeSpans` (default value: `true`) @@ -2532,7 +2644,7 @@ defaultOptions.citations = false % \end{markdown} % \iffalse -###### Lua module example {.unnumbered} +##### Lua Module Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -2567,7 +2679,7 @@ following text: > > “This is a quote.” “This is another quote.” -###### Lua CLI example {.unnumbered} +##### Lua CLI Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -2586,13 +2698,13 @@ following content: `````` Next, invoke LuaTeX from the terminal: ``` sh -texlua codeSpans=false -- content.md optionfalse.tex -texlua -- content.md optiontrue.tex +texlua ⟨CLI pathname⟩ codeSpans=false -- content.md optionfalse.tex +texlua ⟨CLI pathname⟩ -- content.md optiontrue.tex luatex document.tex ``````` -where `` corresponds to the location of the Lua CLI script file, +where \meta{CLI pathname} corresponds to the location of the Lua CLI script file, such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or -`C:\Users\\texmf\scripts\markdown\markdown-cli.lua` on Windows +`C:\Users\`\meta{Your username}`\texmf\scripts\markdown\markdown-cli.lua` on Windows systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI script file using [Kpathsea][]. @@ -2603,7 +2715,7 @@ following text: > > ``Is this a code span?'' ``Or a quote?'' -###### Plain TeX example {.unnumbered} +##### Plain \TeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -2634,7 +2746,7 @@ following text: > > “This is a quote.” “This is another quote.” -###### LaTeX example {.unnumbered} +##### \LaTeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -2666,7 +2778,7 @@ following text: > > “This is a quote.” “This is another quote.” -###### ConTeXt example {.unnumbered} +##### \Hologo{ConTeXt} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -2698,7 +2810,7 @@ following text: > > “This is a quote.” “This is another quote.” -% +% %<*lua,lua-cli> % \fi % \begin{macrocode} @@ -2707,9 +2819,9 @@ defaultOptions.codeSpans = true % \par % \iffalse % -%<*manual> +%<*manual-options> -##### Option `contentBlocks` +#### Option `contentBlocks` `contentBlocks` (default value: `false`) @@ -2723,7 +2835,7 @@ defaultOptions.codeSpans = true : Enable the % iA\,Writer content blocks syntax extension~[@sotkov17]: % \iffalse - iA Writer content blocks syntax extension: + iA\,Writer content blocks syntax extension: % \fi ``` md @@ -2738,15 +2850,12 @@ defaultOptions.codeSpans = true : false : Disable the -% iA\,Writer content blocks syntax extension. -% \iffalse - iA Writer content blocks syntax extension. -% \fi + iA\,Writer content blocks syntax extension. % \end{markdown} % \iffalse -###### LaTeX example {.unnumbered} +##### \LaTeX{} Example {.unnumbered} Using a text editor, create a text document named `table.csv` with the following content: @@ -2805,7 +2914,7 @@ following text: > > This is a *transcluded markdown document*. -###### ConTeXt example {.unnumbered} +##### \Hologo{ConTeXt} Example {.unnumbered} Using a text editor, create a text document named `table.csv` with the following content: @@ -2865,7 +2974,7 @@ following text: > > This is a *transcluded markdown document*. -% +% %<*lua,lua-cli> % \fi % \begin{macrocode} @@ -2874,9 +2983,9 @@ defaultOptions.contentBlocks = false % \par % \iffalse % -%<*manual> +%<*manual-options> -##### Option `contentBlocksLanguageMap` +#### Option `contentBlocksLanguageMap` `contentBlocksLanguageMap` (default value: `"markdown-languages.json"`) @@ -2886,13 +2995,13 @@ defaultOptions.contentBlocks = false % \Valitem[markdown-languages.json]{contentBlocksLanguageMap}{filename} % : The filename of the JSON file that maps filename extensions to - programming language names in the iA Writer content blocks. + programming language names in the iA\,Writer content blocks. % See Section~\ref{sec:texcontentblockrenderers} for more information. % \end{markdown} % \iffalse -###### LaTeX example {.unnumbered} +##### \LaTeX{} Example {.unnumbered} Using a text editor, create a text document named `table.csv` with the following content: @@ -2954,7 +3063,7 @@ following text: > > This is a *transcluded markdown document*. -###### ConTeXt example {.unnumbered} +##### \Hologo{ConTeXt} Example {.unnumbered} Using a text editor, create a text document named `table.csv` with the following content: @@ -3015,7 +3124,7 @@ following text: > > This is a *transcluded markdown document*. -% +% %<*lua,lua-cli> % \fi % \begin{macrocode} @@ -3024,9 +3133,9 @@ defaultOptions.contentBlocksLanguageMap = "markdown-languages.json" % \par % \iffalse % -%<*manual> +%<*manual-options> -##### Option `definitionLists` +#### Option `definitionLists` `definitionLists` (default value: `false`) @@ -3060,7 +3169,7 @@ defaultOptions.contentBlocksLanguageMap = "markdown-languages.json" % \end{markdown} % \iffalse -###### LaTeX example {.unnumbered} +##### \LaTeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -3102,7 +3211,7 @@ following text: > > Third paragraph of definition 2. -###### ConTeXt example {.unnumbered} +##### \Hologo{ConTeXt} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -3144,7 +3253,7 @@ following text: > > Third paragraph of definition 2. -% +% %<*lua,lua-cli> % \fi % \begin{macrocode} @@ -3153,9 +3262,9 @@ defaultOptions.definitionLists = false % \par % \iffalse % -%<*manual> +%<*manual-options> -##### Option `fencedCode` +#### Option `fencedCode` `fencedCode` (default value: `false`) @@ -3194,11 +3303,11 @@ defaultOptions.definitionLists = false % \end{markdown} % \iffalse -###### LaTeX example {.unnumbered} +##### \LaTeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: -``` tex +```` tex \documentclass{article} \usepackage{minted} \usepackage[fencedCode]{markdown} @@ -3247,11 +3356,11 @@ following text: > > ``` -###### ConTeXt example {.unnumbered} +##### \Hologo{ConTeXt} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: -``` tex +```` tex \usemodule[t][markdown] \def\markdownOptionFencedCode{true} \definetyping [js] @@ -3302,7 +3411,7 @@ following text: > > ``` -% +% %<*lua,lua-cli> % \fi % \begin{macrocode} @@ -3311,9 +3420,9 @@ defaultOptions.fencedCode = false % \par % \iffalse % -%<*manual> +%<*manual-options> -##### Option `footnotes` +#### Option `footnotes` `footnotes` (default value: `false`) @@ -3353,7 +3462,7 @@ defaultOptions.fencedCode = false % \end{markdown} % \iffalse -###### LaTeX example {.unnumbered} +##### \LaTeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -3407,7 +3516,7 @@ following text: > This paragraph won't be part of the note, because it > isn't indented. -###### ConTeXt example {.unnumbered} +##### \Hologo{ConTeXt} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -3461,7 +3570,7 @@ following text: > This paragraph won't be part of the note, because it > isn't indented. -% +% %<*lua,lua-cli> % \fi % \begin{macrocode} @@ -3470,9 +3579,9 @@ defaultOptions.footnotes = false % \par % \iffalse % -%<*manual> +%<*manual-options> -##### Option `hashEnumerators` +#### Option `hashEnumerators` `hashEnumerators` (default value: `false`) @@ -3500,7 +3609,7 @@ defaultOptions.footnotes = false % \end{markdown} % \iffalse -###### LaTeX example {.unnumbered} +##### \LaTeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -3510,15 +3619,15 @@ following content: \begin{document} \begin{markdown} -#. Bird -#. McHale -#. Parish +. Bird +. McHale +. Parish \end{markdown} \begin{markdown*}{hashEnumerators} -#. Bird -#. McHale -#. Parish +. Bird +. McHale +. Parish \end{markdown*} \end{document} @@ -3541,7 +3650,7 @@ following text: > #. McHale > #. Parish -###### ConTeXt example {.unnumbered} +##### \Hologo{ConTeXt} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -3550,16 +3659,16 @@ following content: \starttext \startmarkdown -#. Bird -#. McHale -#. Parish +. Bird +. McHale +. Parish \stopmarkdown \def\markdownOptionHashEnumerators{true} \startmarkdown -#. Bird -#. McHale -#. Parish +. Bird +. McHale +. Parish \stopmarkdown \stoptext @@ -3582,7 +3691,7 @@ following text: > #. McHale > #. Parish -% +% %<*lua,lua-cli> % \fi % \begin{macrocode} @@ -3591,9 +3700,54 @@ defaultOptions.hashEnumerators = false % \par % \iffalse % -%<*manual> +%<*manual-options> + +#### Option `headerAttributes` {#header-attributes} + +`headerAttributes` (default value: `false`) + +% \fi +% \begin{markdown} +% +% \Optitem[false]{headerAttributes}{\opt{true}, \opt{false}} +% +: true + + : Enable the assignment of HTML attributes to headings: + + ``` md + # My first heading {#foo} + + ## My second heading ## {#bar .baz} + + Yet another heading {key=value} + =================== + `````` + + These HTML attributes have currently no effect other than enabling +% content slicing, see the \Opt{slice} option. +% \iffalse + [content slicing](#slice). +% \fi + +: false + + : Disable the assignment of HTML attributes to headings. -##### Option `html` +% \end{markdown} +% \iffalse +% +%<*lua,lua-cli> +% \fi +% \begin{macrocode} +defaultOptions.headerAttributes = false +% \end{macrocode} +% \par +% \iffalse +% +%<*manual-options> + +#### Option `html` `html` (default value: `false`) @@ -3625,7 +3779,7 @@ See [the corresponding issue][issue-38] in the package repository. (HTML entities with the `html` Lua option enabled produce a Lua parser error) -###### Lua module example {.unnumbered} +##### Lua Module Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -3668,7 +3822,7 @@ following text: > > There is support. There is support. There is support. -###### Lua CLI example {.unnumbered} +##### Lua CLI Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -3692,13 +3846,13 @@ _Is there support?_ ```````` Next, invoke LuaTeX from the terminal: ``` sh -texlua -- content.md optionfalse.tex -texlua html=true -- content.md optiontrue.tex +texlua ⟨CLI pathname⟩ -- content.md optionfalse.tex +texlua ⟨CLI pathname⟩ html=true -- content.md optiontrue.tex luatex document.tex ``````` -where `` corresponds to the location of the Lua CLI script file, +where \meta{CLI pathname} corresponds to the location of the Lua CLI script file, such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or -`C:\Users\\texmf\scripts\markdown\markdown-cli.lua` on Windows +`C:\Users\`\meta{Your username}`\texmf\scripts\markdown\markdown-cli.lua` on Windows systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI script file using [Kpathsea][]. @@ -3712,7 +3866,7 @@ following text: > > Is there support? Is there support? Is there support? -###### Plain TeX example {.unnumbered} +##### Plain \TeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -3755,7 +3909,7 @@ following text: > > There is support. There is support. There is support. -###### LaTeX example {.unnumbered} +##### \LaTeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -3798,7 +3952,7 @@ following text: > > There is support. There is support. There is support. -###### ConTeXt example {.unnumbered} +##### \Hologo{ConTeXt} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -3841,7 +3995,7 @@ following text: > > There is support. There is support. There is support. -% +% %<*lua,lua-cli> % \fi % \begin{macrocode} @@ -3850,9 +4004,9 @@ defaultOptions.html = false % \par % \iffalse % -%<*manual> +%<*manual-options> -##### Option `hybrid` +#### Option `hybrid` `hybrid` (default value: `true`) @@ -3863,23 +4017,23 @@ defaultOptions.html = false % : true - : Disable the escaping of special plain TeX characters, which makes it - possible to intersperse your markdown markup with TeX code. The + : Disable the escaping of special plain \TeX{} characters, which makes it + possible to intersperse your markdown markup with \TeX{} code. The intended usage is in documents prepared manually by a human author. - In such documents, it can often be desirable to mix TeX and markdown + In such documents, it can often be desirable to mix \TeX{} and markdown markup freely. : false - : Enable the escaping of special plain TeX characters outside verbatim - environments, so that they are not interpretted by TeX. This is + : Enable the escaping of special plain \TeX{} characters outside verbatim + environments, so that they are not interpretted by \TeX{}. This is encouraged when typesetting automatically generated content or markdown documents that were not prepared with this package in mind. % \end{markdown} % \iffalse -###### Lua module example {.unnumbered} +##### Lua Module Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -3888,10 +4042,18 @@ following content: \input lmfonts \directlua{ local markdown = require("markdown") - local convert_safe = markdown.new() - local convert_unsafe = markdown.new({hybrid = true}) - local input = [[$\noexpand\sqrt{-1}$ *equals* $i$.]] - tex.sprint(convert_safe(input) .. " " .. convert_unsafe(input)) } + local input, convert_safe, convert_unsafe, paragraph + + input = [[$\string\sqrt{-1}$ *equals* $i$.]] + convert_safe = markdown.new() + convert_unsafe = markdown.new({hybrid = true}) + paragraph = [[\par]] + + tex.sprint( + convert_safe(input) .. paragraph .. + convert_unsafe(input) + ) +} \bye ``````` Then, invoke LuaTeX from the terminal: @@ -3902,9 +4064,10 @@ A PDF document named `document.pdf` should be produced and contain the following text: > \$\\sqrt {-1}\$ *equals* \$i\$. +> > √-̅1̅ *equals* $i$. -###### Lua CLI example {.unnumbered} +##### Lua CLI Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -3912,6 +4075,7 @@ following content: \input markdown \input lmfonts \input optionfalse + \input optiontrue \bye ``````` @@ -3922,13 +4086,13 @@ $\sqrt{-1}$ *equals* $i$. `````` Next, invoke LuaTeX from the terminal: ``` sh -texlua -- content.md optionfalse.tex -texlua hybrid=true -- content.md optiontrue.tex +texlua ⟨CLI pathname⟩ -- content.md optionfalse.tex +texlua ⟨CLI pathname⟩ hybrid=true -- content.md optiontrue.tex luatex document.tex ``````` -where `` corresponds to the location of the Lua CLI script file, +where \meta{CLI pathname} corresponds to the location of the Lua CLI script file, such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or -`C:\Users\\texmf\scripts\markdown\markdown-cli.lua` on Windows +`C:\Users\`\meta{Your username}`\texmf\scripts\markdown\markdown-cli.lua` on Windows systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI script file using [Kpathsea][]. @@ -3936,22 +4100,26 @@ A PDF document named `document.pdf` should be produced and contain the following text: > \$\\sqrt {-1}\$ *equals* \$i\$. +> > √-̅1̅ *equals* $i$. -###### Plain TeX example {.unnumbered} +##### Plain \TeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: ``` tex \input markdown \input lmfonts + \markdownBegin $\sqrt{-1}$ *equals* $i$. \markdownEnd + \def\markdownOptionHybrid{true} \markdownBegin $\sqrt{-1}$ *equals* $i$. \markdownEnd + \bye ``````` Next, invoke LuaTeX from the terminal: @@ -3962,9 +4130,10 @@ A PDF document named `document.pdf` should be produced and contain the following text: > \$\\sqrt {-1}\$ *equals* \$i\$. +> > √-̅1̅ *equals* $i$. -###### LaTeX example {.unnumbered} +##### \LaTeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -3972,12 +4141,15 @@ following content: \documentclass{article} \usepackage{markdown} \begin{document} + \begin{markdown} $\sqrt{-1}$ *equals* $i$. \end{markdown} + \begin{markdown*}{hybrid} $\sqrt{-1}$ *equals* $i$. \end{markdown*} + \end{document} ``````` Next, invoke LuaTeX from the terminal: @@ -3988,22 +4160,26 @@ A PDF document named `document.pdf` should be produced and contain the following text: > \$\\sqrt {-1}\$ *equals* \$i\$. +> > √-̅1̅ *equals* $i$. -###### ConTeXt example {.unnumbered} +##### \Hologo{ConTeXt} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: ``` tex \usemodule[t][markdown] \starttext + \startmarkdown $\sqrt{-1}$ *equals* $i$. \stopmarkdown + \def\markdownOptionHybrid{true} \startmarkdown $\sqrt{-1}$ *equals* $i$. \stopmarkdown + \stoptext ```````` Next, invoke LuaTeX from the terminal: @@ -4014,9 +4190,10 @@ A PDF document named `document.pdf` should be produced and contain the following text: > \$\\sqrt {-1}\$ *equals* \$i\$. +> > √-̅1̅ *equals* $i$. -% +% %<*lua,lua-cli> % \fi % \begin{macrocode} @@ -4025,9 +4202,9 @@ defaultOptions.hybrid = false % \par % \iffalse % -%<*manual> +%<*manual-options> -##### Option `inlineFootnotes` +#### Option `inlineFootnotes` `inlineFootnotes` (default value: `false`) @@ -4053,7 +4230,7 @@ defaultOptions.hybrid = false % \end{markdown} % \iffalse -###### LaTeX example {.unnumbered} +##### \LaTeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -4079,7 +4256,7 @@ following text: > write, since you don't have to pick an identifier and > move down to type the note.] -###### ConTeXt example {.unnumbered} +##### \Hologo{ConTeXt} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -4106,7 +4283,7 @@ following text: > write, since you don't have to pick an identifier and > move down to type the note.] -% +% %<*lua,lua-cli> % \fi % \begin{macrocode} @@ -4115,9 +4292,9 @@ defaultOptions.inlineFootnotes = false % \par % \iffalse % -%<*manual> +%<*manual-options> -##### Option `preserveTabs` +#### Option `preserveTabs` `preserveTabs` (default value: `false`) @@ -4144,7 +4321,7 @@ issue][issue-38] in the package repository. (Tabs are stripped even with the `preserveTabs=true` Lua option enabled) -% +% %<*lua,lua-cli> % \fi % \begin{macrocode} @@ -4153,117 +4330,80 @@ defaultOptions.preserveTabs = false % \par % \iffalse % -%<*manual> +%<*manual-options> -##### Option `smartEllipses` +#### Option `slice` {#slice} -`smartEllipses` (default value: `false`) +`slice` (default value: `^ $`) % \fi % \begin{markdown} % -% \Optitem[false]{smartEllipses}{\opt{true}, \opt{false}} +% \Valitem[\textasciicircum{} \$]{slice}{the beginning and the end of a slice} % -: true - - : Convert any ellipses in the input to the -% \m{markdownRendererEllipsis} \TeX{} macro. -% \iffalse - `\markdownRendererEllipsis` TeX macro. -% \fi +: Two space-separated selectors that specify the slice of a document that + will be processed, whereas the remainder of the document will be ignored. + The following selectors are recognized: -: false + - The circumflex (`^`) selects the beginning of a document. + - The dollar sign (`$`) selects the end of a document. + - `^`\meta{identifier} selects the beginning of a section with the +% HTML attribute `#`\meta{identifier} (see the +% \Opt{headerAttributes} option). + \iffalse + [HTML attribute](#header-attributes) `#`\meta{identifier}. +% \fi + - `$`\meta{identifier} selects the end of a section with the HTML + attribute `#`\meta{identifier}. + - \meta{identifier} corresponds to `^`\meta{identifier} for the first + selector and to `$`\meta{identifier} for the second selector. - : Preserve all ellipses in the input. + Specifying only a single selector, \meta{identifier}, is equivalent + to specifying the two selectors \meta{identifier} \meta{identifier}, + which is equivalent to `^`\meta{identifier} `$`\meta{identifier}. % \end{markdown} % \iffalse -###### Lua module example {.unnumbered} +##### Plain \TeX{} Example {.unnumbered} -Using a text editor, create a text document named `document.tex` with the +Using a text editor, create a text document named `hamlet.md` with the following content: -``` tex -\input markdown -\def\markdownRendererEllipsis{. . .} -\input lmfonts -\directlua{ - local markdown = require("markdown") - local convert = markdown.new() - input = "These are just three regular dots ..." - tex.sprint(convert(input)) } -\par -\directlua{ - local markdown = require("markdown") - local convert = markdown.new({smartEllipses = true}) - input = "... and this is a victorian ellipsis." - tex.sprint(convert(input)) } -\bye -``````` -Then, invoke LuaTeX from the terminal: -``` sh -luatex document.tex -``````` -A PDF document named `document.pdf` should be produced and contain the -following text: - -> These are just three regular dots ... -> -> . . . and this is a victorian ellipsis. - -###### Lua CLI example {.unnumbered} -Using a text editor, create a text document named `document.tex` with the -following content: -``` tex -\input markdown -\def\markdownRendererEllipsis{. . .} -\input lmfonts -\input optionfalse -\par -\input optiontrue -\bye -``````` -Using a text editor, create a text document named `content.md` with the -following content: ``` md -Are these just three regular dots, a victorian ellipsis, or ... ? -`````` -Next, invoke LuaTeX from the terminal: -``` sh -texlua -- content.md optionfalse.tex -texlua smartEllipses=true -- content.md optiontrue.tex -luatex document.tex -``````` -where `` corresponds to the location of the Lua CLI script file, -such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or -`C:\Users\\texmf\scripts\markdown\markdown-cli.lua` on Windows -systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI -script file using [Kpathsea][]. +# The Tragedy of Hamlet +Shakespeare's longest play. -A PDF document named `document.pdf` should be produced and contain the -following text: +## Act III {#act-3} +Hamlet kills Polonius. -> Are these just three regular dots, a victorian ellipsis, or ... ? -> -> Are these just three regular dots, a victorian ellipsis, or . . . ? +## Act V {#act-5} +Hamlet dies. -###### Plain TeX example {.unnumbered} +## Act I {#act-1} +Hamlet talks to ghost. +``` Using a text editor, create a text document named `document.tex` with the following content: ``` tex \input markdown -\def\markdownRendererEllipsis{. . .} +\def\markdownOptionHeaderAttributes{true} -\markdownBegin -These are just three regular dots ... -\markdownEnd +\font\normal=cmr10\normal +\font\big=cmr10 at 12pt +\def\markdownRendererHeadingTwo#1{{\big #1\par}} +\font\bigger=cmr10 scaled 1440 +\def\markdownRendererHeadingOne#1{{\bigger #1\par}} -\def\markdownOptionSmartEllipses{true} -\markdownBegin -... and this is a victorian ellipsis. -\markdownEnd +\def\markdownOptionSlice{^ ^act-3} +\markdownInput{hamlet.md} + +\def\markdownOptionSlice{act-1} +\markdownInput{hamlet.md} + +\def\markdownOptionSlice{act-3 act-5} +\markdownInput{hamlet.md} \bye ``````` @@ -4274,30 +4414,43 @@ luatex document.tex A PDF document named `document.pdf` should be produced and contain the following text: -> These are just three regular dots ... +> # The Tragedy of Hamlet +> Shakespeare's longest play. > -> . . . and this is a victorian ellipsis. +> ## Act I +> Hamlet talks to ghost. +> +> ## Act III +> Hamlet kills Polonius. +> +> ## Act V +> Hamlet dies. -###### LaTeX example {.unnumbered} +##### \LaTeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: ``` tex \documentclass{article} -\usepackage{markdown} -\markdownSetup{ - renderers = { - ellipsis = {. . .} }} -\begin{document} +\usepackage[headerAttributes]{markdown} +\usepackage{filecontents} +\begin{filecontents*}{hamlet.md} +# The Tragedy of Hamlet +Shakespeare's longest play. -\begin{markdown} -These are just three regular dots ... -\end{markdown} +## Act III {#act-3} +Hamlet kills Polonius. -\begin{markdown*}{smartEllipses} -... and this is a victorian ellipsis. -\end{markdown*} +## Act V {#act-5} +Hamlet dies. +## Act I {#act-1} +Hamlet talks to ghost. +\end{filecontents*} +\begin{document} +\markdownInput[slice=^ ^act-3]{hamlet.md} +\markdownInput[slice=act-1]{hamlet.md} +\markdownInput[slice=act-3 act-5]{hamlet.md} \end{document} ``````` Next, invoke LuaTeX from the terminal: @@ -4307,11 +4460,240 @@ lualatex document.tex A PDF document named `document.pdf` should be produced and contain the following text: -> These are just three regular dots ... +> # The Tragedy of Hamlet +> Shakespeare's longest play. +> +> ## Act I +> Hamlet talks to ghost. +> +> ## Act III +> Hamlet kills Polonius. +> +> ## Act V +> Hamlet dies. + +##### \Hologo{ConTeXt} Example {.unnumbered} + +Using a text editor, create a text document named `hamlet.md` with the +following content: + +``` md +# The Tragedy of Hamlet +Shakespeare's longest play. + +## Act III {#act-3} +Hamlet kills Polonius. + +## Act V {#act-5} +Hamlet dies. + +## Act I {#act-1} +Hamlet talks to ghost. +``` + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\usemodule[t][markdown] +\def\markdownOptionHeaderAttributes{true} +\starttext + +\def\markdownOptionSlice{^ ^act-3} +\markdownInput{hamlet.md} + +\def\markdownOptionSlice{act-1} +\markdownInput{hamlet.md} + +\def\markdownOptionSlice{act-3 act-5} +\markdownInput{hamlet.md} + +\stoptext +```````` +Next, invoke LuaTeX from the terminal: +``` sh +context document.tex +````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> # The Tragedy of Hamlet +> Shakespeare's longest play. +> +> ## Act I +> Hamlet talks to ghost. +> +> ## Act III +> Hamlet kills Polonius. +> +> ## Act V +> Hamlet dies. + +% +%<*lua,lua-cli> +% \fi +% \begin{macrocode} +defaultOptions.slice = "^ $" +% \end{macrocode} +% \par +% \iffalse +% +%<*manual-options> + + +#### Option `smartEllipses` + +`smartEllipses` (default value: `false`) + +% \fi +% \begin{markdown} +% +% \Optitem[false]{smartEllipses}{\opt{true}, \opt{false}} +% +: true + + : Convert any ellipses in the input to the + \m{markdownRendererEllipsis} \TeX{} macro. + +: false + + : Preserve all ellipses in the input. + +% \end{markdown} +% \iffalse + +##### Lua Module Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\input markdown +\def\markdownRendererEllipsis{. . .} +\input lmfonts +\directlua{ + local markdown = require("markdown") + local convert = markdown.new() + local input = "These are just three regular dots ..." + tex.sprint(convert(input)) } +\par +\directlua{ + local markdown = require("markdown") + local convert = markdown.new({smartEllipses = true}) + local input = "... and this is a victorian ellipsis." + tex.sprint(convert(input)) } +\bye +``````` +Then, invoke LuaTeX from the terminal: +``` sh +luatex document.tex +``````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> These are just three regular dots ... +> +> . . . and this is a victorian ellipsis. + +##### Lua CLI Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\input markdown +\def\markdownRendererEllipsis{. . .} +\input lmfonts +\input optionfalse +\par +\input optiontrue +\bye +``````` +Using a text editor, create a text document named `content.md` with the +following content: +``` md +Are these just three regular dots, a victorian ellipsis, or ... ? +`````` +Next, invoke LuaTeX from the terminal: +``` sh +texlua ⟨CLI pathname⟩ -- content.md optionfalse.tex +texlua ⟨CLI pathname⟩ smartEllipses=true -- content.md optiontrue.tex +luatex document.tex +``````` +where \meta{CLI pathname} corresponds to the location of the Lua CLI script file, +such as `~/texmf/scripts/markdown/markdown-cli.lua` on UN\*X systems or +`C:\Users\`\meta{Your username}`\texmf\scripts\markdown\markdown-cli.lua` on Windows +systems. Use the command `kpsewhich markdown-cli.lua` to locate the Lua CLI +script file using [Kpathsea][]. + +A PDF document named `document.pdf` should be produced and contain the +following text: + +> Are these just three regular dots, a victorian ellipsis, or ... ? +> +> Are these just three regular dots, a victorian ellipsis, or . . . ? + +##### Plain \TeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\input markdown +\def\markdownRendererEllipsis{. . .} + +\markdownBegin +These are just three regular dots ... +\markdownEnd + +\def\markdownOptionSmartEllipses{true} +\markdownBegin +... and this is a victorian ellipsis. +\markdownEnd + +\bye +``````` +Next, invoke LuaTeX from the terminal: +``` sh +luatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> These are just three regular dots ... +> +> . . . and this is a victorian ellipsis. + +##### \LaTeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\documentclass{article} +\usepackage{markdown} +\markdownSetup{ + renderers = { + ellipsis = {. . .} }} +\begin{document} + +\begin{markdown} +These are just three regular dots ... +\end{markdown} + +\begin{markdown*}{smartEllipses} +... and this is a victorian ellipsis. +\end{markdown*} + +\end{document} +``````` +Next, invoke LuaTeX from the terminal: +``` sh +lualatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> These are just three regular dots ... > > . . . and this is a victorian ellipsis. -###### ConTeXt example {.unnumbered} +##### \Hologo{ConTeXt} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -4342,7 +4724,7 @@ following text: > > . . . and this is a victorian ellipsis. -% +% %<*lua,lua-cli> % \fi % \begin{macrocode} @@ -4351,9 +4733,9 @@ defaultOptions.smartEllipses = false % \par % \iffalse % -%<*manual> +%<*manual-options> -##### Option `startNumber` +#### Option `startNumber` `startNumber` (default value: `true`) @@ -4366,24 +4748,17 @@ defaultOptions.smartEllipses = false : Make the number in the first item of an ordered lists significant. The item numbers will be passed to the -% \m{markdownRendererOlItemWithNumber} \TeX{} macro. -% \iffalse - `\markdownRendererOlItemWithNumber` TeX macro. -% \fi + \m{markdownRendererOlItemWithNumber} \TeX{} macro. : false : Ignore the numbers in the ordered list items. Each item will only - produce a -% \m{markdownRendererOlItem} \TeX{} macro. -% \iffalse - `\markdownRendererOlItem` TeX macro. -% \fi + produce a \m{markdownRendererOlItem} \TeX{} macro. % \end{markdown} % \iffalse -###### LaTeX example {.unnumbered} +##### \LaTeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -4430,7 +4805,7 @@ following text: > 2. fourth item > 3. fifth item -###### ConTeXt example {.unnumbered} +##### \Hologo{ConTeXt} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -4475,7 +4850,7 @@ following text: > 2. fourth item > 3. fifth item -% +% %<*lua,lua-cli> % \fi % \begin{macrocode} @@ -4484,9 +4859,9 @@ defaultOptions.startNumber = true % \par % \iffalse % -%<*manual> +%<*manual-options> -##### Option `tightLists` +#### Option `tightLists` `tightLists` (default value: `true`) @@ -4499,16 +4874,10 @@ defaultOptions.startNumber = true : Lists whose bullets do not consist of multiple paragraphs will be passed to the -% \m{markdownRendererOlBeginTight}, \m{markdownRendererOlEndTight}, -% \m{markdownRendererUlBeginTight}, \m{markdownRendererUlEndTight}, -% \m{markdownRendererDlBeginTight}, and -% \m{markdownRendererDlEndTight} \TeX{} macros. -% \iffalse - `\markdownRendererOlBeginTight`, `\markdownRendererOlEndTight`, - `\markdownRendererUlBeginTight`, `\markdownRendererUlEndTight`, - `\markdownRendererDlBeginTight`, and - `\markdownRendererDlEndTight` TeX macros. -% \fi + \m{markdownRendererOlBeginTight}, \m{markdownRendererOlEndTight}, + \m{markdownRendererUlBeginTight}, \m{markdownRendererUlEndTight}, + \m{markdownRendererDlBeginTight}, and + \m{markdownRendererDlEndTight} \TeX{} macros. : false @@ -4518,7 +4887,7 @@ defaultOptions.startNumber = true % \end{markdown} % \iffalse -###### LaTeX example {.unnumbered} +##### \LaTeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -4582,7 +4951,7 @@ following text: > > - third item -% +% %<*lua,lua-cli> % \fi % \begin{macrocode} @@ -4591,9 +4960,9 @@ defaultOptions.tightLists = true % \par % \iffalse % -%<*manual> +%<*manual-options> -##### Option `underscores` +#### Option `underscores` `underscores` (default value: `true`) @@ -4623,7 +4992,7 @@ defaultOptions.tightLists = true % \end{markdown} % \iffalse -###### Plain TeX example {.unnumbered} +##### Plain \TeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -4653,7 +5022,7 @@ following text: > > This is _emphasized text_ and this is a math subscript: *mₙ*. -###### LaTeX example {.unnumbered} +##### \LaTeX{} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -4683,7 +5052,7 @@ following text: > > This is _emphasized text_ and this is a math subscript: *mₙ*. -###### ConTeXt example {.unnumbered} +##### \Hologo{ConTeXt} Example {.unnumbered} Using a text editor, create a text document named `document.tex` with the following content: @@ -4714,7 +5083,7 @@ following text: > > This is _emphasized text_ and this is a math subscript: *mₙ*. -% +% %<*lua,lua-cli> % \fi % \begin{macrocode} @@ -4876,7 +5245,7 @@ end % ``````` % % This shows another advantage of using the command-line interface compared to -% using a higher-level \TeX{} interface -- it is unnecessary to provide shell +% using a higher-level \TeX{} interface: it is unnecessary to provide shell % access for the \TeX{} engine. % % \end{markdown} @@ -4893,35 +5262,66 @@ end % % \iffalse % -%<*manual> +%<*manual-interfaces> -Plain TeX ---------- +### Plain \TeX{} -The plain TeX macro package provides TeX commands for typesetting markdown -documents that invoke the Lua parser in the background. Beside TeX commands -that correspond to the Lua options, the macro package also provides commands -corresponding to additional plain TeX-specific options, and so-called *token -renderer* commands that define how the individual markdown elements will be -typeset. +The plain \TeX{} interface provides \TeX{} commands that typeset markdown +documents by using the Lua interface behind the scenes. Unlike the Lua +interface, the plain TeX interface does not provide low-level tools for +converting markdown to \TeX{}. Instead, its goal is to provide high-level +typesetting capabilities. -### Interfaces +The plain \TeX{} interface accepts the same options as the `markdown` Lua +module, in addition to its own options, but now the options are specified as +\TeX{} commands. + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\input markdown +\input lmfonts - +\markdownBegin +$\sqrt{-1}$ *equals* $i$. +\markdownEnd -% +\def\markdownOptionHybrid{true} +\markdownBegin +$\sqrt{-1}$ *equals* $i$. +\markdownEnd + +\bye +``````` +Next, invoke LuaTeX from the terminal: +``` sh +luatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> \$\\sqrt{-1}\$ *equals* \$i\$. +> +> √-̅1̅ *equals* $i$. + +Invoking pdfTeX should have the same effect: +``` sh +pdftex --shell-escape document.tex +`````` + +% %<*tex> % \fi % % The plain \TeX{} interface provides macros for the typesetting of markdown % input from within plain \TeX{}, for setting the Lua interface options (see % Section \ref{sec:luaoptions}) used during the conversion from markdown to -% plain \TeX{}, and for changing the way markdown the tokens are rendered. +% plain \TeX{} and for changing the way markdown the tokens are rendered. % % \end{markdown} % \begin{macrocode} -\def\markdownLastModified{2018/04/08}% -\def\markdownVersion{2.5.6}% +\def\markdownLastModified{2019/04/04}% +\def\markdownVersion{2.7.0}% % \end{macrocode} % \par % \begin{markdown} @@ -5021,24 +5421,35 @@ typeset. %### Options % \label{sec:texoptions} % +% The plain \TeX{} options are represented by \TeX{} commands. Some of them map +% directly to the options recognized by the Lua interface (see +% Section~\ref{sec:luaoptions}), while some of them are specific to the plain +% \TeX{} interface. +% +% \end{markdown} % \iffalse % -%<*manual> +%<*manual-options> -### Options +### Plain \TeX{} - +Plain \TeX{} options control the communication between the \TeX{} interface and +the `markdown` Lua module. They are supported by all higher-level interfaces of +the Markdown package, i.e. the plain \TeX{}, \LaTeX{} and \Hologo{ConTeXt} +interfaces. -% +% \fi +% \begin{markdown} + +#### File and Directory Names + +% \end{markdown} +% \iffalse +% %<*tex> % \fi +% \begin{markdown} % -% The plain \TeX{} options are represented by \TeX{} macros. Some of them map -% directly to the options recognized by the Lua interface (see -% Section~\ref{sec:luaoptions}), while some of them are specific to the plain -% \TeX{} interface. -% -%#### File and Directory names % The \mdef{markdownOptionHelperScriptFileName} macro sets the filename of the % helper Lua script file that is created during the conversion from markdown to % plain \TeX{} in \TeX{} engines without the \m{directlua} primitive. It @@ -5096,35 +5507,97 @@ typeset. % \par % \begin{markdown} % -% The \mdef{markdownOptionCacheDir} macro corresponds to the Lua interface -% \Opt{cacheDir} option that sets the path to the directory that will contain -% the produced cache files. The option defaults to `_markdown_`\m{jobname}, -% which is a similar naming scheme to the one used by the \pkg{minted} \LaTeX{} -% package. The same limitations apply here as in the case of the +% The \mdef{markdownOptionOutputDir} macro sets the path to the directory that +% will contain the cache files produced by the Lua implementation and also the +% auxiliary files produced by the plain \TeX{} implementation. The option +% defaults to `.`. +% +% The path must be set to the same value as the `-output-directory` option of +% your \TeX{} engine for the package to function correctly. We need this macro +% to make the Lua implementation aware where it should store the helper files. +% The same limitations apply here as in the case of the % \m{markdownOptionHelperScriptFileName} macro. % % \end{markdown} % \begin{macrocode} -\def\markdownOptionCacheDir{\markdownOptionOutputDir/_markdown_\jobname}% +\def\markdownOptionOutputDir{.}% % \end{macrocode} % \par % \begin{markdown} % -% The \mdef{markdownOptionOutputDir} macro sets the path to the directory that -% will contain the cache files produced by the Lua implementation and also the -% auxiliary files produced by the plain TeX implementation. The option defaults -% to `.`. -% -% The path must be set to the same value as the `-output-directory` option of -% your TeX engine for the package to function correctly. We need this macro to -% make the Lua implementation aware where it should store the helper files. -% The same limitations apply here as in the case of the +% The \mdef{markdownOptionCacheDir} macro corresponds to the Lua interface +% \Opt{cacheDir} option that sets the path to the directory that will contain +% the produced cache files. The option defaults to `_markdown_`\m{jobname}, +% which is a similar naming scheme to the one used by the \pkg{minted} \LaTeX{} +% package. The same limitations apply here as in the case of the % \m{markdownOptionHelperScriptFileName} macro. % % \end{markdown} % \begin{macrocode} -\def\markdownOptionOutputDir{.}% +\def\markdownOptionCacheDir{\markdownOptionOutputDir/_markdown_\jobname}% % \end{macrocode} +% +% \iffalse +% +%<*manual-options> + +The plain \TeX{} interface provides the following commands that you can use to +specify the location of temporary files produced during the conversion from +Markdown to \TeX{}: + +- `\markdownOptionHelperScriptFileName`, +- `\markdownOptionInputTempFileName`, +- `\markdownOptionOutputTempFileName`, +- `\markdownOptionErrorTempFileName`, +- `\markdownOptionOutputDir`, and +- `\markdownOptionCacheDir`. + +Using a text editor, create a folder named `output-directory` and a text +document named `document.tex` with the following content: +``` tex +\input lmfonts +\input markdown +\def\markdownOptionHelperScriptFileName{helper-script.lua} +\def\markdownOptionInputTempFileName{temporary-input.md} +\def\markdownOptionOutputTempFileName{temporary-output.tex} +\def\markdownOptionErrorTempFileName{error-output.txt} +\def\markdownOptionOutputDir{output-directory} +\def\markdownOptionCacheDir{output-directory/cache-directory} +\markdownBegin +Hello *world*! +\markdownEnd +\bye +``````` +Next, invoke LuaTeX from the terminal: +``` sh +luatex --output-directory output-directory document.tex +`````` +A text document named `temporary-input.md` should be produced in the folder +named `output-directory` and contain the following text: + +> Hello \*world\*! + +A folder named `output-directory/cache-directory` should also be produced and +contain fragments of the converted markdown document. LuaTeX does not need +other temporary files to perform the conversion from markdown to \TeX{}. To +produce the remaining temporary files, invoke pdfTeX from the terminal: +``` sh +pdftex --output-directory output-directory --shell-escape document.tex +`````` +Text documents named `helper-script.lua`, and `temporary-output.md` should be +produced in the folder named `output-directory`. The document named +`helper-script.lua` will contain Lua code that was executed to convert markdown +to plain \TeX{}. The document named `temporary-output.tex` will contain the +input markdown document converted to \TeX{}. + +No document named `error-output.txt` should be produced in the folder named +`output-directory`. This document would only be produced if an error had occured +while executing the Lua code. If this happens, please [file a +bug](https://github.com/witiko/markdown/issues). + +% +%<*tex> +% \fi % \par % \begin{markdown} % @@ -5152,24 +5625,68 @@ typeset. \let\markdownOptionFootnotes\undefined \let\markdownOptionFencedCode\undefined \let\markdownOptionHashEnumerators\undefined +\let\markdownOptionHeaderAttributes\undefined \let\markdownOptionHtml\undefined \let\markdownOptionHybrid\undefined \let\markdownOptionInlineFootnotes\undefined \let\markdownOptionPreserveTabs\undefined +\let\markdownOptionSlice\undefined \let\markdownOptionSmartEllipses\undefined \let\markdownOptionStartNumber\undefined \let\markdownOptionTightLists\undefined % \end{macrocode} % \par +% \iffalse +% +%<*manual-options> + +#### Package Documentation + +The \mdef{markdownOptionStripPercentSigns} macro controls whether a percent +sign (`%`) at the beginning of a line will be discarded when reading Markdown +input from a \TeX{} document. This enables the use of markdown when writing +\TeX{} package documentation using the [Doc \LaTeX{} package][doc] by Frank +Mittelbach. + + [doc]: https://ctan.org/pkg/doc (doc – Format LaTeX documentation) + +Using a text editor, create a text document named `document.dtx` with the +following content: + + ``` tex + % \iffalse + \documentclass{ltxdoc} + \usepackage[stripPercentSigns]{markdown} + \begin{document} + \DocInput{document.dtx} + \end{document} + % \fi + % + % \begin{markdown} + % Hello *world*! + % \end{markdown} + ``````` + +Next, invoke LuaTeX from the terminal: +``` sh +lualatex document.dtx +`````` +A PDF document named `document.pdf` should be produced and contain the text +“Hello *world*!” + +% +%<*tex> +% \fi % \begin{markdown} % -%#### Miscellaneous options +%#### Miscellaneous Options +% % The \mdef{markdownOptionStripPercentSigns} macro controls whether a percent % sign (`%`) at the beginning of a line will be discarded when buffering % Markdown input (see Section~\ref{sec:buffering}) or not. Notably, this % enables the use of markdown when writing \TeX{} package documentation using % the \pkg{Doc} \LaTeX{}~package~[@mittelbach17] or similar. The recognized -% values of the macro are `true` (discard), and `false` (retain). +% values of the macro are `true` (discard) and `false` (retain). % % \end{markdown} % \begin{macrocode} @@ -5196,22 +5713,32 @@ typeset. \csname markdownOption#1\endcsname\relax\relax\relax\relax\relax} % \end{macrocode} % \par -% \begin{markdown} -% -%### Token Renderers -% \label{sec:texrenderersuser} % % \iffalse % -%<*manual> +%<*manual-tokens> -### Token renderers +## Markdown Tokens - +A key feature of the Markdown package is the support for manipulating markdown +tokens, such as headings, emphasized text, links, and lists, in \TeX{}. Instead +of reducing \TeX{} to a PDF document producer, the Markdown package allows the +user to specify how every markdown token should be processed and rendered. + +% \fi +% \begin{markdown} + +### Token Renderers + +% \label{sec:texrenderersuser} +% \end{markdown} +% \iffalse + +Token renderers are user-defined \TeX{} macros, which render markdown tokens. +In this section, I will describe the individual token renderers. -% -%<*tex> % \fi +% \begin{markdown} % % The following \TeX{} macros may occur inside the output of the % converter functions exposed by the Lua interface (see Section @@ -5219,62 +5746,550 @@ typeset. % macros are intended to be redefined by the user who is typesetting a % document. By default, they point to the corresponding prototypes (see Section % \ref{sec:texrendererprototypes}). + +#### Interblock Separator Renderer +The \mdef{markdownRendererInterblockSeparator} macro represents a separator +between two markdown block elements. The macro receives no arguments. + +% \end{markdown} % -%#### Interblock Separator Renderer -% The \mdef{markdownRendererInterblockSeparator} macro represents a separator -% between two markdown block elements. The macro receives no arguments. +% \iffalse + +##### Plain \TeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\input markdown +\def\markdownRendererInterblockSeparator{% + \par + {\it(The end of a block)}% + \par +} +\markdownBegin +Hello *world*! + +_Foo_ bar! +\markdownEnd +\bye +``````` +Next, invoke LuaTeX from the terminal: +``` sh +luatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> Hello *world*! +> +> *(The end of a block)* +> +> _Foo_ bar! + +##### \LaTeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\documentclass{article} +\usepackage{markdown} +\markdownSetup{ + renderers = { + interblockSeparator = {% + \par + \emph{(The end of a block)}% + \par + }, + }, +} +\begin{document} +\begin{markdown} +Hello *world*! + +_Foo_ bar! +\end{markdown} +\end{document} +``````` +Next, invoke LuaTeX from the terminal: +``` sh +lualatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> Hello *world*! +> +> *(The end of a block)* +> +> _Foo_ bar! + +##### \Hologo{ConTeXt} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\usemodule[t][markdown] +\def\markdownRendererInterblockSeparator{% + \par + \emph{(The end of a block)}% + \par +} +\starttext +\startmarkdown +Hello *world*! + +_Foo_ bar! +\stopmarkdown +\stoptext +``````` +Next, invoke LuaTeX from the terminal: +``` sh +context document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> Hello *world*! +> +> *(The end of a block)* +> +> _Foo_ bar! + +% +%<*tex> +% \fi % -% \end{markdown} % \begin{macrocode} \def\markdownRendererInterblockSeparator{% \markdownRendererInterblockSeparatorPrototype}% % \end{macrocode} % \par -% \begin{markdown} % -%#### Line Break Renderer -% The \mdef{markdownRendererLineBreak} macro represents a forced line break. -% The macro receives no arguments. +% \iffalse +% +%<*manual-tokens> +% \fi % +% \begin{markdown} + +#### Line Break Renderer +The \mdef{markdownRendererLineBreak} macro represents a forced line break. +The macro receives no arguments. + % \end{markdown} +% +% \iffalse + +##### Plain \TeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\input markdown +\def\markdownRendererLineBreak{% + \par + {\it(A forced linebreak)}% + \par +} +\markdownInput{example.md} +\bye +``````` +Using a text editor, create a text document named `example.md` with the +following content. Note the two spaces at the end of the first line, which +specify a hard linebreak. Due to the limitations of the \TeX{} input +processor, hard linebreaks would be ignored if we typed them directly into the +`document.tex` document. + +
    Hello world!  
    _Foo_ bar!
    + +Next, invoke LuaTeX from the terminal: +``` sh +luatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> Hello *world*! +> +> *(A forced linebreak)* +> +> _Foo_ bar! + +##### \LaTeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\documentclass{article} +\usepackage{markdown} +\markdownSetup{ + renderers = { + lineBreak = {% + \par + \emph{(A forced linebreak)}% + \par + }, + }, +} +\begin{document} +\markdownInput{example.md} +\end{document} +``````` +Using a text editor, create a text document named `example.md` with the +following content. Note the two spaces at the end of the first line, which +specify a hard linebreak. Due to the limitations of the \TeX{} input +processor, hard linebreaks would be ignored if we typed them directly into the +`document.tex` document. + +
    Hello world!  
    _Foo_ bar!
    + +Next, invoke LuaTeX from the terminal: +``` sh +lualatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> Hello *world*! +> +> *(A forced linebreak)* +> +> _Foo_ bar! + +##### \Hologo{ConTeXt} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\usemodule[t][markdown] +\def\markdownRendererLineBreak{% + \par + \emph{(A forced linebreak)}% + \par +} +\starttext +\markdownInput{example.md} +\stoptext +``````` +Using a text editor, create a text document named `example.md` with the +following content. Note the two spaces at the end of the first line, which +specify a hard linebreak. Due to the limitations of the \TeX{} input +processor, hard linebreaks would be ignored if we typed them directly into the +`document.tex` document. + +
    Hello world!  
    _Foo_ bar!
    + +Next, invoke LuaTeX from the terminal: +``` sh +luatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> Hello *world*! +> +> *(A forced linebreak)* +> +> _Foo_ bar! + +% +%<*tex> +% \fi +% % \begin{macrocode} \def\markdownRendererLineBreak{% \markdownRendererLineBreakPrototype}% % \end{macrocode} % \par -% \begin{markdown} % -%#### Ellipsis Renderer -% The \mdef{markdownRendererEllipsis} macro replaces any occurance of ASCII -% ellipses in the input text. This macro will only be produced, when the -% \Opt{smartEllipses} option is `true`. The macro receives no arguments. +% \iffalse +% +%<*manual-tokens> +% \fi % -% \end{markdown} -% \begin{macrocode} -\def\markdownRendererEllipsis{% - \markdownRendererEllipsisPrototype}% -% \end{macrocode} -% \par % \begin{markdown} -% -%#### Non-breaking Space Renderer -% The \mdef{markdownRendererNbsp} macro represents a non-breaking space. -% + +#### Ellipsis Renderer + The \mdef{markdownRendererEllipsis} macro replaces any occurance of ASCII + ellipses in the input text. This macro will only be produced, when the + \Opt{smartEllipses} option is `true`. The macro receives no arguments. + % \end{markdown} -% \begin{macrocode} -\def\markdownRendererNbsp{% - \markdownRendererNbspPrototype}% -% \end{macrocode} -% \par -% \begin{markdown} % -%#### Special Character Renderers -% The following macros replace any special plain \TeX{} characters (including -% the active pipe character (`|`) of \Hologo{ConTeXt}) in the input text. -% These macros will only be produced, when the \Opt{hybrid} option is -% `false`. +% \iffalse + +##### Plain \TeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\input markdown +\def\markdownOptionSmartEllipses{true} +\def\markdownRendererEllipsis{{\it SHAZAM}!} +\markdownBegin +The secret word is ... +\markdownEnd +\bye +``````` +Next, invoke LuaTeX from the terminal: +``` sh +luatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> The secret word is *SHAZAM*! + +##### \LaTeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\documentclass{article} +\usepackage[smartEllipses]{markdown} +\markdownSetup{ + renderers = { + ellipsis = \emph{SHAZAM}!, + }, +} +\begin{document} +\begin{markdown} +The secret word is ... +\end{markdown} +\end{document} +``````` +Next, invoke LuaTeX from the terminal: +``` sh +lualatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> The secret word is *SHAZAM*! + +##### \Hologo{ConTeXt} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\usemodule[t][markdown] +\def\markdownOptionSmartEllipses{true} +\def\markdownRendererEllipsis{\emph{SHAZAM}!} +\starttext +\startmarkdown +The secret word is ... +\stopmarkdown +\stoptext +``````` +Next, invoke LuaTeX from the terminal: +``` sh +context document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> Hello *world*! +> +> *(The end of a block)* +> +> _Foo_ bar! + +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererEllipsis{% + \markdownRendererEllipsisPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +#### Non-Breaking Space Renderer +The \mdef{markdownRendererNbsp} macro represents a non-breaking space. + +% \end{markdown} +% +% \iffalse + +##### \LaTeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.bib` with the +following content: +``` bib +@book{knuth:tex, + author = "Knuth, Donald Ervin", + title = "The \TeX book, volume A of Computers and typesetting", + publisher = "Addison-Wesley", + year = "1984" +} +``````` +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\documentclass{article} +\usepackage[ + citations, + citationNbsps, +]{markdown} +\markdownSetup{ + renderers = { + nbsp = {$\cdot$}, + }, +} +\begin{document} + +\begin{markdown} +The TeXbook [@knuth:tex, p. 123 and 130] is good. +\end{markdown} + +\bibliographystyle{plain} +\bibliography{document.bib} + +\end{document} +``````` +Next, invoke LuaTeX and BibTeX from the terminal: +``` sh +lualatex document.tex +bibtex document.aux +lualatex document.tex +lualatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> The TeXbook [1, p.·123·and·130] is good. +> +> ### References +> [1] Donald Ervin Knuth. _The TeXbook, volume A of Computers and typesetting._ +> Addison-Wesley, 1984. + +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererNbsp{% + \markdownRendererNbspPrototype}% +% \end{macrocode} +% \par % +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +#### Special Character Renderers +The following macros replace any special plain \TeX{} characters, including +% \iffalse +the active pipe character (`|`) of \Hologo{ConTeXt}, in the input text: + +- \mdef{markdownRendererAmpersand} replaces the ampersand (`&`). +- \mdef{markdownRendererBackslash} replaces the backslash (`\`). +- \mdef{markdownRendererCircumflex} replaces the circumflex (`^`). +- \mdef{markdownRendererDollarSign} replaces the dollar sign (`$`). +- \mdef{markdownRendererHash} replaces the hash sign (`#`). +- \mdef{markdownRendererLeftBrace} replaces the left brace (`{`). +- \mdef{markdownRendererPercentSign} replaces the percent sign (`%`). +- \mdef{markdownRendererPipe} replaces the pipe character (`|`). +- \mdef{markdownRendererRightBrace} replaces the right brace (`}`). +- \mdef{markdownRendererTilde} replaces the tilde (`~`). +- \mdef{markdownRendererUnderscore} replaces the underscore (`_`). + +% \fi +% the active pipe character (`|`) of \Hologo{ConTeXt}, in the input text. +% These macros will only be produced, when the \Opt{hybrid} option is +% `false`. + % \end{markdown} +% +% \iffalse + +##### Plain \TeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content. We will make the tilde behave as if it were written in +\TeX{}, where it represents a non-breaking space. +``` tex +\input markdown +\def\markdownRendererTilde{~} +\markdownBegin +Bartel~Leendert van~der~Waerden +\markdownEnd +\bye +``````` +Next, invoke LuaTeX from the terminal: +``` sh +luatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text, where the middot (`·`) denotes a non-breakable space: + +> Bartel·Leendert van·der·Waerden + +##### \LaTeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content. We will make the tilde behave as if it were written in +\TeX{}, where it represents a non-breaking space. +``` tex +\documentclass{article} +\usepackage{markdown} +\markdownSetup{ + renderers = { + tilde = ~, + }, +} +\begin{document} +\begin{markdown} +Bartel~Leendert van~der~Waerden +\end{markdown} +\end{document} +``````` +Next, invoke LuaTeX from the terminal: +``` sh +lualatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text, where the middot (`·`) denotes a non-breakable space: + +> Bartel·Leendert van·der·Waerden + +##### \Hologo{ConTeXt} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content. We will make the tilde behave as if it were written in +\TeX{}, where it represents a non-breaking space. +``` tex +\usemodule[t][markdown] +\def\markdownRendererTilde{~} +\starttext +\startmarkdown +Bartel~Leendert van~der~Waerden +\stopmarkdown +\stoptext +``````` +Next, invoke LuaTeX from the terminal: +``` sh +context document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text, where the middot (`·`) denotes a non-breakable space: + +> Bartel·Leendert van·der·Waerden + +% +%<*tex> +% \fi +% % \begin{macrocode} \def\markdownRendererLeftBrace{% \markdownRendererLeftBracePrototype}% @@ -5300,570 +6315,3078 @@ typeset. \markdownRendererPipePrototype}% % \end{macrocode} % \par -% \begin{markdown} % -%#### Code Span Renderer -% The \mdef{markdownRendererCodeSpan} macro represents inlined code span in the -% input text. It receives a single argument that corresponds to the inlined -% code span. +% \iffalse +% +%<*manual-tokens> +% \fi % -% \end{markdown} -% \begin{macrocode} -\def\markdownRendererCodeSpan{% - \markdownRendererCodeSpanPrototype}% -% \end{macrocode} -% \par % \begin{markdown} -% -%#### Link Renderer -% The \mdef{markdownRendererLink} macro represents a hyperlink. It receives -% four arguments: the label, the fully escaped \acro{uri} that can be directly -% typeset, the raw \acro{uri} that can be used outside typesetting, and the -% title of the link. -% + +#### Code Span Renderer +The \mdef{markdownRendererCodeSpan} macro represents inlined code span in the +input text. It receives a single argument that corresponds to the inlined +code span. + % \end{markdown} -% \begin{macrocode} -\def\markdownRendererLink{% - \markdownRendererLinkPrototype}% -% \end{macrocode} -% \par -% \begin{markdown} % -%#### Image Renderer -% The \mdef{markdownRendererImage} macro represents an image. It receives -% four arguments: the label, the fully escaped \acro{uri} that can be directly -% typeset, the raw \acro{uri} that can be used outside typesetting, and the -% title of the link. +% \iffalse + +##### Plain \TeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\input markdown +\input lmfonts + +\def\markdownRendererCodeSpan#1{#1} + +\markdownBegin +`$\sqrt{-1}$ *equals* $i$` + +$\sqrt{-1}$ *equals* $i$ +\markdownEnd + +\def\markdownOptionHybrid{true} +\markdownBegin +$\sqrt{-1}$ *equals* $i$ +\markdownEnd + +\bye +``````` +Next, invoke LuaTeX from the terminal: +``` sh +luatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> \$\\sqrt{-1}\$ \*equals\* \$i\$. +> +> \$\\sqrt{-1}\$ *equals* \$i\$. +> +> √-̅1̅ *equals* $i$. + +##### \LaTeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\documentclass{article} +\usepackage[smartEllipses]{markdown} +\markdownSetup{ + renderers = { + codeSpan = {#1}, + }, +} +\begin{document} + +\begin{markdown} +`$\sqrt{-1}$ *equals* $i$` + +$\sqrt{-1}$ *equals* $i$ +\end{markdown} + +\begin{markdown*}{hybrid} +$\sqrt{-1}$ *equals* $i$ +\end{markdown*} + +\end{document} +``````` +Next, invoke LuaTeX from the terminal: +``` sh +lualatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> \$\\sqrt{-1}\$ \*equals\* \$i\$. +> +> \$\\sqrt{-1}\$ *equals* \$i\$. +> +> √-̅1̅ *equals* $i$. + +##### \Hologo{ConTeXt} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\usemodule[t][markdown] +\def\markdownRendererCodeSpan#1{#1} +\starttext + +\startmarkdown +`$\sqrt{-1}$ *equals* $i$` + +$\sqrt{-1}$ *equals* $i$ +\stopmarkdown + +\def\markdownOptionHybrid{true} +\startmarkdown +$\sqrt{-1}$ *equals* $i$ +\stopmarkdown + +\bye +``````` +Next, invoke LuaTeX from the terminal: +``` sh +context document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> \$\\sqrt{-1}\$ \*equals\* \$i\$. +> +> \$\\sqrt{-1}\$ *equals* \$i\$. +> +> √-̅1̅ *equals* $i$. + +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererCodeSpan{% + \markdownRendererCodeSpanPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +#### Link Renderer +The \mdef{markdownRendererLink} macro represents a hyperlink. It receives +four arguments: the label, the fully escaped \acro{uri} that can be directly +typeset, the raw \acro{uri} that can be used outside typesetting, and the +title of the link. + +% \end{markdown} +% +% \iffalse + +##### Plain \TeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\input markdown +\def\markdownRendererLink#1#2#3#4{% + #1 {\tt#2} titled {\it#4}% +} +\markdownBegin +Please visit [the link][ctan]. + + [ctan]: https://ctan.org/ + (the Comprehensive TeX Archive Network) +\markdownEnd +\bye +``````` +Next, invoke LuaTeX from the terminal: +``` sh +luatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> Please visit the link titled *the Comprehensive TeX +> Archive Network*. + +##### \LaTeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\documentclass{article} +\usepackage{markdown} +\markdownSetup{ + renderers = { + link = {% + #1 \texttt{#2} titled \emph{#4}% + }, + }, +} +\begin{document} +\begin{markdown} +Please visit [the link][ctan]. + + [ctan]: https://ctan.org/ + (the Comprehensive TeX Archive Network) +\end{markdown} +\end{document} +``````` +Next, invoke LuaTeX from the terminal: +``` sh +lualatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> Please visit the link titled *the Comprehensive TeX +> Archive Network*. + +##### \Hologo{ConTeXt} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\usemodule[t][markdown] +\def\markdownRendererLink#1#2#3#4{% + #1 {\tt#2} titled \emph{#4}% +} +\starttext +\startmarkdown +Please visit [the link][ctan]. + + [ctan]: https://ctan.org/ + (the Comprehensive TeX Archive Network) +\stopmarkdown +\stoptext +``````` +Next, invoke LuaTeX from the terminal: +``` sh +context document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> Please visit the link titled *the Comprehensive TeX +> Archive Network*. + +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererLink{% + \markdownRendererLinkPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +#### Image Renderer +The \mdef{markdownRendererImage} macro represents an image. It receives +four arguments: the label, the fully escaped \acro{uri} that can be directly +typeset, the raw \acro{uri} that can be used outside typesetting, and the +title of the link. + +% \end{markdown} +% +% \iffalse + +##### \LaTeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\documentclass{article} +\usepackage{markdown} +\begingroup +\catcode`\@=11 +\catcode`\%=12 +\catcode`\^^A=14 +\global\def\markdownRendererImage#1#2#3#4{^^A + \immediate\write18{^^A + if printf '%s' "#3" | grep -q ^http; then + OUTPUT="$(printf '%s' "#3" | md5sum | cut -d' ' -f1).^^A + $(printf '%s' "#3" | sed 's/.*[.]//')"; + if ! [ -e "$OUTPUT" ]; then + wget -O "$OUTPUT" '#3' || rm "$OUTPUT"; + convert "$OUTPUT" png:"$OUTPUT"; + fi; + printf '%s%%' "$OUTPUT" > \jobname.fetched; + else + printf '%s%%' "#3" > \jobname.fetched; + fi^^A + }^^A + {^^A + \everyeof={\noexpand}^^A + \edef\filename{\@@input"\jobname.fetched" }^^A + \includegraphics[width=\textwidth]{\filename}^^A + }^^A +} +\endgroup +\begin{document} +\begin{markdown} +![TUGboat](https://tug.org/tugboat/noword.jpg) +\end{markdown} +\end{document} +`````` +Next, invoke LuaTeX from the terminal: +``` sh +lualatex --shell-escape document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following content. This assumes that you use a Unix-like operating system with +Bourne or Bourne again shell as the default shell of the current user. It also +assumes that the `md5sum`, `wget`, and `convert` binaries are installed and +that the \TeX{} engine has shell access. + +> ![](https://tug.org/tugboat/noword.jpg "The Communications of the TeX Users Group") + +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererImage{% + \markdownRendererImagePrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +#### Content Block Renderers +\label{sec:texcontentblockrenderers} +The \mdef{markdownRendererContentBlock} macro represents an iA\,Writer content +block. It receives four arguments: the local file or online image filename +extension cast to the lower case, the fully escaped \acro{uri} that can be +directly typeset, the raw \acro{uri} that can be used outside typesetting, +and the title of the content block. + +% \end{markdown} +% +% \iffalse +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererContentBlock{% + \markdownRendererContentBlockPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +The \mdef{markdownRendererContentBlockOnlineImage} macro represents an +iA\,Writer online image content block. The macro receives the same arguments +as \m{markdownRendererContentBlock}. + +% \end{markdown} +% +% \iffalse +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererContentBlockOnlineImage{% + \markdownRendererContentBlockOnlineImagePrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +The \mdef{markdownRendererContentBlockCode} macro represents an iA\,Writer +content block that was recognized as a file in a known programming language +by its filename extension $s$. If any `markdown-languages.json` file found +by \pkg{kpathsea}\footnote{Local files take precedence. Filenames other +than `markdown-languages.json` may be specified using the +`contentBlocksLanguageMap` Lua option.} contains a record $(k, v)$, then a +non-online-image content block with the filename extension $s, +s$`:lower()`${}=k$ is considered to be in a known programming language $v$. +The macro receives five arguments: the local file name extension $s$ cast to +the lower case, the language $v$, the fully escaped \acro{uri} that can be +directly typeset, the raw \acro{uri} that can be used outside typesetting, +and the title of the content block. + +Note that you will need to place place a `markdown-languages.json` file +inside your working directory or inside your local \TeX{} directory +structure. In this file, you will define a mapping between filename +extensions and the language names recognized by your favorite syntax +highlighter; there may exist other creative uses beside syntax highlighting. +% The `Languages.json` file provided by @sotkov17 is a good starting point. +% \end{markdown} +% +% \iffalse +[The `Languages.json` file provided by Anton Sotkov][sotkov17] is a good +starting point. + + [sotkov17]: https://github.com/iainc/Markdown-Content-Blocks + (File transclusion syntax for Markdown) + +##### Plain \TeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\input markdown +\def\markdownOptionContentBlocks{true} +\def\markdownRendererContentBlock#1#2#3#4{% + This is {\tt #2}, #4. +} +\def\markdownRendererContentBlockOnlineImage#1#2#3#4{% + This is the image {\tt #2}, #4. +} +\def\markdownRendererContentBlockCode#1#2#3#4#5{% + This is the #2 (\uppercase{#1}) document {\tt #3}, #5. +} +\markdownBegin +/document.tex (the document that we are currently typesetting) +/markdown-languages.json (the mapping between filename extensions + and programming language names) +https://tug.org/tugboat/noword.jpg (the logotype of TUGboat) +\markdownEnd +\bye +``````` +Create also a text document named `markdown-languages.json` with the following +content: +``` js +{ + "json": "JavaScript Object Notation", +} +`````` +Next, invoke LuaTeX from the terminal: +``` sh +luatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> This is `document.tex`, the document that we are currently typesetting. +> +> This is the JavaScript Object Notation (JSON) document +> `markdown-languages.json`, the mapping between filename extensions and +> programming language names. +> +> This is the image `https://tug.org/tugboat/noword.jpg`, the logotype of +> TUGboat. + +##### \LaTeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\documentclass{article} +\usepackage{filecontents} +\begin{filecontents*}{markdown-languages.json} +{ + "json": "JavaScript Object Notation", +} +\end{filecontents*} +\usepackage[contentBlocks]{markdown} +\markdownSetup{ + renderers = { + contentBlock = {This is \texttt{#2}, #4.}, + contentBlockOnlineImage = {This is the image \texttt{#2}, #4.}, + contentBlockCode = {% + This is the #2 (\MakeUppercase{#1}) document \texttt{#3}, #5. + }, + }, +} +\begin{document} +\begin{markdown} +/document.tex (the document that we are currently typesetting) +/markdown-languages.json (the mapping between filename extensions + and programming language names) +https://tug.org/tugboat/noword.jpg (the logotype of TUGboat) +\end{markdown} +\end{document} +``````` +Next, invoke LuaTeX from the terminal: +``` sh +lualatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> This is `document.tex`, the document that we are currently typesetting. +> +> This is the JavaScript Object Notation (JSON) document +> `markdown-languages.json`, the mapping between filename extensions and +> programming language names. +> +> This is the image `https://tug.org/tugboat/noword.jpg`, the logotype of +> TUGboat. + +##### \Hologo{ConTeXt} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\usemodule[t][markdown] +\def\markdownOptionContentBlocks{true} +\def\markdownRendererContentBlock#1#2#3#4{% + This is {\tt #2}, #4. +} +\def\markdownRendererContentBlockOnlineImage#1#2#3#4{% + This is the image {\tt #2}, #4. +} +\def\markdownRendererContentBlockCode#1#2#3#4#5{% + This is the #2 (\uppercase{#1}) document {\tt #3}, #5. +} +\starttext +\startmarkdown +/document.tex (the document that we are currently typesetting) +/markdown-languages.json (the mapping between filename extensions + and programming language names) +https://tug.org/tugboat/noword.jpg (the logotype of TUGboat) +\stopmarkdown +\stoptext +``````` +Create also a text document named `markdown-languages.json` with the following +content: +``` js +{ + "json": "JavaScript Object Notation", +} +`````` +Next, invoke LuaTeX from the terminal: +``` sh +context document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> This is `document.tex`, the document that we are currently typesetting. +> +> This is the JavaScript Object Notation (JSON) document +> `markdown-languages.json`, the mapping between filename extensions and +> programming language names. +> +> This is the image `https://tug.org/tugboat/noword.jpg`, the logotype of +> TUGboat. + +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererContentBlockCode{% + \markdownRendererContentBlockCodePrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +#### Bullet List Renderers +The \mdef{markdownRendererUlBegin} macro represents the beginning of a +bulleted list that contains an item with several paragraphs of text (the +list is not tight). The macro receives no arguments. + +% \end{markdown} +% +% \iffalse +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererUlBegin{% + \markdownRendererUlBeginPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +The \mdef{markdownRendererUlBeginTight} macro represents the beginning of a +bulleted list that contains no item with several paragraphs of text (the list +is tight). This macro will only be produced, when the \Opt{tightLists} option +is `false`. The macro receives no arguments. + +% \end{markdown} +% +% \iffalse +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererUlBeginTight{% + \markdownRendererUlBeginTightPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +The \mdef{markdownRendererUlItem} macro represents an item in a bulleted +list. The macro receives no arguments. + +% \end{markdown} +% +% \iffalse +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererUlItem{% + \markdownRendererUlItemPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +The \mdef{markdownRendererUlItemEnd} macro represents the end of an item in a +bulleted list. The macro receives no arguments. + +% \end{markdown} +% +% \iffalse +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererUlItemEnd{% + \markdownRendererUlItemEndPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +The \mdef{markdownRendererUlEnd} macro represents the end of a bulleted list +that contains an item with several paragraphs of text (the list is not +tight). The macro receives no arguments. + +% \end{markdown} +% +% \iffalse +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererUlEnd{% + \markdownRendererUlEndPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +The \mdef{markdownRendererUlEndTight} macro represents the end of a bulleted +list that contains no item with several paragraphs of text (the list is +tight). This macro will only be produced, when the \Opt{tightLists} option is +`false`. The macro receives no arguments. + +% \end{markdown} +% +% \iffalse + +##### Plain \TeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\input markdown +\def\markdownOptionTightLists{true} + +\def\markdownRendererInterblockSeparator{} +\def\markdownRendererUlBeginTight{ (} +\def\markdownRendererUlItem{% + \def\markdownRendererUlItem{% + , + \def\markdownRendererUlItem{, and }% + }% +} +\def\markdownRendererUlItemEnd{} +\def\markdownRendererUlEndTight{).} + +\markdownBegin +This is a tight list + +- the first item +- the second item +- the third item +\markdownEnd + +\def\markdownRendererInterblockSeparator{% + :\par + \def\markdownRendererInterblockSeparator{\par}% +} +\def\markdownRendererUlBegin{} +\def\markdownRendererUlItem{--\kern 0.5em} +\def\markdownRendererUlItemEnd{.\par} +\def\markdownRendererUlEnd{} + +\markdownBegin +This is a loose list + +- This is the first item + +- This is the second item + +- This is the third item +\markdownEnd + +\bye +``````` +Next, invoke LuaTeX from the terminal: +``` sh +luatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> This is a tight list (the first item, the second item, and the third item). +> +> This is a loose list: +> +> - This is the first item. +> +> - This is the second item. +> +> - This is the third item. + +##### \LaTeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\documentclass{article} +\usepackage[tightLists]{markdown} +\begin{document} + +\begin{markdown*}{ + renderers = { + interblockSeparator = {}, + ulBeginTight = { (}, + ulItem = {% + \def\markdownRendererUlItem{% + , + \def\markdownRendererUlItem{, and }% + }% + }, + ulItemEnd = {}, + ulEndTight = {).}, + }, +} +This is a tight list + +- the first item +- the second item +- the third item +\end{markdown*} + +\begin{markdown*}{ + renderers = { + interblockSeparator = {% + :\par + \def\markdownRendererInterblockSeparator{\par}% + }, + ulBeginTight = {\begin{itemize}}, + ulItem = {\item}, + ulItemEnd = {.}, + ulEnd = {\end{itemize}}, + }, +} +This is a loose list + +- This is the first item + +- This is the second item + +- This is the third item +\end{markdown*} + +\end{document} +``````` +Next, invoke LuaTeX from the terminal: +``` sh +lualatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> This is a tight list (the first item, the second item, and the third item). +> +> This is a loose list: +> +> - This is the first item. +> +> - This is the second item. +> +> - This is the third item. + +##### \Hologo{ConTeXt} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\usemodule[t][markdown] +\def\markdownOptionTightLists{true} +\starttext + +\def\markdownRendererInterblockSeparator{} +\def\markdownRendererUlBeginTight{ (} +\def\markdownRendererUlItem{% + \def\markdownRendererUlItem{% + , + \def\markdownRendererUlItem{, and }% + }% +} +\def\markdownRendererUlItemEnd{} +\def\markdownRendererUlEndTight{).} + +\startmarkdown +This is a tight list + +- the first item +- the second item +- the third item +\stopmarkdown + +\def\markdownRendererInterblockSeparator{% + :\par + \def\markdownRendererInterblockSeparator{\par}% +} +\def\markdownRendererUlBegin{\startitemize} +\def\markdownRendererUlItem{\item} +\def\markdownRendererUlItemEnd{.} +\def\markdownRendererUlEnd{\stopitemize} + +\startmarkdown +This is a loose list + +- This is the first item + +- This is the second item + +- This is the third item +\stopmarkdown + +\stoptext +``````` +Next, invoke LuaTeX from the terminal: +``` sh +context document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> This is a tight list (the first item, the second item, and the third item). +> +> This is a loose list: +> +> - This is the first item. +> +> - This is the second item. +> +> - This is the third item. + +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererUlEndTight{% + \markdownRendererUlEndTightPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +#### Ordered List Renderers +The \mdef{markdownRendererOlBegin} macro represents the beginning of an +ordered list that contains an item with several paragraphs of text (the +list is not tight). The macro receives no arguments. + +% \end{markdown} +% +% \iffalse +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererOlBegin{% + \markdownRendererOlBeginPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +The \mdef{markdownRendererOlBeginTight} macro represents the beginning of an +ordered list that contains no item with several paragraphs of text (the +list is tight). This macro will only be produced, when the \Opt{tightLists} +option is `false`. The macro receives no arguments. + +% \end{markdown} +% +% \iffalse +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererOlBeginTight{% + \markdownRendererOlBeginTightPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +The \mdef{markdownRendererOlItem} macro represents an item in an ordered list. +This macro will only be produced, when the \Opt{startNumber} option is +`false`. The macro receives no arguments. + +% \end{markdown} +% +% \iffalse +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererOlItem{% + \markdownRendererOlItemPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +The \mdef{markdownRendererOlItemEnd} macro represents the end of an item in +an ordered list. The macro receives no arguments. + +% \end{markdown} +% +% \iffalse +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererOlItemEnd{% + \markdownRendererOlItemEndPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +The \mdef{markdownRendererOlItemWithNumber} macro represents an item in an +ordered list. This macro will only be produced, when the \Opt{startNumber} +option is `true`. The macro receives no arguments. + +% \end{markdown} +% +% \iffalse +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererOlItemWithNumber{% + \markdownRendererOlItemWithNumberPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +The \mdef{markdownRendererOlEnd} macro represents the end of an ordered list +that contains an item with several paragraphs of text (the list is not +tight). The macro receives no arguments. + +% \end{markdown} +% +% \iffalse +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererOlEnd{% + \markdownRendererOlEndPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +The \mdef{markdownRendererOlEndTight} macro represents the end of an ordered +list that contains no item with several paragraphs of text (the list is +tight). This macro will only be produced, when the \Opt{tightLists} option is +`false`. The macro receives no arguments. + +% \end{markdown} +% +% \iffalse + +##### Plain \TeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\input markdown +\def\markdownOptionTightLists{true} +\def\markdownOptionStartNumber{true} + +\def\markdownRendererInterblockSeparator{} +\def\markdownRendererOlBeginTight{ (} +\def\markdownRendererOlItemWithNumber#1{% + \ifnum #1=1\relax + the first + \else + \ifnum #1=2\relax + , the second + \else + , and the third + \fi + \fi +} +\def\markdownRendererOlItemEnd{} +\def\markdownRendererOlEndTight{).} + +\markdownBegin +This is a tight list + +1. item +2. item +3. item +\markdownEnd + +\def\markdownRendererInterblockSeparator{% + :\par + \def\markdownRendererInterblockSeparator{\par}% +} +\def\markdownRendererOlBegin{} +\def\markdownRendererOlItemWithNumber#1{% + #1.\kern 0.5em% + This is the + \ifnum #1=1\relax + first + \else + \ifnum #1=2\relax + second + \else + third + \fi + \fi +} +\def\markdownRendererOlItemEnd{.\par} +\def\markdownRendererOlEnd{} + +\markdownBegin +This is a loose list + +1. item + +2. item + +3. item +\markdownEnd + +\bye +``````` +Next, invoke LuaTeX from the terminal: +``` sh +luatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> This is a tight list (the first item, the second item, and the third item). +> +> This is a loose list: +> +> 1. This is the first item. +> +> 2. This is the second item. +> +> 3. This is the third item. + +##### \LaTeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\documentclass{article} +\usepackage[tightLists, startNumber]{markdown} +\begin{document} + +\begin{markdown*}{ + renderers = { + interblockSeparator = {}, + olBeginTight = { (}, + olItemWithNumber = {% + \ifnum #1=1\relax + the first + \else + \ifnum #1=2\relax + , the second + \else + , and the third + \fi + \fi + }, + olItemEnd = {}, + olEndTight = {).}, + }, +} +This is a tight list + +1. item +2. item +3. item +\end{markdown*} + +\begin{markdown*}{ + renderers = { + interblockSeparator = {% + :\par + \def\markdownRendererInterblockSeparator{\par}% + }, + olBeginTight = {\begin{enumerate}}, + olItemWithNumber = {% + \item This is the + \ifnum #1=1\relax + first + \else + \ifnum #1=2\relax + second + \else + third + \fi + \fi + }, + olItemEnd = {.}, + olEnd = {\end{enumerate}}, + }, +} +This is a loose list + +1. item + +2. item + +3. item +\end{markdown*} + +\end{document} +``````` +Next, invoke LuaTeX from the terminal: +``` sh +lualatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> This is a tight list (the first item, the second item, and the third item). +> +> This is a loose list: +> +> 1. This is the first item. +> +> 2. This is the second item. +> +> 3. This is the third item. + +##### \Hologo{ConTeXt} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\usemodule[t][markdown] +\def\markdownOptionTightLists{true} +\def\markdownOptionStartNumber{true} +\starttext + +\def\markdownRendererInterblockSeparator{} +\def\markdownRendererOlBeginTight{ (} +\def\markdownRendererOlItemWithNumber#1{% + \ifnum #1=1\relax + the first + \else + \ifnum #1=2\relax + , the second + \else + , and the third + \fi + \fi +} +\def\markdownRendererOlItemEnd{} +\def\markdownRendererOlEndTight{).} + +\startmarkdown +This is a tight list + +1. item +2. item +3. item +\stopmarkdown + +\def\markdownRendererInterblockSeparator{% + :\par + \def\markdownRendererInterblockSeparator{\par}% +} +\def\markdownRendererOlBegin{\startitemize} +\def\markdownRendererOlItemWithNumber#1{% + \sym{#1.} + This is the + \ifnum #1=1\relax + first + \else + \ifnum #1=2\relax + second + \else + third + \fi + \fi +} +\def\markdownRendererOlItemEnd{.\par} +\def\markdownRendererOlEnd{\stopitemize} + +\startmarkdown +This is a loose list + +1. item + +2. item + +3. item +\stopmarkdown + +\stoptext +``````` +Next, invoke LuaTeX from the terminal: +``` sh +context document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> This is a tight list (the first item, the second item, and the third item). +> +> This is a loose list: +> +> 1. This is the first item. +> +> 2. This is the second item. +> +> 3. This is the third item. + +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererOlEndTight{% + \markdownRendererOlEndTightPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +#### Definition List Renderers +The following macros are only produced, when the \Opt{definitionLists} option +is `true`. + +The \mdef{markdownRendererDlBegin} macro represents the beginning of a +definition list that contains an item with several paragraphs of text (the +list is not tight). The macro receives no arguments. + +% \end{markdown} +% +% \iffalse +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererDlBegin{% + \markdownRendererDlBeginPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +The \mdef{markdownRendererDlBeginTight} macro represents the beginning of a +definition list that contains an item with several paragraphs of text (the +list is not tight). This macro will only be produced, when the +\Opt{tightLists} option is `false`. The macro receives no arguments. + +% \end{markdown} +% +% \iffalse +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererDlBeginTight{% + \markdownRendererDlBeginTightPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +The \mdef{markdownRendererDlItem} macro represents a term in a definition +list. The macro receives a single argument that corresponds to the term +being defined. + +% \end{markdown} +% +% \iffalse +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererDlItem{% + \markdownRendererDlItemPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +The \mdef{markdownRendererDlItemEnd} macro represents the end of a list of +definitions for a single term. + +% \end{markdown} +% +% \iffalse +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererDlItemEnd{% + \markdownRendererDlItemEndPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +The \mdef{markdownRendererDlDefinitionBegin} macro represents the beginning +of a definition in a definition list. There can be several definitions for +a single term. + +% \end{markdown} +% +% \iffalse +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererDlDefinitionBegin{% + \markdownRendererDlDefinitionBeginPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +The \mdef{markdownRendererDlDefinitionEnd} macro represents the end of a +definition in a definition list. There can be several definitions for a +single term. + +% \end{markdown} +% +% \iffalse +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererDlDefinitionEnd{% + \markdownRendererDlDefinitionEndPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +The \mdef{markdownRendererDlEnd} macro represents the end of a definition +list that contains an item with several paragraphs of text (the list is not +tight). The macro receives no arguments. + +% \end{markdown} +% +% \iffalse +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererDlEnd{% + \markdownRendererDlEndPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +The \mdef{markdownRendererDlEndTight} macro represents the end of a +definition list that contains no item with several paragraphs of text (the +list is tight). This macro will only be produced, when the \Opt{tightLists} +option is `false`. The macro receives no arguments. + +% \end{markdown} +% +% \iffalse + +##### Plain \TeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\input markdown +\def\markdownOptionDefinitionLists{true} +\def\markdownOptionTightLists{true} + +\def\markdownRendererInterblockSeparator{% + :% + \def\markdownRendererInterblockSeparator{\par}% +} +\def\markdownRendererDlBeginTight{% + \begingroup + \parindent=0pt +} +\def\markdownRendererDlItem#1{% + \par{\bf#1}% + \def\markdownRendererDlDefinitionEnd{% + , + \def\markdownRendererDlDefinitionEnd{% + , and + \def\markdownRendererDlDefinitionEnd{.}% + }% + }% +} +\def\markdownRendererDlItemEnd{} +\def\markdownRendererDlDefinitionBegin{\par--\kern 0.5em} +\def\markdownRendererDlEndTight{\endgroup} + +\markdownBegin +This is a tight definition list + +Coffee +: black hot drink +: prepared from roasted coffee beans +: one of the most traded agricultural commodities in the world + +Milk +: white cold drink +: nutrient-rich +: produced on an industrial scale +\markdownEnd + +\def\markdownRendererInterblockSeparator{% + \def\markdownRendererInterblockSeparator{\par}% +} +\def\markdownRendererDlBegin{} +\def\markdownRendererDlItem#1{% + . #1 is a + \def\markdownRendererDlDefinitionBegin{% + \def\markdownRendererDlDefinitionBegin{% + , + \def\markdownRendererDlDefinitionBegin{, and }% + }% + }% +} +\def\markdownRendererDlItemEnd{} +\def\markdownRendererDlDefinitionEnd{} +\def\markdownRendererDlEnd{.} + +\markdownBegin +This is a loose definition list + +Coffee + +: black hot drink + +: prepared from roasted coffee beans + +: one of the most traded agricultural commodities in the world + +Milk + +: white cold drink + +: nutrient-rich + +: produced on an industrial scale +\markdownEnd + +\bye +``````` +Next, invoke LuaTeX from the terminal: +``` sh +luatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> This is a tight definition list: +> +> **Coffee** +> +> - black hot drink, +> - prepared from roasted coffee beans, and +> - one of the most traded agricultural commodities in the world. +> +> **Milk** +> +> - white cold drink, +> - nutrient-rich, and +> - produced on an industrial scale. +> +> This is a loose definition list. Coffee is a black hot drink, prepared from +> roasted coffee beans, and one of the most traded agricultural commodities in +> the world. Milk is a white cold drink, nutrient-rich, and produced on an +> industrial scale. + +##### \LaTeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\documentclass{article} +\usepackage[definitionLists, tightLists]{markdown} +\begin{document} + +\begin{markdown*}{ + renderers = { + interblockSeparator = {% + :% + \def\markdownRendererInterblockSeparator{\par}% + }, + dlBeginTight = {\begin{description}}, + dlItem = {% + \item[#1] + \begin{itemize} + \def\markdownRendererDlDefinitionEnd{% + , + \def\markdownRendererDlDefinitionEnd{% + , and + \def\markdownRendererDlDefinitionEnd{.}% + }% + }% + }, + dlItemEnd = {\end{itemize}}, + dlDefinitionBegin = \item, + dlEndTight = {\end{description}}, + }, +} +This is a tight definition list + +Coffee +: black hot drink +: prepared from roasted coffee beans +: one of the most traded agricultural commodities in the world + +Milk +: white cold drink +: nutrient-rich +: produced on an industrial scale +\end{markdown*} + +\begin{markdown*}{ + renderers = { + interblockSeparator = {% + \def\markdownRendererInterblockSeparator{\par}% + }, + dlBegin = {}, + dlItem = {% + . #1 is a + \def\markdownRendererDlDefinitionBegin{% + \def\markdownRendererDlDefinitionBegin{% + , + \def\markdownRendererDlDefinitionBegin{, and }% + }% + }% + }, + dlItemEnd = {}, + dlDefinitionEnd = {}, + dlEnd = {.}, + }, +} +This is a loose definition list + +Coffee + +: black hot drink + +: prepared from roasted coffee beans + +: one of the most traded agricultural commodities in the world + +Milk + +: white cold drink + +: nutrient-rich + +: produced on an industrial scale +\end{markdown*} + +\end{document} +``````` +Next, invoke LuaTeX from the terminal: +``` sh +lualatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> This is a tight definition list: +> +> **Coffee** +> +> - black hot drink, +> - prepared from roasted coffee beans, and +> - one of the most traded agricultural commodities in the world. +> +> **Milk** +> +> - white cold drink, +> - nutrient-rich, and +> - produced on an industrial scale. +> +> This is a loose definition list. Coffee is a black hot drink, prepared from +> roasted coffee beans, and one of the most traded agricultural commodities in +> the world. Milk is a white cold drink, nutrient-rich, and produced on an +> industrial scale. + +##### \Hologo{ConTeXt} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\usemodule[t][markdown] +\def\markdownOptionDefinitionLists{true} +\def\markdownOptionTightLists{true} +\starttext + +\def\markdownRendererInterblockSeparator{% + :% + \def\markdownRendererInterblockSeparator{\par}% +} +\def\markdownRendererDlBeginTight{} +\def\markdownRendererDlItem#1{% + \par{\bf#1}% + \startitemize + \def\markdownRendererDlDefinitionEnd{% + , + \def\markdownRendererDlDefinitionEnd{% + , and + \def\markdownRendererDlDefinitionEnd{.}% + }% + }% +} +\def\markdownRendererDlItemEnd{\stopitemize} +\def\markdownRendererDlDefinitionBegin{\item} +\def\markdownRendererDlEndTight{} + +\startmarkdown +This is a tight definition list + +Coffee +: black hot drink +: prepared from roasted coffee beans +: one of the most traded agricultural commodities in the world + +Milk +: white cold drink +: nutrient-rich +: produced on an industrial scale +\stopmarkdown + +\def\markdownRendererInterblockSeparator{% + \def\markdownRendererInterblockSeparator{\par}% +} +\def\markdownRendererDlBegin{} +\def\markdownRendererDlItem#1{% + . #1 is a + \def\markdownRendererDlDefinitionBegin{% + \def\markdownRendererDlDefinitionBegin{% + , + \def\markdownRendererDlDefinitionBegin{, and }% + }% + }% +} +\def\markdownRendererDlItemEnd{} +\def\markdownRendererDlDefinitionEnd{} +\def\markdownRendererDlEnd{.} + +\startmarkdown +This is a loose definition list + +Coffee + +: black hot drink + +: prepared from roasted coffee beans + +: one of the most traded agricultural commodities in the world + +Milk + +: white cold drink + +: nutrient-rich + +: produced on an industrial scale +\stopmarkdown + +\stoptext +``````` +Next, invoke LuaTeX from the terminal: +``` sh +context document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> This is a tight definition list: +> +> **Coffee** +> +> - black hot drink, +> - prepared from roasted coffee beans, and +> - one of the most traded agricultural commodities in the world. +> +> **Milk** +> +> - white cold drink, +> - nutrient-rich, and +> - produced on an industrial scale. +> +> This is a loose definition list. Coffee is a black hot drink, prepared from +> roasted coffee beans, and one of the most traded agricultural commodities in +> the world. Milk is a white cold drink, nutrient-rich, and produced on an +> industrial scale. + +% +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererDlEndTight{% + \markdownRendererDlEndTightPrototype}% +% \end{macrocode} +% \par +% +% \iffalse +% +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +#### Emphasis Renderers +The \mdef{markdownRendererEmphasis} macro represents an emphasized span of +text. The macro receives a single argument that corresponds to the emphasized +span of text. + +% \end{markdown} +% +% \iffalse + +##### Plain \TeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\input markdown +\def\markdownRendererEmphasis#1{{\it#1}} +\def\markdownRendererStrongEmphasis#1{{\bf#1}} +\markdownBegin +This is *emphasis*. + +This is **strong emphasis**. +\markdownEnd +\bye +``````` +Next, invoke LuaTeX from the terminal: +``` sh +luatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> This is *emphasis*. +> +> This is **strong emphasis**. + +##### \LaTeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\documentclass{article} +\usepackage{markdown} +\markdownSetup{ + renderers = { + emphasis = {\emph{#1}}, + strongEmphasis = {\textbf{#1}}, + }, +} +\begin{document} +\begin{markdown} +This is *emphasis*. + +This is **strong emphasis**. +\end{markdown} +\end{document} +``````` +Next, invoke LuaTeX from the terminal: +``` sh +lualatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> This is *emphasis*. +> +> This is **strong emphasis**. + +##### \Hologo{ConTeXt} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\usemodule[t][markdown] +\def\markdownRendererEmphasis#1{\emph{#1}} +\def\markdownRendererStrongEmphasis#1{\bold{#1}} +\starttext +\startmarkdown +This is *emphasis*. + +This is **strong emphasis**. +\stopmarkdown +\stoptext +``````` +Next, invoke LuaTeX from the terminal: +``` sh +context document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> This is *emphasis*. +> +> This is **strong emphasis**. + +% +%<*tex> +% \fi % -% \end{markdown} % \begin{macrocode} -\def\markdownRendererImage{% - \markdownRendererImagePrototype}% +\def\markdownRendererEmphasis{% + \markdownRendererEmphasisPrototype}% % \end{macrocode} % \par -% \begin{markdown} % -%#### Content Block Renderers -% \label{sec:texcontentblockrenderers} -% The \mdef{markdownRendererContentBlock} macro represents an iA\,Writer content -% block. It receives four arguments: the local file or online image filename -% extension cast to the lower case, the fully escaped \acro{uri} that can be -% directly typeset, the raw \acro{uri} that can be used outside typesetting, -% and the title of the content block. +% \iffalse +% +%<*manual-tokens> +% \fi % -% \end{markdown} -% \begin{macrocode} -\def\markdownRendererContentBlock{% - \markdownRendererContentBlockPrototype}% -% \end{macrocode} -% \par % \begin{markdown} -% -% The \mdef{markdownRendererContentBlockOnlineImage} macro represents an -% iA\,Writer online image content block. The macro receives the same arguments -% as \m{markdownRendererContentBlock}. -% + +The \mdef{markdownRendererStrongEmphasis} macro represents a strongly +emphasized span of text. The macro receives a single argument that +corresponds to the emphasized span of text. + % \end{markdown} -% \begin{macrocode} -\def\markdownRendererContentBlockOnlineImage{% - \markdownRendererContentBlockOnlineImagePrototype}% -% \end{macrocode} -% \par -% \begin{markdown} -% -% The \mdef{markdownRendererContentBlockCode} macro represents an iA\,Writer -% content block that was recognized as a file in a known programming language -% by its filename extension $s$. If any `markdown-languages.json` file found -% by \pkg{kpathsea}\footnote{Local files take precedence. Filenames other -% than `markdown-languages.json` may be specified using the -% `contentBlocksLanguageMap` Lua option.} contains a record $(k, v)$, then a -% non-online-image content block with the filename extension $s, -% s$`:lower()`${}=k$ is considered to be in a known programming language $v$. -% The macro receives five arguments: the local file name extension $s$ cast to -% the lower case, the language $v$, the fully escaped \acro{uri} that can be -% directly typeset, the raw \acro{uri} that can be used outside typesetting, -% and the title of the content block. % -% Note that you will need to place place a `markdown-languages.json` file -% inside your working directory or inside your local TeX directory structure. -% In this file, you will define a mapping between filename extensions and the -% language names recognized by your favorite syntax highlighter; there may -% exist other creative uses beside syntax highlighting. The `Languages.json` -% file provided by @sotkov17 is a good starting point. +% \iffalse +% +%<*tex> +% \fi % -% \end{markdown} % \begin{macrocode} -\def\markdownRendererContentBlockCode{% - \markdownRendererContentBlockCodePrototype}% +\def\markdownRendererStrongEmphasis{% + \markdownRendererStrongEmphasisPrototype}% % \end{macrocode} % \par -% \begin{markdown} % -%#### Bullet List Renderers -% The \mdef{markdownRendererUlBegin} macro represents the beginning of a -% bulleted list that contains an item with several paragraphs of text (the -% list is not tight). The macro receives no arguments. +% \iffalse +% +%<*manual-tokens> +% \fi % -% \end{markdown} -% \begin{macrocode} -\def\markdownRendererUlBegin{% - \markdownRendererUlBeginPrototype}% -% \end{macrocode} -% \par % \begin{markdown} -% -% The \mdef{markdownRendererUlBeginTight} macro represents the beginning of a -% bulleted list that contains no item with several paragraphs of text (the list -% is tight). This macro will only be produced, when the \Opt{tightLists} option -% is `false`. The macro receives no arguments. -% + +#### Block Quote Renderers +The \mdef{markdownRendererBlockQuoteBegin} macro represents the beginning of +a block quote. The macro receives no arguments. + % \end{markdown} -% \begin{macrocode} -\def\markdownRendererUlBeginTight{% - \markdownRendererUlBeginTightPrototype}% -% \end{macrocode} -% \par -% \begin{markdown} % -% The \mdef{markdownRendererUlItem} macro represents an item in a bulleted -% list. The macro receives no arguments. +% \iffalse + +##### Plain \TeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\input markdown +\def\markdownRendererBlockQuoteBegin{% + \begingroup + \vskip\parindent + \leftskip=2\parindent + \parindent=0pt +} +\def\markdownRendererBlockQuoteEnd{% + \par + \vskip\parindent + \endgroup +} +\markdownBegin +A quote from William Shakespeare's King Lear: + +> This is the excellent foppery of the world that when we are +> sick in fortune---often the surfeit of our own behavior---we +> make guilty of our disasters the sun, the moon, and the +> stars [...] +\markdownEnd +\bye +``````` +Next, invoke LuaTeX from the terminal: +``` sh +luatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> A quote from William Shakespeare's King Lear: +> +> > This is the excellent foppery of the world that when we are +> > sick in fortune—often the surfeit of our own behavior—we +> > make guilty of our disasters the sun, the moon, and the +> > stars [...] + +##### \LaTeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\documentclass{article} +\usepackage{markdown} +\markdownSetup{ + renderers = { + blockQuoteBegin = {\begin{quote}}, + blockQuoteEnd = {\end{quote}}, + }, +} +\begin{document} +\begin{markdown} +A quote from William Shakespeare's King Lear: + +> This is the excellent foppery of the world that when we are +> sick in fortune---often the surfeit of our own behavior---we +> make guilty of our disasters the sun, the moon, and the +> stars [...] +\end{markdown} +\end{document} +``````` +Next, invoke LuaTeX from the terminal: +``` sh +lualatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> A quote from William Shakespeare's King Lear: +> +> > This is the excellent foppery of the world that when we are +> > sick in fortune—often the surfeit of our own behavior—we +> > make guilty of our disasters the sun, the moon, and the +> > stars [...] + +##### \Hologo{ConTeXt} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\usemodule[t][markdown] +\def\markdownRendererBlockQuoteBegin{\startquotation} +\def\markdownRendererBlockQuoteEnd{\stopquotation} +\starttext +\startmarkdown +A quote from William Shakespeare's King Lear: + +> This is the excellent foppery of the world that when we are +> sick in fortune---often the surfeit of our own behavior---we +> make guilty of our disasters the sun, the moon, and the +> stars [...] +\stopmarkdown +\stoptext +``````` +Next, invoke LuaTeX from the terminal: +``` sh +context document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> A quote from William Shakespeare's King Lear: +> +> > This is the excellent foppery of the world that when we are +> > sick in fortune—often the surfeit of our own behavior—we +> > make guilty of our disasters the sun, the moon, and the +> > stars [...] + +% +%<*tex> +% \fi % -% \end{markdown} % \begin{macrocode} -\def\markdownRendererUlItem{% - \markdownRendererUlItemPrototype}% +\def\markdownRendererBlockQuoteBegin{% + \markdownRendererBlockQuoteBeginPrototype}% % \end{macrocode} % \par -% \begin{markdown} % -% The \mdef{markdownRendererUlItemEnd} macro represents the end of an item in a -% bulleted list. The macro receives no arguments. +% \iffalse +% +%<*manual-tokens> +% \fi % -% \end{markdown} -% \begin{macrocode} -\def\markdownRendererUlItemEnd{% - \markdownRendererUlItemEndPrototype}% -% \end{macrocode} -% \par % \begin{markdown} -% -% The \mdef{markdownRendererUlEnd} macro represents the end of a bulleted list -% that contains an item with several paragraphs of text (the list is not -% tight). The macro receives no arguments. -% + +The \mdef{markdownRendererBlockQuoteEnd} macro represents the end of a block +quote. The macro receives no arguments. + % \end{markdown} -% \begin{macrocode} -\def\markdownRendererUlEnd{% - \markdownRendererUlEndPrototype}% -% \end{macrocode} -% \par -% \begin{markdown} % -% The \mdef{markdownRendererUlEndTight} macro represents the end of a bulleted -% list that contains no item with several paragraphs of text (the list is -% tight). This macro will only be produced, when the \Opt{tightLists} option is -% `false`. The macro receives no arguments. +% \iffalse +% +%<*tex> +% \fi % -% \end{markdown} % \begin{macrocode} -\def\markdownRendererUlEndTight{% - \markdownRendererUlEndTightPrototype}% +\def\markdownRendererBlockQuoteEnd{% + \markdownRendererBlockQuoteEndPrototype}% % \end{macrocode} % \par -% \begin{markdown} % -%#### Ordered List Renderers -% The \mdef{markdownRendererOlBegin} macro represents the beginning of an -% ordered list that contains an item with several paragraphs of text (the -% list is not tight). The macro receives no arguments. +% \iffalse +% +%<*manual-tokens> +% \fi % -% \end{markdown} -% \begin{macrocode} -\def\markdownRendererOlBegin{% - \markdownRendererOlBeginPrototype}% -% \end{macrocode} -% \par % \begin{markdown} -% -% The \mdef{markdownRendererOlBeginTight} macro represents the beginning of an -% ordered list that contains no item with several paragraphs of text (the -% list is tight). This macro will only be produced, when the \Opt{tightLists} -% option is `false`. The macro receives no arguments. -% + +#### Code Block Renderers +The \mdef{markdownRendererInputVerbatim} macro represents a code +block. The macro receives a single argument that corresponds to the +filename of a file contaning the code block contents. + % \end{markdown} -% \begin{macrocode} -\def\markdownRendererOlBeginTight{% - \markdownRendererOlBeginTightPrototype}% -% \end{macrocode} -% \par -% \begin{markdown} % -% The \mdef{markdownRendererOlItem} macro represents an item in an ordered list. -% This macro will only be produced, when the \Opt{startNumber} option is -% `false`. The macro receives no arguments. +% \iffalse +% +%<*tex> +% \fi % -% \end{markdown} % \begin{macrocode} -\def\markdownRendererOlItem{% - \markdownRendererOlItemPrototype}% +\def\markdownRendererInputVerbatim{% + \markdownRendererInputVerbatimPrototype}% % \end{macrocode} % \par -% \begin{markdown} % -% The \mdef{markdownRendererOlItemEnd} macro represents the end of an item in -% an ordered list. The macro receives no arguments. +% \iffalse +% +%<*manual-tokens> +% \fi % -% \end{markdown} -% \begin{macrocode} -\def\markdownRendererOlItemEnd{% - \markdownRendererOlItemEndPrototype}% -% \end{macrocode} -% \par % \begin{markdown} -% -% The \mdef{markdownRendererOlItemWithNumber} macro represents an item in an -% ordered list. This macro will only be produced, when the \Opt{startNumber} -% option is `true`. The macro receives no arguments. -% + +The \mdef{markdownRendererInputFencedCode} macro represents a fenced code +block. This macro will only be produced, when the \Opt{fencedCode} option is +`true`. The macro receives two arguments that correspond to the filename of +a file contaning the code block contents and to the code fence infostring. + % \end{markdown} -% \begin{macrocode} -\def\markdownRendererOlItemWithNumber{% - \markdownRendererOlItemWithNumberPrototype}% -% \end{macrocode} -% \par -% \begin{markdown} % -% The \mdef{markdownRendererOlEnd} macro represents the end of an ordered list -% that contains an item with several paragraphs of text (the list is not -% tight). The macro receives no arguments. +% \iffalse + +##### \LaTeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\documentclass{article} +\usepackage{verbatim} +\usepackage[hyphens]{url} +\usepackage[fencedCode]{markdown} +\markdownSetup{ + renderers = { + interblockSeparator = { + \def\markdownRendererInterblockSeparator{% + \par + \def\markdownRendererInterblockSeparator{% + \def\markdownRendererInterblockSeparator{% + \par + }% + }% + }% + }, + inputVerbatim = { + is contained in file \url{#1}:% + \verbatiminput{#1}% + }, + inputFencedCode = { + in #2 \markdownRendererInputVerbatim{#1}% + }, + }, +} +\begin{document} +\begin{markdown} +The following code + + def foo(bar): + if len(bar) <= 1: + return bar[0] + elif len(bar) == 2: + return sorted(bar) + else: + baz = len(bar) // 2 + return foo(bar[baz:], bar[:baz]) + +The following code + +~~~ Python +>>> foo([4, 2, 1, 3]) +[1, 2, 3, 4] +~~~~~~~~~~ +\end{markdown} +\end{document} +``````` +Next, invoke LuaTeX from the terminal: +``` sh +lualatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text except for the filename, which may differ: + +> The following code is contained in file +> `./_markdown_document/882453149edcf288976647f6fe147ada.verbatim`: +> ``` py +> def foo(bar): +> if len(bar) <= 1: +> return bar[:1] +> elif len(bar) == 2: +> return sorted(bar) +> else: +> baz = bar[len(bar) // 2] +> return ( +> foo([qux for qux in bar if qux < baz]) + [baz] + +> foo([qux for qux in bar if qux > baz]) +> ) +> `````` +> The following code in Python contained in file +> `./_markdown_document/cf2a96e2120cef5b1fae5fea36fcc27b.verbatim`: +> ``` py +> >>> foo([4, 2, 1, 3]) +> [1, 2, 3, 4] +> `````` + +% +%<*tex> +% \fi % -% \end{markdown} % \begin{macrocode} -\def\markdownRendererOlEnd{% - \markdownRendererOlEndPrototype}% +\def\markdownRendererInputFencedCode{% + \markdownRendererInputFencedCodePrototype}% % \end{macrocode} % \par -% \begin{markdown} % -% The \mdef{markdownRendererOlEndTight} macro represents the end of an ordered -% list that contains no item with several paragraphs of text (the list is -% tight). This macro will only be produced, when the \Opt{tightLists} option is -% `false`. The macro receives no arguments. +% \iffalse +% +%<*manual-tokens> +% \fi % -% \end{markdown} -% \begin{macrocode} -\def\markdownRendererOlEndTight{% - \markdownRendererOlEndTightPrototype}% -% \end{macrocode} -% \par % \begin{markdown} + +#### Heading Renderers +The \mdef{markdownRendererHeadingOne} macro represents a first level heading. +The macro receives a single argument that corresponds to the heading text. + +% \end{markdown} % -%#### Definition List Renderers -% The following macros are only produces, when the \Opt{definitionLists} option -% is `true`. -% -% The \mdef{markdownRendererDlBegin} macro represents the beginning of a -% definition list that contains an item with several paragraphs of text (the -% list is not tight). The macro receives no arguments. +% \iffalse +% +%<*tex> +% \fi % -% \end{markdown} % \begin{macrocode} -\def\markdownRendererDlBegin{% - \markdownRendererDlBeginPrototype}% +\def\markdownRendererHeadingOne{% + \markdownRendererHeadingOnePrototype}% % \end{macrocode} % \par -% \begin{markdown} % -% The \mdef{markdownRendererDlBeginTight} macro represents the beginning of a -% definition list that contains an item with several paragraphs of text (the -% list is not tight). This macro will only be produced, when the -% \Opt{tightLists} option is `false`. The macro receives no arguments. +% \iffalse +% +%<*manual-tokens> +% \fi % -% \end{markdown} -% \begin{macrocode} -\def\markdownRendererDlBeginTight{% - \markdownRendererDlBeginTightPrototype}% -% \end{macrocode} -% \par % \begin{markdown} + +The \mdef{markdownRendererHeadingTwo} macro represents a second level +heading. The macro receives a single argument that corresponds to the heading +text. + +% \end{markdown} % -% The \mdef{markdownRendererDlItem} macro represents a term in a definition -% list. The macro receives a single argument that corresponds to the term -% being defined. +% \iffalse +% +%<*tex> +% \fi % -% \end{markdown} % \begin{macrocode} -\def\markdownRendererDlItem{% - \markdownRendererDlItemPrototype}% +\def\markdownRendererHeadingTwo{% + \markdownRendererHeadingTwoPrototype}% % \end{macrocode} % \par -% \begin{markdown} % -% The \mdef{markdownRendererDlItemEnd} macro represents the end of a list of -% definitions for a single term. +% \iffalse +% +%<*manual-tokens> +% \fi % -% \end{markdown} -% \begin{macrocode} -\def\markdownRendererDlItemEnd{% - \markdownRendererDlItemEndPrototype}% -% \end{macrocode} -% \par % \begin{markdown} + +The \mdef{markdownRendererHeadingThree} macro represents a third level +heading. The macro receives a single argument that corresponds to the heading +text. + +% \end{markdown} % -% The \mdef{markdownRendererDlDefinitionBegin} macro represents the beginning -% of a definition in a definition list. There can be several definitions for -% a single term. +% \iffalse +% +%<*tex> +% \fi % -% \end{markdown} % \begin{macrocode} -\def\markdownRendererDlDefinitionBegin{% - \markdownRendererDlDefinitionBeginPrototype}% +\def\markdownRendererHeadingThree{% + \markdownRendererHeadingThreePrototype}% % \end{macrocode} % \par -% \begin{markdown} % -% The \mdef{markdownRendererDlDefinitionEnd} macro represents the end of a -% definition in a definition list. There can be several definitions for a -% single term. +% \iffalse +% +%<*manual-tokens> +% \fi % -% \end{markdown} -% \begin{macrocode} -\def\markdownRendererDlDefinitionEnd{% - \markdownRendererDlDefinitionEndPrototype}% -% \end{macrocode} -% \par % \begin{markdown} + +The \mdef{markdownRendererHeadingFour} macro represents a fourth level +heading. The macro receives a single argument that corresponds to the heading +text. + +% \end{markdown} % -% The \mdef{markdownRendererDlEnd} macro represents the end of a definition -% list that contains an item with several paragraphs of text (the list is not -% tight). The macro receives no arguments. +% \iffalse +% +%<*tex> +% \fi % -% \end{markdown} % \begin{macrocode} -\def\markdownRendererDlEnd{% - \markdownRendererDlEndPrototype}% +\def\markdownRendererHeadingFour{% + \markdownRendererHeadingFourPrototype}% % \end{macrocode} % \par -% \begin{markdown} % -% The \mdef{markdownRendererDlEndTight} macro represents the end of a -% definition list that contains no item with several paragraphs of text (the -% list is tight). This macro will only be produced, when the \Opt{tightLists} -% option is `false`. The macro receives no arguments. +% \iffalse +% +%<*manual-tokens> +% \fi % -% \end{markdown} -% \begin{macrocode} -\def\markdownRendererDlEndTight{% - \markdownRendererDlEndTightPrototype}% -% \end{macrocode} -% \par % \begin{markdown} + +The \mdef{markdownRendererHeadingFive} macro represents a fifth level +heading. The macro receives a single argument that corresponds to the heading +text. + +% \end{markdown} % -%#### Emphasis Renderers -% The \mdef{markdownRendererEmphasis} macro represents an emphasized span of -% text. The macro receives a single argument that corresponds to the emphasized -% span of text. +% \iffalse +% +%<*tex> +% \fi % -% \end{markdown} % \begin{macrocode} -\def\markdownRendererEmphasis{% - \markdownRendererEmphasisPrototype}% +\def\markdownRendererHeadingFive{% + \markdownRendererHeadingFivePrototype}% % \end{macrocode} % \par -% \begin{markdown} % -% The \mdef{markdownRendererStrongEmphasis} macro represents a strongly -% emphasized span of text. The macro receives a single argument that -% corresponds to the emphasized span of text. +% \iffalse +% +%<*manual-tokens> +% \fi % -% \end{markdown} -% \begin{macrocode} -\def\markdownRendererStrongEmphasis{% - \markdownRendererStrongEmphasisPrototype}% -% \end{macrocode} -% \par % \begin{markdown} + +The \mdef{markdownRendererHeadingSix} macro represents a sixth level +heading. The macro receives a single argument that corresponds to the heading +text. + +% \end{markdown} % -%#### Block Quote Renderers -% The \mdef{markdownRendererBlockQuoteBegin} macro represents the beginning of -% a block quote. The macro receives no arguments. +% \iffalse + +##### Plain \TeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\input markdown +\def\markdownRendererInterblockSeparator{} +\def\markdownRendererHeadingOne{1} +\def\markdownRendererHeadingTwo{2} +\def\markdownRendererHeadingThree{3} +\def\markdownRendererHeadingFour{4} +\def\markdownRendererHeadingFive{5} +\def\markdownRendererHeadingSix{6} +\markdownBegin +###### +##### +##### +### +###### +\markdownEnd +\bye +``````` +Next, invoke LuaTeX from the terminal: +``` sh +luatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> 65536 + +##### \LaTeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\documentclass{article} +\usepackage{markdown} +\markdownSetup{ + renderers = { + interblockSeparator = {}, + headingOne = 1, + headingTwo = 2, + headingThree = 3, + headingFour = 4, + headingFive = 5, + headingSix = 6, + }, +} +\begin{document} +\begin{markdown} +###### +##### +##### +### +###### +\end{markdown} +\end{document} +``````` +Next, invoke LuaTeX from the terminal: +``` sh +lualatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> 65536 + +##### \Hologo{ConTeXt} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\usemodule[t][markdown] +\def\markdownRendererInterblockSeparator{} +\def\markdownRendererHeadingOne{1} +\def\markdownRendererHeadingTwo{2} +\def\markdownRendererHeadingThree{3} +\def\markdownRendererHeadingFour{4} +\def\markdownRendererHeadingFive{5} +\def\markdownRendererHeadingSix{6} +\starttext +\startmarkdown +###### +##### +##### +### +###### +\stopmarkdown +\stoptext +``````` +Next, invoke LuaTeX from the terminal: +``` sh +context document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> 65536 + +% +%<*tex> +% \fi % -% \end{markdown} % \begin{macrocode} -\def\markdownRendererBlockQuoteBegin{% - \markdownRendererBlockQuoteBeginPrototype}% +\def\markdownRendererHeadingSix{% + \markdownRendererHeadingSixPrototype}% % \end{macrocode} % \par -% \begin{markdown} % -% The \mdef{markdownRendererBlockQuoteEnd} macro represents the end of a block -% quote. The macro receives no arguments. +% \iffalse +% +%<*manual-tokens> +% \fi % -% \end{markdown} -% \begin{macrocode} -\def\markdownRendererBlockQuoteEnd{% - \markdownRendererBlockQuoteEndPrototype}% -% \end{macrocode} -% \par % \begin{markdown} + +#### Horizontal Rule Renderer +The \mdef{markdownRendererHorizontalRule} macro represents a horizontal rule. +The macro receives no arguments. + +% \end{markdown} % -%#### Code Block Renderers -% The \mdef{markdownRendererInputVerbatim} macro represents a code -% block. The macro receives a single argument that corresponds to the -% filename of a file contaning the code block contents. +% \iffalse + +##### Plain \TeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\input markdown +\def\markdownRendererHorizontalRule{\vfil\break} +\markdownBegin +This is the first page. + +*** + +This is the second page. +\markdownEnd +\bye +``````` +Next, invoke LuaTeX from the terminal: +``` sh +luatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> This is the first page. +> +> *** +> +> This is the second page. + +##### \LaTeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\documentclass{article} +\usepackage{markdown} +\markdownSetup{ + renderers = { + horizontalRule = \newpage, + }, +} +\begin{document} +\begin{markdown} +This is the first page. + +*** + +This is the second page. +\end{markdown} +\end{document} +``````` +Next, invoke LuaTeX from the terminal: +``` sh +lualatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> This is the first page. +> +> *** +> +> This is the second page. + +##### \Hologo{ConTeXt} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\usemodule[t][markdown] +\def\markdownRendererHorizontalRule{\page[yes]} +\starttext +\startmarkdown +This is the first page. + +*** + +This is the second page. +\stopmarkdown +\stoptext +``````` +Next, invoke LuaTeX from the terminal: +``` sh +context document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> This is the first page. +> +> *** +> +> This is the second page. + +% +%<*tex> +% \fi % -% \end{markdown} % \begin{macrocode} -\def\markdownRendererInputVerbatim{% - \markdownRendererInputVerbatimPrototype}% +\def\markdownRendererHorizontalRule{% + \markdownRendererHorizontalRulePrototype}% % \end{macrocode} % \par -% \begin{markdown} % -% The \mdef{markdownRendererInputFencedCode} macro represents a fenced code -% block. This macro will only be produced, when the \Opt{fencedCode} option is -% `true`. The macro receives two arguments that correspond to the filename of -% a file contaning the code block contents and to the code fence infostring. +% \iffalse +% +%<*manual-tokens> +% \fi % -% \end{markdown} -% \begin{macrocode} -\def\markdownRendererInputFencedCode{% - \markdownRendererInputFencedCodePrototype}% -% \end{macrocode} -% \par % \begin{markdown} -% -%#### Heading Renderers -% The \mdef{markdownRendererHeadingOne} macro represents a first level heading. -% The macro receives a single argument that corresponds to the heading text. -% + +#### Footnote Renderer +The \mdef{markdownRendererFootnote} macro represents a footnote. This macro +will only be produced, when the \Opt{footnotes} option is `true`. The +macro receives a single argument that corresponds to the footnote text. + % \end{markdown} -% \begin{macrocode} -\def\markdownRendererHeadingOne{% - \markdownRendererHeadingOnePrototype}% -% \end{macrocode} -% \par -% \begin{markdown} % -% The \mdef{markdownRendererHeadingTwo} macro represents a second level -% heading. The macro receives a single argument that corresponds to the heading -% text. +% \iffalse + +##### Plain \TeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\input markdown +\def\markdownOptionFootnotes{true} +\def\markdownRendererFootnote#1{ (and \lowercase{#1})} +\markdownBegin +This is some text[^1] and this is some other text[^2]. + + [^1]: this is a footnote + + [^2]: this is some other footnote +\markdownEnd +\bye +``````` +Next, invoke LuaTeX from the terminal: +``` sh +luatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> This is some text (and this is a footnote) and this is some other +> text (and this is some other footnote). + +##### \LaTeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\documentclass{article} +\usepackage[footnotes]{markdown} +\markdownSetup{ + renderers = { + footnote = { (and \MakeLowercase{#1})}, + }, +} +\begin{document} +\begin{markdown} +This is some text[^1] and this is some other text[^2]. + + [^1]: this is a footnote + + [^2]: this is some other footnote +\end{markdown} +\end{document} +``````` +Next, invoke LuaTeX from the terminal: +``` sh +lualatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> This is some text (and this is a footnote) and this is some other +> text (and this is some other footnote). + +##### \Hologo{ConTeXt} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\usemodule[t][markdown] +\def\markdownOptionFootnotes{true} +\def\markdownRendererFootnote#1{ (and \lowercase{#1})} +\starttext +\startmarkdown +This is some text[^1] and this is some other text[^2]. + + [^1]: this is a footnote + + [^2]: this is some other footnote +\stopmarkdown +\stoptext +``````` +Next, invoke LuaTeX from the terminal: +``` sh +context document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> This is some text (and this is a footnote) and this is some other +> text (and this is some other footnote). + +% +%<*tex> +% \fi % -% \end{markdown} % \begin{macrocode} -\def\markdownRendererHeadingTwo{% - \markdownRendererHeadingTwoPrototype}% +\def\markdownRendererFootnote{% + \markdownRendererFootnotePrototype}% % \end{macrocode} % \par -% \begin{markdown} % -% The \mdef{markdownRendererHeadingThree} macro represents a third level -% heading. The macro receives a single argument that corresponds to the heading -% text. +% \iffalse +% +%<*manual-tokens> +% \fi % -% \end{markdown} -% \begin{macrocode} -\def\markdownRendererHeadingThree{% - \markdownRendererHeadingThreePrototype}% -% \end{macrocode} -% \par % \begin{markdown} -% -% The \mdef{markdownRendererHeadingFour} macro represents a fourth level -% heading. The macro receives a single argument that corresponds to the heading -% text. -% + +#### Parenthesized Citations Renderer +The \mdef{markdownRendererCite} macro represents a string of one or more +parenthetical citations. This macro will only be produced, when the +\Opt{citations} option is `true`. The macro receives the parameter +`{`\meta{number of citations}`}` followed by \meta{suppress +author}`{`\meta{prenote}`}{`\meta{postnote}`}{`\meta{name}`}` repeated +\meta{number of citations} times. The \meta{suppress author} parameter is +either the token `-`, when the author's name is to be suppressed, or `+` +otherwise. + % \end{markdown} -% \begin{macrocode} -\def\markdownRendererHeadingFour{% - \markdownRendererHeadingFourPrototype}% -% \end{macrocode} -% \par -% \begin{markdown} % -% The \mdef{markdownRendererHeadingFive} macro represents a fifth level -% heading. The macro receives a single argument that corresponds to the heading -% text. +% \iffalse + +##### \LaTeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\documentclass{article} +\usepackage[citations]{markdown} +\newcount\citationsCounter +\newcount\citationsTotal +\makeatletter +\def\citations#1#2#3#4{% + a parenthesized citation \emph{#4} + \advance\citationsCounter by 1\relax + \ifx\relax#2\relax + \ifx\relax#3\relax\else + with a postfix \emph{#3}% + \fi + \else + with a prefix \emph{#2}% + \ifx\relax#3\relax\else + \ and a postfix \emph{#3}% + \fi + \fi + \ifnum\citationsCounter>\citationsTotal\relax + .% + \expandafter\@gobble + \else + , and + \fi\citations} +\makeatother +\markdownSetup{ + renderers = { + cite = {% + \citationsCounter=1% + \citationsTotal=#1% + This is + \expandafter\citations + }, + }, +} +\begin{document} +\begin{markdown} +[see @abrahams90, pp. 12; @eijkhout91, pp. 34] +\end{markdown} +\end{document} +``````` +Next, invoke LuaTeX from the terminal: +``` sh +lualatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> This is a parenthesized citation *abrahams90* with a prefix see +> and a postfix *pp. > 12*, and a citation *eijkhout91* with a +> postfix *pp. 34*. + +% +%<*tex> +% \fi % -% \end{markdown} % \begin{macrocode} -\def\markdownRendererHeadingFive{% - \markdownRendererHeadingFivePrototype}% +\def\markdownRendererCite{% + \markdownRendererCitePrototype}% % \end{macrocode} % \par -% \begin{markdown} % -% The \mdef{markdownRendererHeadingSix} macro represents a sixth level -% heading. The macro receives a single argument that corresponds to the heading -% text. +% \iffalse +% +%<*manual-tokens> +% \fi % -% \end{markdown} -% \begin{macrocode} -\def\markdownRendererHeadingSix{% - \markdownRendererHeadingSixPrototype}% -% \end{macrocode} -% \par % \begin{markdown} + +#### Text Citations Renderer +The \mdef{markdownRendererTextCite} macro represents a string of one or more +text citations. This macro will only be produced, when the +\Opt{citations} option is `true`. The macro receives parameters in the same +format as the \m{markdownRendererCite} macro. + +% \end{markdown} % -%#### Horizontal Rule Renderer -% The \mdef{markdownRendererHorizontalRule} macro represents a horizontal rule. -% The macro receives no arguments. +% \iffalse + +##### \LaTeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\documentclass{article} +\usepackage[citations]{markdown} +\newcount\citationsCounter +\newcount\citationsTotal +\makeatletter +\def\citations#1#2#3#4{% + a text citation \emph{#4} + \advance\citationsCounter by 1\relax + \ifx\relax#2\relax + \ifx\relax#3\relax\else + with a postfix \emph{#3}% + \fi + \else + with a prefix \emph{#2}% + \ifx\relax#3\relax\else + \ and a postfix \emph{#3}% + \fi + \fi + \ifnum\citationsCounter>\citationsTotal\relax + .% + \expandafter\@gobble + \else + , and + \fi\citations} +\makeatother +\markdownSetup{ + renderers = { + textCite = {% + \citationsCounter=1% + \citationsTotal=#1% + This is + \expandafter\citations + }, + }, +} +\begin{document} +\begin{markdown} +@abrahams90 [pp. 12; also @eijkhout91] +\end{markdown} +\end{document} +``````` +Next, invoke LuaTeX from the terminal: +``` sh +lualatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> This is a text citation *abrahams90* with a postfix *pp. 12*, +> and a citation *eijkhout91* with a prefix *also*. + +% +%<*tex> +% \fi % -% \end{markdown} % \begin{macrocode} -\def\markdownRendererHorizontalRule{% - \markdownRendererHorizontalRulePrototype}% +\def\markdownRendererTextCite{% + \markdownRendererTextCitePrototype}% % \end{macrocode} % \par -% \begin{markdown} % -%#### Footnote Renderer -% The \mdef{markdownRendererFootnote} macro represents a footnote. This macro -% will only be produced, when the \Opt{footnotes} option is `true`. The -% macro receives a single argument that corresponds to the footnote text. +% \iffalse +% +%<*manual-tokens> +% \fi % -% \end{markdown} -% \begin{macrocode} -\def\markdownRendererFootnote{% - \markdownRendererFootnotePrototype}% -% \end{macrocode} -% \par % \begin{markdown} -% -%#### Parenthesized Citations Renderer -% The \mdef{markdownRendererCite} macro represents a string of one or more -% parenthetical citations. This macro will only be produced, when the -% \Opt{citations} option is `true`. The macro receives the parameter -% `{`\meta{number of citations}`}` followed by \meta{suppress -% author}`{`\meta{prenote}`}{`\meta{postnote}`}{`\meta{name}`}` repeated -% \meta{number of citations} times. The \meta{suppress author} parameter is -% either the token `-`, when the author's name is to be suppressed, or `+` -% otherwise. + +### Token Renderer Prototypes + +% \label{sec:texrendererprototypes} % % \end{markdown} -% \begin{macrocode} -\def\markdownRendererCite{% - \markdownRendererCitePrototype}% -% \end{macrocode} -% \par -% \begin{markdown} +% \iffalse + +By default, token renderers point to package-defined \TeX{} macros, further +referred to as *prototypes*, which provide useful default definitions. + +% \fi % -%#### Text Citations Renderer -% The \mdef{markdownRendererTextCite} macro represents a string of one or more -% text citations. This macro will only be produced, when the -% \Opt{citations} option is `true`. The macro receives parameters in the same -% format as the \m{markdownRendererCite} macro. +% \iffalse + +##### Plain \TeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\input markdown +\def\markdownRendererTildePrototype{% + Packages can specify token renderer prototypes.% +} +\markdownBegin +~ +\markdownEnd + +\def\markdownRendererTilde{% + User-defined token renderers take precedence.% +} +\markdownBegin +~ +\markdownEnd +\bye +``````` +Next, invoke LuaTeX from the terminal: +``` sh +luatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> Packages can specify token renderer prototypes. +> +> User-defined token renderers take precedence. + +##### \LaTeX{} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\documentclass{article} +\usepackage{markdown} +\markdownSetup{ + rendererPrototypes = { + tilde = {Packages can specify token renderer prototypes.}, + }, +} +\begin{document} +\begin{markdown} +~ +\end{markdown} + +\begin{markdown*}{ + renderers = { + tilde = {User-defined token renderers take precedence.}, + }, +} +~ +\end{markdown*} +\end{document} +``````` +Next, invoke LuaTeX from the terminal: +``` sh +lualatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> Packages can specify token renderer prototypes. +> +> User-defined token renderers take precedence. + +##### \Hologo{ConTeXt} Example {.unnumbered} + +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\usemodule[t][markdown] +\def\markdownRendererTildePrototype{% + Packages can specify token renderer prototypes.% +} +\starttext +\startmarkdown +~ +\stopmarkdown + +\def\markdownRendererTilde{% + User-defined token renderers take precedence.% +} +\startmarkdown +~ +\stopmarkdown +\stoptext +``````` +Next, invoke LuaTeX from the terminal: +``` sh +context document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> Packages can specify token renderer prototypes. +> +> User-defined token renderers take precedence. + +% +%<*tex> +% \fi % -% \end{markdown} -% \begin{macrocode} -\def\markdownRendererTextCite{% - \markdownRendererTextCitePrototype}% -% \end{macrocode} -% \par % \begin{markdown} % -%### Token Renderer Prototypes -% \label{sec:texrendererprototypes} % The following \TeX{} macros provide definitions for the token renderers (see % Section \ref{sec:texrenderersuser}) that have not been redefined by the % user. These macros are intended to be redefined by macro package authors @@ -5934,12 +9457,11 @@ typeset. % \end{macrocode} % \par % \begin{markdown} -% +% %### Logging Facilities -% The \mdef{markdownInfo}, \mdef{markdownWarning}, and -% \mdef{markdownError} macros provide access to logging to the rest of -% the macros. Their first argument specifies the text of the info, warning, or -% error message. +% The \mdef{markdownInfo}, \mdef{markdownWarning}, and \mdef{markdownError} +% macros perform logging for the Markdown package. Their first argument +% specifies the text of the info, warning, or error message. % % \end{markdown} % \begin{macrocode} @@ -5950,7 +9472,7 @@ typeset. % \begin{markdown} % % The \m{markdownError} macro receives a second argument that provides a help -% text suggesting a remedy to the error. +% text. % % \end{markdown} % \begin{macrocode} @@ -6013,11 +9535,11 @@ typeset. % The \mdef{markdownMode} macro specifies how the plain \TeX{} implementation % interfaces with the Lua interface. The valid values and their meaning are % as follows: -% \begin{itemize} -% \item`0` -- Shell escape via the 18 output file stream -% \item`1` -- Shell escape via the Lua \luam{os.execute} method -% \item`2` -- Direct Lua access -% \end{itemize} +% +% - `0` – Shell escape via the 18 output file stream +% - `1` – Shell escape via the Lua \luam{os.execute} method +% - `2` – Direct Lua access +% % By defining the macro, the user can coerce the package to use a specific mode. % If the user does not define the macro prior to loading the plain \TeX{} % implementation, the correct value will be automatically detected. The outcome @@ -6047,7 +9569,6 @@ typeset. % \end{macrocode} % \iffalse % -%<*latex> % \fi % \par % \begin{markdown} @@ -6056,25 +9577,59 @@ typeset. %------------------- % \label{sec:latexinterface} % +% \end{markdown} % \iffalse -% -%<*manual> +%<*manual-interfaces> + +### \LaTeX{} -LaTeX ------ +The \LaTeX{} interface provides the same level of functionality as the plain +\TeX{} interface by using the plain \TeX{} interface behind the scenes. Unlike +the plain \TeX{} interface, the \LaTeX{} interface uses familiar \LaTeX{} +idioms, such as package options and environments. -The LaTeX macro package provides additional syntactic sugar on top of the plain -TeX macro package and provides sane default definitions of the token renderers. +The \LaTeX{} interface accepts the same options as the plain \TeX{} interface, +but now the options are specified as \meta{key}${}={}$\meta{value} pairs and +they are passed either as package options, in the \m{markdownSetup} command, or +as parameters for the \envm{markdown*} \LaTeX{} environment. - +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\documentclass{article} +\usepackage{markdown} +\begin{document} -### Interfaces +\begin{markdown} +$\sqrt{-1}$ *equals* $i$ +\end{markdown} - +\begin{markdown*}{hybrid} +$\sqrt{-1}$ *equals* $i$ +\end{markdown*} -% +\end{document} +``````` +Next, invoke LuaTeX from the terminal: +``` sh +lualatex document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: + +> \$\\sqrt{-1}\$ *equals* \$i\$. +> +> √-̅1̅ *equals* $i$. + +Invoking pdfTeX should have the same effect: +``` sh +pdflatex --shell-escape document.tex +`````` + +% %<*latex> % \fi +% \begin{markdown} % % The \LaTeX{} interface provides \LaTeX{} environments for the typesetting of % markdown input from within \LaTeX{}, facilities for setting Lua interface @@ -6086,7 +9641,7 @@ TeX macro package and provides sane default definitions of the token renderers. % The \LaTeX{} interface is implemented by the `markdown.sty` file, which % can be loaded from the \LaTeX{} document preamble as follows: % \end{markdown} -% \begin{Verbatim}[commandchars=\\\{\}] +% \begin{Verbatim}[commandchars=\\\{\},gobble=2] % \textbackslash{}usepackage[\textrm{\meta{options}}]\{markdown\} % \end{Verbatim} % \begin{markdown} @@ -6164,18 +9719,6 @@ TeX macro package and provides sane default definitions of the token renderers. %### Options % \label{sec:latexoptions} % -% \iffalse -% -%<*manual> - -### Options - - - -% -%<*latex> -% \fi -% % The \LaTeX{} options are represented by a comma-delimited list of % \meta{key}`=`\meta{value} pairs. For boolean options, the `=`\meta{value} % part is optional, and \meta{key} will be interpreted as \meta{key}`=true`. @@ -6242,6 +9785,8 @@ TeX macro package and provides sane default definitions of the token renderers. \def\markdownOptionFencedCode{#1}}% \define@key{markdownOptions}{hashEnumerators}[true]{% \def\markdownOptionHashEnumerators{#1}}% +\define@key{markdownOptions}{headerAttributes}[true]{% + \def\markdownOptionHeaderAttributes{#1}}% \define@key{markdownOptions}{html}[true]{% \def\markdownOptionHtml{#1}}% \define@key{markdownOptions}{hybrid}[true]{% @@ -6252,6 +9797,8 @@ TeX macro package and provides sane default definitions of the token renderers. \def\markdownOptionPreserveTabs{#1}}% \define@key{markdownOptions}{smartEllipses}[true]{% \def\markdownOptionSmartEllipses{#1}}% +\define@key{markdownOptions}{slice}[true]{% + \def\markdownOptionSlice{#1}}% \define@key{markdownOptions}{startNumber}[true]{% \def\markdownOptionStartNumber{#1}}% \define@key{markdownOptions}{tightLists}[true]{% @@ -6278,18 +9825,6 @@ TeX macro package and provides sane default definitions of the token renderers. %#### Plain \TeX{} Markdown Token Renderers % \label{sec:latexrenderers} % -% \iffalse -% -%<*manual> - -### Token renderers - - - -% -%<*latex> -% \fi -% % The \LaTeX{} interface recognizes an option with the `renderers` key, % whose value must be a list of options that map directly to the markdown token % renderer macros exposed by the plain \TeX{} interface (see Section @@ -6580,28 +10115,52 @@ TeX macro package and provides sane default definitions of the token renderers. % % \iffalse % -%<*manual> +%<*manual-interfaces> -ConTeXt -------- +### \Hologo{ConTeXt} -The ConTeXt macro package provides additional syntactic sugar on top of the -plain TeX macro package and provides sane default definitions of the token -renderers. +The \Hologo{ConTeXt} interface provides the same level of functionality as the +plain \TeX{} interface by using the plain \TeX{} interface behind the scenes. +Unlike the plain \TeX{} interface, the \Hologo{ConTeXt} interface uses familiar +\Hologo{ConTeXt} idioms, such as environments. -### Interfaces +The \Hologo{ConTeXt} interface accepts the same options as the plain \TeX{} +interface. - +Using a text editor, create a text document named `document.tex` with the +following content: +``` tex +\usemodule[t][markdown] +\starttext -### Options +\startmarkdown +$\sqrt{-1}$ *equals* $i$. +\stopmarkdown - +\def\markdownOptionHybrid{true} +\startmarkdown +$\sqrt{-1}$ *equals* $i$. +\stopmarkdown -### Token renderers +\stoptext +``````` +Next, invoke LuaTeX from the terminal: +``` sh +context document.tex +`````` +A PDF document named `document.pdf` should be produced and contain the +following text: - +> \$\\sqrt{-1}\$ *equals* \$i\$. +> +> √-̅1̅ *equals* $i$. + +Invoking pdfTeX should have the same effect: +``` sh +texexec --passon=--shell-escape document.tex +`````` -% +% %<*context> % \fi % @@ -7345,6 +10904,40 @@ function M.writer.new(options) % \par % \begin{markdown} % +% Parse the \Opt{slice} option and define \luamdef{writer->slice\_begin} +% \luamdef{writer->slice\_end}, and \luamdef{writer->is\_writing}. +% +% \end{markdown} +% \begin{macrocode} + local slice_specifiers = {} + for specifier in options.slice:gmatch("[^%s]+") do + table.insert(slice_specifiers, specifier) + end + + if #slice_specifiers == 2 then + self.slice_begin, self.slice_end = table.unpack(slice_specifiers) + local slice_begin_type = self.slice_begin:sub(1, 1) + if slice_begin_type ~= "^" and slice_begin_type ~= "$" then + self.slice_begin = "^" .. self.slice_begin + end + local slice_end_type = self.slice_end:sub(1, 1) + if slice_end_type ~= "^" and slice_end_type ~= "$" then + self.slice_end = "$" .. self.slice_end + end + elseif #slice_specifiers == 1 then + self.slice_begin = "^" .. slice_specifiers[1] + self.slice_end = "$" .. slice_specifiers[1] + end + + if self.slice_begin == "^" and self.slice_end ~= "^" then + self.is_writing = true + else + self.is_writing = false + end +% \end{macrocode} +% \par +% \begin{markdown} +% % Define \luamdef{writer->suffix} as the suffix of the produced cache files. % % \end{markdown} @@ -7391,6 +10984,7 @@ function M.writer.new(options) % \end{markdown} % \begin{macrocode} function self.paragraph(s) + if not self.is_writing then return "" end return s end % \end{macrocode} @@ -7404,7 +10998,7 @@ function M.writer.new(options) % \end{markdown} % \begin{macrocode} function self.pack(name) - return [[\input"]] .. name .. [["\relax{}]] + return [[\input ]] .. name .. [[\relax{}]] end % \end{macrocode} % \par @@ -7415,7 +11009,10 @@ function M.writer.new(options) % % \end{markdown} % \begin{macrocode} - self.interblocksep = "\\markdownRendererInterblockSeparator\n{}" + function self.interblocksep() + if not self.is_writing then return "" end + return "\\markdownRendererInterblockSeparator\n{}" + end % \end{macrocode} % \par % \begin{markdown} @@ -7451,7 +11048,10 @@ function M.writer.new(options) % % \end{markdown} % \begin{macrocode} - self.hrule = "\\markdownRendererHorizontalRule{}" + function self.hrule() + if not self.is_writing then return "" end + return "\\markdownRendererHorizontalRule{}" + end % \end{macrocode} % \par % \begin{markdown} @@ -7586,29 +11186,29 @@ function M.writer.new(options) % % \end{markdown} % \begin{macrocode} -local languages_json = (function() - local kpse = require("kpse") - kpse.set_program_name("luatex") - local base, prev, curr - for _, file in ipairs{kpse.lookup(options.contentBlocksLanguageMap, - { all=true })} do - json = io.open(file, "r"):read("*all") - :gsub('("[^\n]-"):','[%1]=') - curr = (function() - local _ENV={ json=json, load=load } -- run in sandbox - return load("return "..json)() - end)() - if type(curr) == "table" then - if base == nil then - base = curr - else - setmetatable(prev, { __index = curr }) + local languages_json = (function() + local kpse = require("kpse") + kpse.set_program_name("luatex") + local base, prev, curr + for _, file in ipairs{kpse.lookup(options.contentBlocksLanguageMap, + { all=true })} do + json = io.open(file, "r"):read("*all") + :gsub('("[^\n]-"):','[%1]=') + curr = (function() + local _ENV={ json=json, load=load } -- run in sandbox + return load("return "..json)() + end)() + if type(curr) == "table" then + if base == nil then + base = curr + else + setmetatable(prev, { __index = curr }) + end + prev = curr end - prev = curr end - end - return base or {} -end)() + return base or {} + end)() % \end{macrocode} % \par % \begin{markdown} @@ -7622,6 +11222,7 @@ end)() % \end{markdown} % \begin{macrocode} function self.contentblock(src,suf,type,tit) + if not self.is_writing then return "" end src = src.."."..suf suf = suf:lower() if type == "onlineimage" then @@ -7658,6 +11259,7 @@ end)() end function self.bulletlist(items,tight) + if not self.is_writing then return "" end local buffer = {} for _,item in ipairs(items) do buffer[#buffer + 1] = ulitem(item) @@ -7694,6 +11296,7 @@ end)() end function self.orderedlist(items,tight,startnum) + if not self.is_writing then return "" end local buffer = {} local num = startnum for _,item in ipairs(items) do @@ -7747,6 +11350,7 @@ end)() end function self.definitionlist(items,tight) + if not self.is_writing then return "" end local buffer = {} for _,item in ipairs(items) do buffer[#buffer + 1] = dlitem(item.term, item.definitions) @@ -7793,6 +11397,7 @@ end)() % \end{markdown} % \begin{macrocode} function self.blockquote(s) + if #util.rope_to_string(s) == 0 then return "" end return {"\\markdownRendererBlockQuoteBegin\n",s, "\n\\markdownRendererBlockQuoteEnd "} end @@ -7806,6 +11411,7 @@ end)() % \end{markdown} % \begin{macrocode} function self.verbatim(s) + if not self.is_writing then return "" end local name = util.cache(options.cacheDir, s, nil, nil, ".verbatim") return {"\\markdownRendererInputVerbatim{",name,"}"} end @@ -7820,6 +11426,7 @@ end)() % \end{markdown} % \begin{macrocode} function self.fencedCode(i, s) + if not self.is_writing then return "" end local name = util.cache(options.cacheDir, s, nil, nil, ".verbatim") return {"\\markdownRendererInputFencedCode{",name,"}{",i,"}"} end @@ -7827,12 +11434,67 @@ end)() % \par % \begin{markdown} % +% Define \luamdef{writer->active_headings} as a stack of identifiers +% of the headings that are currently active. +% +% \end{markdown} +% \begin{macrocode} + self.active_headings = {} +% \end{macrocode} +% \par +% \begin{markdown} +% % Define \luamdef{writer->heading} as a function that will transform an -% input heading `s` at level `level` to the output format. +% input heading `s` at level `level` with identifiers `identifiers` to the +% output format. % % \end{markdown} % \begin{macrocode} - function self.heading(s,level) + function self.heading(s,level,attributes) + local active_headings = self.active_headings + local slice_begin_type = self.slice_begin:sub(1, 1) + local slice_begin_identifier = self.slice_begin:sub(2) or "" + local slice_end_type = self.slice_end:sub(1, 1) + local slice_end_identifier = self.slice_end:sub(2) or "" + + while #active_headings < level do + -- push empty identifiers for implied sections + table.insert(active_headings, {}) + end + + while #active_headings >= level do + -- pop identifiers for sections that have ended + local active_identifiers = active_headings[#active_headings] + if active_identifiers[slice_begin_identifier] ~= nil + and slice_begin_type == "$" then + self.is_writing = true + end + if active_identifiers[slice_end_identifier] ~= nil + and slice_end_type == "$" then + self.is_writing = false + end + table.remove(active_headings, #active_headings) + end + + -- push identifiers for the new section + attributes = attributes or {} + local identifiers = {} + for index = 1, #attributes do + attribute = attributes[index] + identifiers[attribute:sub(2)] = true + end + if identifiers[slice_begin_identifier] ~= nil + and slice_begin_type == "^" then + self.is_writing = true + end + if identifiers[slice_end_identifier] ~= nil + and slice_end_type == "^" then + self.is_writing = false + end + table.insert(active_headings, identifiers) + + if not self.is_writing then return "" end + local cmd if level == 1 then cmd = "\\markdownRendererHeadingOne" @@ -7934,6 +11596,8 @@ parsers.lparent = P("(") parsers.rparent = P(")") parsers.lbracket = P("[") parsers.rbracket = P("]") +parsers.lbrace = P("{") +parsers.rbrace = P("}") parsers.circumflex = P("^") parsers.slash = P("/") parsers.equal = P("=") @@ -8000,6 +11664,22 @@ parsers.nonemptyline = parsers.line - parsers.blankline parsers.chunk = parsers.line * (parsers.optionallyindentedline - parsers.blankline)^0 +parsers.css_identifier_char = R("AZ", "az", "09") + S("-_") +parsers.css_identifier = (parsers.hash + parsers.period) + * (((parsers.css_identifier_char + - parsers.dash - parsers.digit) + * parsers.css_identifier_char^1) + + (parsers.dash + * (parsers.css_identifier_char + - parsers.digit) + * parsers.css_identifier_char^0)) +parsers.attribute_name_char = parsers.any - parsers.space + - parsers.squote - parsers.dquote + - parsers.more - parsers.slash + - parsers.equal +parsers.attribute_value_char = parsers.any - parsers.dquote + - parsers.more + -- block followed by 0 or more optionally -- indented blocks with first line indented. parsers.indented_blocks = function(bl) @@ -8284,9 +11964,8 @@ parsers.citation_body_postnote parsers.citation_body_chunk = parsers.citation_body_prenote * parsers.spnl * parsers.citation_name - * ((parsers.internal_punctuation - parsers.semicolon) - * parsers.spnl)^-1 - * parsers.citation_body_postnote + * (parsers.internal_punctuation - parsers.semicolon)^-1 + * parsers.spnl * parsers.citation_body_postnote parsers.citation_body = parsers.citation_body_chunk @@ -8437,7 +12116,7 @@ parsers.inlinehtml = parsers.emptyelt_any % \par % \begin{markdown} % -%#### Parsers Used for \textsc{html} entities +%#### Parsers Used for \textsc{html} Entities % % \end{markdown} % \begin{macrocode} @@ -8540,6 +12219,18 @@ parsers.dlchunk = Cs(parsers.line * (parsers.indentedline - parsers.blankline)^0 % % \end{markdown} % \begin{macrocode} +parsers.heading_attribute = C(parsers.css_identifier) + + C((parsers.attribute_name_char + - parsers.rbrace)^1 + * parsers.equal + * (parsers.attribute_value_char + - parsers.rbrace)^1) +parsers.HeadingAttributes = parsers.lbrace + * parsers.heading_attribute + * (parsers.spacechar^1 + * parsers.heading_attribute)^0 + * parsers.rbrace + -- parse Atx heading start and return level parsers.HeadingStart = #parsers.hash * C(parsers.hash^-6) * -parsers.hash / length @@ -9147,6 +12838,9 @@ function M.reader.new(writer, options) local function ordered_list(items,tight,startNumber) if options.startNumber then startNumber = tonumber(startNumber) or 1 -- fallback for '#' + if startNumber ~= nil then + startNumber = math.floor(startNumber) + end else startNumber = nil end @@ -9203,18 +12897,63 @@ function M.reader.new(writer, options) % \end{markdown} % \begin{macrocode} -- parse atx header - larsers.AtxHeading = Cg(parsers.HeadingStart,"level") - * parsers.optionalspace - * (C(parsers.line) / strip_atx_end / parse_inlines) - * Cb("level") - / writer.heading - - -- parse setext header - larsers.SetextHeading = #(parsers.line * S("=-")) - * Ct(parsers.line / parse_inlines) - * parsers.HeadingLevel - * parsers.optionalspace * parsers.newline - / writer.heading + if options.headerAttributes then + larsers.AtxHeading = Cg(parsers.HeadingStart,"level") + * parsers.optionalspace + * (C(((parsers.linechar + - ((parsers.hash^1 + * parsers.optionalspace + * parsers.HeadingAttributes^-1 + + parsers.HeadingAttributes) + * parsers.optionalspace + * parsers.newline)) + * (parsers.linechar + - parsers.hash + - parsers.lbrace)^0)^1) + / parse_inlines) + * Cg(Ct(parsers.newline + + (parsers.hash^1 + * parsers.optionalspace + * parsers.HeadingAttributes^-1 + + parsers.HeadingAttributes) + * parsers.optionalspace + * parsers.newline), "attributes") + * Cb("level") + * Cb("attributes") + / writer.heading + + larsers.SetextHeading = #(parsers.line * S("=-")) + * (C(((parsers.linechar + - (parsers.HeadingAttributes + * parsers.optionalspace + * parsers.newline)) + * (parsers.linechar + - parsers.lbrace)^0)^1) + / parse_inlines) + * Cg(Ct(parsers.newline + + (parsers.HeadingAttributes + * parsers.optionalspace + * parsers.newline)), "attributes") + * parsers.HeadingLevel + * Cb("attributes") + * parsers.optionalspace + * parsers.newline + / writer.heading + else + larsers.AtxHeading = Cg(parsers.HeadingStart,"level") + * parsers.optionalspace + * (C(parsers.line) / strip_atx_end / parse_inlines) + * Cb("level") + / writer.heading + + larsers.SetextHeading = #(parsers.line * S("=-")) + * Ct(parsers.linechar^1 / parse_inlines) + * parsers.newline + * parsers.HeadingLevel + * parsers.optionalspace + * parsers.newline + / writer.heading + end larsers.Heading = larsers.AtxHeading + larsers.SetextHeading % \end{macrocode} @@ -9229,9 +12968,7 @@ function M.reader.new(writer, options) { "Blocks", Blocks = larsers.Blank^0 * parsers.Block^-1 - * (larsers.Blank^0 / function() - return writer.interblocksep - end + * (larsers.Blank^0 / writer.interblocksep * parsers.Block)^0 * larsers.Blank^0 * parsers.eof, @@ -9573,7 +13310,7 @@ end \def\markdownRendererBlockQuoteBeginPrototype{\par\begingroup\it}% \def\markdownRendererBlockQuoteEndPrototype{\endgroup\par}% \def\markdownRendererInputVerbatimPrototype#1{% - \par{\tt\input"#1"\relax{}}\par}% + \par{\tt\input#1\relax{}}\par}% \def\markdownRendererInputFencedCodePrototype#1#2{% \markdownRendererInputVerbatimPrototype{#1}}% \def\markdownRendererHeadingOnePrototype#1{#1}% @@ -9639,6 +13376,9 @@ end \ifx\markdownOptionHashEnumerators\undefined\else hashEnumerators = \markdownOptionHashEnumerators, \fi +\ifx\markdownOptionHeaderAttributes\undefined\else + headerAttributes = \markdownOptionHeaderAttributes, +\fi \ifx\markdownOptionHtml\undefined\else html = \markdownOptionHtml, \fi @@ -9651,6 +13391,9 @@ end \ifx\markdownOptionPreserveTabs\undefined\else preserveTabs = \markdownOptionPreserveTabs, \fi +\ifx\markdownOptionSlice\undefined\else + slice = "\markdownOptionSlice", +\fi \ifx\markdownOptionSmartEllipses\undefined\else smartEllipses = \markdownOptionSmartEllipses, \fi @@ -9755,7 +13498,7 @@ local convert = md.new(\markdownLuaOptions) % \end{markdown} % \begin{macrocode} |immediate|openout|markdownOutputFileStream@ - |markdownOptionInputTempFileName@ + |markdownOptionInputTempFileName|relax@ |markdownInfo{Buffering markdown input into the temporary @ input file "|markdownOptionInputTempFileName" and scanning @ for the closing token sequence "#1"}@ @@ -9878,7 +13621,7 @@ local convert = md.new(\markdownLuaOptions) % \ref{sec:directlua} are meant to be indistinguishable to the remaining code. % % The package assumes that although the user is not using the Lua\TeX{} engine, -% their TeX distribution contains it, and uses shell access to produce and +% their \TeX{} distribution contains it, and uses shell access to produce and % execute Lua scripts using the \TeX{}Lua interpreter~[@luatex17, Section % 3.1.1]. % @@ -10097,7 +13840,9 @@ local convert = md.new(\markdownLuaOptions) |closein|markdownInputFileStream |markdownLuaExecute{% |markdownPrepare - local input = assert(io.open("#1", "r"):read("*a")) + local input = assert(io.open("% + |markdownOptionOutputDir + /#1", "r"):read("*a")) % \end{macrocode} % \begin{markdown} % Since the Lua converter expects \acro{unix} line endings, normalize the @@ -10396,23 +14141,172 @@ local convert = md.new(\markdownLuaOptions) % \begin{markdown} % % There is a basic implementation for citations that uses the \LaTeX{} \m{cite} -% macro. There is also a more advanced implementation that uses the Bib\LaTeX{} -% \m{autocites} and \m{textcites} macros. This implementation will be used, when -% Bib\LaTeX{} is loaded. +% macro. There are also implementations that use the \pkg{natbib} \m{citep}, +% and \m{citet} macros, and the Bib\LaTeX{} \m{autocites} and \m{textcites} +% macros. These implementations will be used, when the respective packages are +% loaded. % % \end{markdown} % \begin{macrocode} \newcount\markdownLaTeXCitationsCounter % Basic implementation -\def\markdownLaTeXBasicCitations#1#2#3#4{% +\def\markdownLaTeXBasicCitations#1#2#3#4#5#6{% \advance\markdownLaTeXCitationsCounter by 1\relax - \ifx\relax#2\relax\else#2~\fi\cite[#3]{#4}% - \ifnum\markdownLaTeXCitationsCounter>\markdownLaTeXCitationsTotal\relax - \expandafter\@gobble - \fi\markdownLaTeXBasicCitations} + \ifx\relax#4\relax + \ifx\relax#5\relax + \ifnum\markdownLaTeXCitationsCounter>\markdownLaTeXCitationsTotal\relax + \cite{#1#2#6}% Without prenotes and postnotes, just accumulate cites + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter + \@gobblethree + \fi + \else% Before a postnote (#5), dump the accumulator + \ifx\relax#1\relax\else + \cite{#1}% + \fi + \cite[#5]{#6}% + \ifnum\markdownLaTeXCitationsCounter>\markdownLaTeXCitationsTotal\relax + \else + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter + \markdownLaTeXBasicCitations + \fi + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter}% + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter}% + \expandafter\expandafter\expandafter + \@gobblethree + \fi + \else% Before a prenote (#4), dump the accumulator + \ifx\relax#1\relax\else + \cite{#1}% + \fi + \ifnum\markdownLaTeXCitationsCounter>1\relax + \space % Insert a space before the prenote in later citations + \fi + #4~\expandafter\cite\ifx\relax#5\relax{#6}\else[#5]{#6}\fi + \ifnum\markdownLaTeXCitationsCounter>\markdownLaTeXCitationsTotal\relax + \else + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter + \markdownLaTeXBasicCitations + \fi + \expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter}% + \expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter}% + \expandafter + \@gobblethree + \fi\markdownLaTeXBasicCitations{#1#2#6},} \let\markdownLaTeXBasicTextCitations\markdownLaTeXBasicCitations +% Natbib implementation +\def\markdownLaTeXNatbibCitations#1#2#3#4#5{% + \advance\markdownLaTeXCitationsCounter by 1\relax + \ifx\relax#3\relax + \ifx\relax#4\relax + \ifnum\markdownLaTeXCitationsCounter>\markdownLaTeXCitationsTotal\relax + \citep{#1,#5}% Without prenotes and postnotes, just accumulate cites + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter + \@gobbletwo + \fi + \else% Before a postnote (#4), dump the accumulator + \ifx\relax#1\relax\else + \citep{#1}% + \fi + \citep[][#4]{#5}% + \ifnum\markdownLaTeXCitationsCounter>\markdownLaTeXCitationsTotal\relax + \else + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter + \markdownLaTeXNatbibCitations + \fi + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter}% + \expandafter\expandafter\expandafter + \@gobbletwo + \fi + \else% Before a prenote (#3), dump the accumulator + \ifx\relax#1\relax\relax\else + \citep{#1}% + \fi + \citep[#3][#4]{#5}% + \ifnum\markdownLaTeXCitationsCounter>\markdownLaTeXCitationsTotal\relax + \else + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter + \markdownLaTeXNatbibCitations + \fi + \expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter}% + \expandafter + \@gobbletwo + \fi\markdownLaTeXNatbibCitations{#1,#5}} +\def\markdownLaTeXNatbibTextCitations#1#2#3#4#5{% + \advance\markdownLaTeXCitationsCounter by 1\relax + \ifx\relax#3\relax + \ifx\relax#4\relax + \ifnum\markdownLaTeXCitationsCounter>\markdownLaTeXCitationsTotal\relax + \citet{#1,#5}% Without prenotes and postnotes, just accumulate cites + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter + \@gobbletwo + \fi + \else% After a prenote or a postnote, dump the accumulator + \ifx\relax#1\relax\else + \citet{#1}% + \fi + , \citet[#3][#4]{#5}% + \ifnum\markdownLaTeXCitationsCounter<\markdownLaTeXCitationsTotal\relax + , + \else + \ifnum\markdownLaTeXCitationsCounter=\markdownLaTeXCitationsTotal\relax + , + \fi + \fi + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter + \markdownLaTeXNatbibTextCitations + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter}% + \expandafter\expandafter\expandafter + \@gobbletwo + \fi + \else% After a prenote or a postnote, dump the accumulator + \ifx\relax#1\relax\relax\else + \citet{#1}% + \fi + , \citet[#3][#4]{#5}% + \ifnum\markdownLaTeXCitationsCounter<\markdownLaTeXCitationsTotal\relax + , + \else + \ifnum\markdownLaTeXCitationsCounter=\markdownLaTeXCitationsTotal\relax + , + \fi + \fi + \expandafter\expandafter\expandafter + \markdownLaTeXNatbibTextCitations + \expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter}% + \expandafter + \@gobbletwo + \fi\markdownLaTeXNatbibTextCitations{#1,#5}} + % BibLaTeX implementation \def\markdownLaTeXBibLaTeXCitations#1#2#3#4#5{% \advance\markdownLaTeXCitationsCounter by 1\relax @@ -10432,8 +14326,19 @@ local convert = md.new(\markdownLuaOptions) \markdownLaTeXCitationsCounter=1% \def\markdownLaTeXCitationsTotal{#1}% \ifx\autocites\undefined - \expandafter - \markdownLaTeXBasicCitations + \ifx\citep\undefined + \expandafter\expandafter\expandafter + \markdownLaTeXBasicCitations + \expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter}% + \expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter}% + \else + \expandafter\expandafter\expandafter + \markdownLaTeXNatbibCitations + \expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter}% + \fi \else \expandafter\expandafter\expandafter \markdownLaTeXBibLaTeXCitations @@ -10442,9 +14347,20 @@ local convert = md.new(\markdownLuaOptions) textCite = {% \markdownLaTeXCitationsCounter=1% \def\markdownLaTeXCitationsTotal{#1}% - \ifx\textcites\undefined - \expandafter - \markdownLaTeXBasicTextCitations + \ifx\autocites\undefined + \ifx\citep\undefined + \expandafter\expandafter\expandafter + \markdownLaTeXBasicTextCitations + \expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter}% + \expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter}% + \else + \expandafter\expandafter\expandafter + \markdownLaTeXNatbibTextCitations + \expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter}% + \fi \else \expandafter\expandafter\expandafter \markdownLaTeXBibLaTeXTextCitations @@ -10517,7 +14433,8 @@ local convert = md.new(\markdownLuaOptions) % When buffering user input, we should disable the bytes with the high bit set, % since these are made active by the \m{enableregime} macro. We will do this % by redefining the \m{markdownMakeOther} macro accordingly. The code is -% courtesy of Scott Pakin, the creator of the \pkg{filecontents} LaTeX package. +% courtesy of Scott Pakin, the creator of the \pkg{filecontents} \LaTeX{} +% package. % % \end{markdown} % \begin{macrocode} diff --git a/Master/texmf-dist/source/generic/markdown/markdown.ins b/Master/texmf-dist/source/generic/markdown/markdown.ins index 0965a974b78..b7436c37fcf 100644 --- a/Master/texmf-dist/source/generic/markdown/markdown.ins +++ b/Master/texmf-dist/source/generic/markdown/markdown.ins @@ -8,5 +8,8 @@ \file{t-markdown.tex}{\from{markdown.dtx}{context}} \usepreamble\empty\usepostamble\empty \file{markdown.md}{\from{markdown.dtx}{manual}} + \file{markdown-interfaces.md}{\from{markdown.dtx}{manual-interfaces}} + \file{markdown-options.md}{\from{markdown.dtx}{manual-options}} + \file{markdown-tokens.md}{\from{markdown.dtx}{manual-tokens}} \file{markdown.css}{\from{markdown.dtx}{manual-css}}} \endbatchfile diff --git a/Master/texmf-dist/tex/context/third/markdown/t-markdown.tex b/Master/texmf-dist/tex/context/third/markdown/t-markdown.tex index 40f891b19bd..f114a6d267a 100644 --- a/Master/texmf-dist/tex/context/third/markdown/t-markdown.tex +++ b/Master/texmf-dist/tex/context/third/markdown/t-markdown.tex @@ -6,7 +6,7 @@ %% %% markdown.dtx (with options: `context') %% -%% Copyright (C) 2018 Vít Novotný +%% Copyright (C) 2016-2019 Vít Novotný %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 diff --git a/Master/texmf-dist/tex/generic/markdown/markdown.tex b/Master/texmf-dist/tex/generic/markdown/markdown.tex index 8b33ee045de..6091f6ea530 100644 --- a/Master/texmf-dist/tex/generic/markdown/markdown.tex +++ b/Master/texmf-dist/tex/generic/markdown/markdown.tex @@ -6,7 +6,7 @@ %% %% markdown.dtx (with options: `tex') %% -%% Copyright (C) 2018 Vít Novotný +%% Copyright (C) 2016-2019 Vít Novotný %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -45,8 +45,8 @@ %% %% The names of the source files used are shown above. %% -\def\markdownLastModified{2018/04/08}% -\def\markdownVersion{2.5.6}% +\def\markdownLastModified{2019/04/04}% +\def\markdownVersion{2.7.0}% \let\markdownBegin\relax \let\markdownEnd\relax \let\markdownInput\relax @@ -54,8 +54,8 @@ \def\markdownOptionInputTempFileName{\jobname.markdown.in}% \def\markdownOptionOutputTempFileName{\jobname.markdown.out}% \def\markdownOptionErrorTempFileName{\jobname.markdown.err}% -\def\markdownOptionCacheDir{\markdownOptionOutputDir/_markdown_\jobname}% \def\markdownOptionOutputDir{.}% +\def\markdownOptionCacheDir{\markdownOptionOutputDir/_markdown_\jobname}% \let\markdownOptionBlankBeforeBlockquote\undefined \let\markdownOptionBlankBeforeCodeFence\undefined \let\markdownOptionBlankBeforeHeading\undefined @@ -68,10 +68,12 @@ \let\markdownOptionFootnotes\undefined \let\markdownOptionFencedCode\undefined \let\markdownOptionHashEnumerators\undefined +\let\markdownOptionHeaderAttributes\undefined \let\markdownOptionHtml\undefined \let\markdownOptionHybrid\undefined \let\markdownOptionInlineFootnotes\undefined \let\markdownOptionPreserveTabs\undefined +\let\markdownOptionSlice\undefined \let\markdownOptionSmartEllipses\undefined \let\markdownOptionStartNumber\undefined \let\markdownOptionTightLists\undefined @@ -338,7 +340,7 @@ \def\markdownRendererBlockQuoteBeginPrototype{\par\begingroup\it}% \def\markdownRendererBlockQuoteEndPrototype{\endgroup\par}% \def\markdownRendererInputVerbatimPrototype#1{% - \par{\tt\input"#1"\relax{}}\par}% + \par{\tt\input#1\relax{}}\par}% \def\markdownRendererInputFencedCodePrototype#1#2{% \markdownRendererInputVerbatimPrototype{#1}}% \def\markdownRendererHeadingOnePrototype#1{#1}% @@ -393,6 +395,9 @@ \ifx\markdownOptionHashEnumerators\undefined\else hashEnumerators = \markdownOptionHashEnumerators, \fi +\ifx\markdownOptionHeaderAttributes\undefined\else + headerAttributes = \markdownOptionHeaderAttributes, +\fi \ifx\markdownOptionHtml\undefined\else html = \markdownOptionHtml, \fi @@ -405,6 +410,9 @@ \ifx\markdownOptionPreserveTabs\undefined\else preserveTabs = \markdownOptionPreserveTabs, \fi +\ifx\markdownOptionSlice\undefined\else + slice = "\markdownOptionSlice", +\fi \ifx\markdownOptionSmartEllipses\undefined\else smartEllipses = \markdownOptionSmartEllipses, \fi @@ -443,7 +451,7 @@ local convert = md.new(\markdownLuaOptions) |gdef|markdownReadAndConvert#1#2{@ |begingroup@ |immediate|openout|markdownOutputFileStream@ - |markdownOptionInputTempFileName@ + |markdownOptionInputTempFileName|relax@ |markdownInfo{Buffering markdown input into the temporary @ input file "|markdownOptionInputTempFileName" and scanning @ for the closing token sequence "#1"}@ @@ -570,7 +578,9 @@ local convert = md.new(\markdownLuaOptions) |closein|markdownInputFileStream |markdownLuaExecute{% |markdownPrepare - local input = assert(io.open("#1", "r"):read("*a")) + local input = assert(io.open("% + |markdownOptionOutputDir + /#1", "r"):read("*a")) print(convert(input:gsub("\r\n?", "\n")))}}% |endgroup \endinput diff --git a/Master/texmf-dist/tex/latex/markdown/markdown.sty b/Master/texmf-dist/tex/latex/markdown/markdown.sty index 251a2f62d74..f21cb15b81d 100644 --- a/Master/texmf-dist/tex/latex/markdown/markdown.sty +++ b/Master/texmf-dist/tex/latex/markdown/markdown.sty @@ -6,7 +6,7 @@ %% %% markdown.dtx (with options: `latex') %% -%% Copyright (C) 2018 Vít Novotný +%% Copyright (C) 2016-2019 Vít Novotný %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -52,6 +52,7 @@ \RequirePackage{ifthen} \RequirePackage{fancyvrb} \RequirePackage{csvsimple} +\RequirePackage{gobble} \newenvironment{markdown}\relax\relax \newenvironment{markdown*}[1]\relax\relax \newcommand\markdownSetup[1]{% @@ -94,6 +95,8 @@ \def\markdownOptionFencedCode{#1}}% \define@key{markdownOptions}{hashEnumerators}[true]{% \def\markdownOptionHashEnumerators{#1}}% +\define@key{markdownOptions}{headerAttributes}[true]{% + \def\markdownOptionHeaderAttributes{#1}}% \define@key{markdownOptions}{html}[true]{% \def\markdownOptionHtml{#1}}% \define@key{markdownOptions}{hybrid}[true]{% @@ -104,6 +107,8 @@ \def\markdownOptionPreserveTabs{#1}}% \define@key{markdownOptions}{smartEllipses}[true]{% \def\markdownOptionSmartEllipses{#1}}% +\define@key{markdownOptions}{slice}[true]{% + \def\markdownOptionSlice{#1}}% \define@key{markdownOptions}{startNumber}[true]{% \def\markdownOptionStartNumber{#1}}% \define@key{markdownOptions}{tightLists}[true]{% @@ -495,14 +500,161 @@ \fi \newcount\markdownLaTeXCitationsCounter -\def\markdownLaTeXBasicCitations#1#2#3#4{% +\def\markdownLaTeXBasicCitations#1#2#3#4#5#6{% \advance\markdownLaTeXCitationsCounter by 1\relax - \ifx\relax#2\relax\else#2~\fi\cite[#3]{#4}% - \ifnum\markdownLaTeXCitationsCounter>\markdownLaTeXCitationsTotal\relax - \expandafter\@gobble - \fi\markdownLaTeXBasicCitations} + \ifx\relax#4\relax + \ifx\relax#5\relax + \ifnum\markdownLaTeXCitationsCounter>\markdownLaTeXCitationsTotal\relax + \cite{#1#2#6}% Without prenotes and postnotes, just accumulate cites + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter + \@gobblethree + \fi + \else% Before a postnote (#5), dump the accumulator + \ifx\relax#1\relax\else + \cite{#1}% + \fi + \cite[#5]{#6}% + \ifnum\markdownLaTeXCitationsCounter>\markdownLaTeXCitationsTotal\relax + \else + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter + \markdownLaTeXBasicCitations + \fi + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter}% + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter}% + \expandafter\expandafter\expandafter + \@gobblethree + \fi + \else% Before a prenote (#4), dump the accumulator + \ifx\relax#1\relax\else + \cite{#1}% + \fi + \ifnum\markdownLaTeXCitationsCounter>1\relax + \space % Insert a space before the prenote in later citations + \fi + #4~\expandafter\cite\ifx\relax#5\relax{#6}\else[#5]{#6}\fi + \ifnum\markdownLaTeXCitationsCounter>\markdownLaTeXCitationsTotal\relax + \else + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter + \markdownLaTeXBasicCitations + \fi + \expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter}% + \expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter}% + \expandafter + \@gobblethree + \fi\markdownLaTeXBasicCitations{#1#2#6},} \let\markdownLaTeXBasicTextCitations\markdownLaTeXBasicCitations +\def\markdownLaTeXNatbibCitations#1#2#3#4#5{% + \advance\markdownLaTeXCitationsCounter by 1\relax + \ifx\relax#3\relax + \ifx\relax#4\relax + \ifnum\markdownLaTeXCitationsCounter>\markdownLaTeXCitationsTotal\relax + \citep{#1,#5}% Without prenotes and postnotes, just accumulate cites + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter + \@gobbletwo + \fi + \else% Before a postnote (#4), dump the accumulator + \ifx\relax#1\relax\else + \citep{#1}% + \fi + \citep[][#4]{#5}% + \ifnum\markdownLaTeXCitationsCounter>\markdownLaTeXCitationsTotal\relax + \else + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter + \markdownLaTeXNatbibCitations + \fi + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter}% + \expandafter\expandafter\expandafter + \@gobbletwo + \fi + \else% Before a prenote (#3), dump the accumulator + \ifx\relax#1\relax\relax\else + \citep{#1}% + \fi + \citep[#3][#4]{#5}% + \ifnum\markdownLaTeXCitationsCounter>\markdownLaTeXCitationsTotal\relax + \else + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter + \markdownLaTeXNatbibCitations + \fi + \expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter}% + \expandafter + \@gobbletwo + \fi\markdownLaTeXNatbibCitations{#1,#5}} +\def\markdownLaTeXNatbibTextCitations#1#2#3#4#5{% + \advance\markdownLaTeXCitationsCounter by 1\relax + \ifx\relax#3\relax + \ifx\relax#4\relax + \ifnum\markdownLaTeXCitationsCounter>\markdownLaTeXCitationsTotal\relax + \citet{#1,#5}% Without prenotes and postnotes, just accumulate cites + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter + \@gobbletwo + \fi + \else% After a prenote or a postnote, dump the accumulator + \ifx\relax#1\relax\else + \citet{#1}% + \fi + , \citet[#3][#4]{#5}% + \ifnum\markdownLaTeXCitationsCounter<\markdownLaTeXCitationsTotal\relax + , + \else + \ifnum\markdownLaTeXCitationsCounter=\markdownLaTeXCitationsTotal\relax + , + \fi + \fi + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter + \markdownLaTeXNatbibTextCitations + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter}% + \expandafter\expandafter\expandafter + \@gobbletwo + \fi + \else% After a prenote or a postnote, dump the accumulator + \ifx\relax#1\relax\relax\else + \citet{#1}% + \fi + , \citet[#3][#4]{#5}% + \ifnum\markdownLaTeXCitationsCounter<\markdownLaTeXCitationsTotal\relax + , + \else + \ifnum\markdownLaTeXCitationsCounter=\markdownLaTeXCitationsTotal\relax + , + \fi + \fi + \expandafter\expandafter\expandafter + \markdownLaTeXNatbibTextCitations + \expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter}% + \expandafter + \@gobbletwo + \fi\markdownLaTeXNatbibTextCitations{#1,#5}} + \def\markdownLaTeXBibLaTeXCitations#1#2#3#4#5{% \advance\markdownLaTeXCitationsCounter by 1\relax \ifnum\markdownLaTeXCitationsCounter>\markdownLaTeXCitationsTotal\relax @@ -521,8 +673,19 @@ \markdownLaTeXCitationsCounter=1% \def\markdownLaTeXCitationsTotal{#1}% \ifx\autocites\undefined - \expandafter - \markdownLaTeXBasicCitations + \ifx\citep\undefined + \expandafter\expandafter\expandafter + \markdownLaTeXBasicCitations + \expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter}% + \expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter}% + \else + \expandafter\expandafter\expandafter + \markdownLaTeXNatbibCitations + \expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter}% + \fi \else \expandafter\expandafter\expandafter \markdownLaTeXBibLaTeXCitations @@ -531,9 +694,20 @@ textCite = {% \markdownLaTeXCitationsCounter=1% \def\markdownLaTeXCitationsTotal{#1}% - \ifx\textcites\undefined - \expandafter - \markdownLaTeXBasicTextCitations + \ifx\autocites\undefined + \ifx\citep\undefined + \expandafter\expandafter\expandafter + \markdownLaTeXBasicTextCitations + \expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter}% + \expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter}% + \else + \expandafter\expandafter\expandafter + \markdownLaTeXNatbibTextCitations + \expandafter\expandafter\expandafter{% + \expandafter\expandafter\expandafter}% + \fi \else \expandafter\expandafter\expandafter \markdownLaTeXBibLaTeXTextCitations diff --git a/Master/texmf-dist/tex/luatex/markdown/markdown.lua b/Master/texmf-dist/tex/luatex/markdown/markdown.lua index 25d45c32da2..9614434b81f 100644 --- a/Master/texmf-dist/tex/luatex/markdown/markdown.lua +++ b/Master/texmf-dist/tex/luatex/markdown/markdown.lua @@ -20,7 +20,7 @@ -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- --- Copyright (C) 2018 Vít Novotný +-- Copyright (C) 2016-2019 Vít Novotný -- -- This work may be distributed and/or modified under the -- conditions of the LaTeX Project Public License, either version 1.3 @@ -58,11 +58,11 @@ -- those in the standard .ins files. -- local metadata = { - version = "2.5.6", + version = "2.7.0", comment = "A module for the conversion from markdown to plain TeX", author = "John MacFarlane, Hans Hagen, Vít Novotný", copyright = {"2009-2016 John MacFarlane, Hans Hagen", - "2016-2018 Vít Novotný"}, + "2016-2019 Vít Novotný"}, license = "LPPL 1.3" } @@ -87,10 +87,12 @@ defaultOptions.definitionLists = false defaultOptions.fencedCode = false defaultOptions.footnotes = false defaultOptions.hashEnumerators = false +defaultOptions.headerAttributes = false defaultOptions.html = false defaultOptions.hybrid = false defaultOptions.inlineFootnotes = false defaultOptions.preserveTabs = false +defaultOptions.slice = "^ $" defaultOptions.smartEllipses = false defaultOptions.startNumber = true defaultOptions.tightLists = true @@ -498,6 +500,31 @@ function M.writer.new(options) options = options or {} setmetatable(options, { __index = function (_, key) return defaultOptions[key] end }) + local slice_specifiers = {} + for specifier in options.slice:gmatch("[^%s]+") do + table.insert(slice_specifiers, specifier) + end + + if #slice_specifiers == 2 then + self.slice_begin, self.slice_end = table.unpack(slice_specifiers) + local slice_begin_type = self.slice_begin:sub(1, 1) + if slice_begin_type ~= "^" and slice_begin_type ~= "$" then + self.slice_begin = "^" .. self.slice_begin + end + local slice_end_type = self.slice_end:sub(1, 1) + if slice_end_type ~= "^" and slice_end_type ~= "$" then + self.slice_end = "$" .. self.slice_end + end + elseif #slice_specifiers == 1 then + self.slice_begin = "^" .. slice_specifiers[1] + self.slice_end = "$" .. slice_specifiers[1] + end + + if self.slice_begin == "^" and self.slice_end ~= "^" then + self.is_writing = true + else + self.is_writing = false + end self.suffix = ".tex" self.space = " " self.nbsp = "\\markdownRendererNbsp{}" @@ -505,16 +532,23 @@ function M.writer.new(options) return s end function self.paragraph(s) + if not self.is_writing then return "" end return s end function self.pack(name) - return [[\input"]] .. name .. [["\relax{}]] + return [[\input ]] .. name .. [[\relax{}]] + end + function self.interblocksep() + if not self.is_writing then return "" end + return "\\markdownRendererInterblockSeparator\n{}" end - self.interblocksep = "\\markdownRendererInterblockSeparator\n{}" self.eof = [[\relax]] self.linebreak = "\\markdownRendererLineBreak\n{}" self.ellipsis = "\\markdownRendererEllipsis{}" - self.hrule = "\\markdownRendererHorizontalRule{}" + function self.hrule() + if not self.is_writing then return "" end + return "\\markdownRendererHorizontalRule{}" + end local escaped_chars = { ["{"] = "\\markdownRendererLeftBrace{}", ["}"] = "\\markdownRendererRightBrace{}", @@ -572,30 +606,31 @@ function M.writer.new(options) "{",self.uri(src),"}", "{",self.string(tit or ""),"}"} end -local languages_json = (function() - local kpse = require("kpse") - kpse.set_program_name("luatex") - local base, prev, curr - for _, file in ipairs{kpse.lookup(options.contentBlocksLanguageMap, - { all=true })} do - json = io.open(file, "r"):read("*all") - :gsub('("[^\n]-"):','[%1]=') - curr = (function() - local _ENV={ json=json, load=load } -- run in sandbox - return load("return "..json)() - end)() - if type(curr) == "table" then - if base == nil then - base = curr - else - setmetatable(prev, { __index = curr }) + local languages_json = (function() + local kpse = require("kpse") + kpse.set_program_name("luatex") + local base, prev, curr + for _, file in ipairs{kpse.lookup(options.contentBlocksLanguageMap, + { all=true })} do + json = io.open(file, "r"):read("*all") + :gsub('("[^\n]-"):','[%1]=') + curr = (function() + local _ENV={ json=json, load=load } -- run in sandbox + return load("return "..json)() + end)() + if type(curr) == "table" then + if base == nil then + base = curr + else + setmetatable(prev, { __index = curr }) + end + prev = curr end - prev = curr end - end - return base or {} -end)() + return base or {} + end)() function self.contentblock(src,suf,type,tit) + if not self.is_writing then return "" end src = src.."."..suf suf = suf:lower() if type == "onlineimage" then @@ -622,6 +657,7 @@ end)() end function self.bulletlist(items,tight) + if not self.is_writing then return "" end local buffer = {} for _,item in ipairs(items) do buffer[#buffer + 1] = ulitem(item) @@ -646,6 +682,7 @@ end)() end function self.orderedlist(items,tight,startnum) + if not self.is_writing then return "" end local buffer = {} local num = startnum for _,item in ipairs(items) do @@ -676,6 +713,7 @@ end)() end function self.definitionlist(items,tight) + if not self.is_writing then return "" end local buffer = {} for _,item in ipairs(items) do buffer[#buffer + 1] = dlitem(item.term, item.definitions) @@ -695,18 +733,66 @@ end)() return {"\\markdownRendererStrongEmphasis{",s,"}"} end function self.blockquote(s) + if #util.rope_to_string(s) == 0 then return "" end return {"\\markdownRendererBlockQuoteBegin\n",s, "\n\\markdownRendererBlockQuoteEnd "} end function self.verbatim(s) + if not self.is_writing then return "" end local name = util.cache(options.cacheDir, s, nil, nil, ".verbatim") return {"\\markdownRendererInputVerbatim{",name,"}"} end function self.fencedCode(i, s) + if not self.is_writing then return "" end local name = util.cache(options.cacheDir, s, nil, nil, ".verbatim") return {"\\markdownRendererInputFencedCode{",name,"}{",i,"}"} end - function self.heading(s,level) + self.active_headings = {} + function self.heading(s,level,attributes) + local active_headings = self.active_headings + local slice_begin_type = self.slice_begin:sub(1, 1) + local slice_begin_identifier = self.slice_begin:sub(2) or "" + local slice_end_type = self.slice_end:sub(1, 1) + local slice_end_identifier = self.slice_end:sub(2) or "" + + while #active_headings < level do + -- push empty identifiers for implied sections + table.insert(active_headings, {}) + end + + while #active_headings >= level do + -- pop identifiers for sections that have ended + local active_identifiers = active_headings[#active_headings] + if active_identifiers[slice_begin_identifier] ~= nil + and slice_begin_type == "$" then + self.is_writing = true + end + if active_identifiers[slice_end_identifier] ~= nil + and slice_end_type == "$" then + self.is_writing = false + end + table.remove(active_headings, #active_headings) + end + + -- push identifiers for the new section + attributes = attributes or {} + local identifiers = {} + for index = 1, #attributes do + attribute = attributes[index] + identifiers[attribute:sub(2)] = true + end + if identifiers[slice_begin_identifier] ~= nil + and slice_begin_type == "^" then + self.is_writing = true + end + if identifiers[slice_end_identifier] ~= nil + and slice_end_type == "^" then + self.is_writing = false + end + table.insert(active_headings, identifiers) + + if not self.is_writing then return "" end + local cmd if level == 1 then cmd = "\\markdownRendererHeadingOne" @@ -761,6 +847,8 @@ parsers.lparent = P("(") parsers.rparent = P(")") parsers.lbracket = P("[") parsers.rbracket = P("]") +parsers.lbrace = P("{") +parsers.rbrace = P("}") parsers.circumflex = P("^") parsers.slash = P("/") parsers.equal = P("=") @@ -827,6 +915,22 @@ parsers.nonemptyline = parsers.line - parsers.blankline parsers.chunk = parsers.line * (parsers.optionallyindentedline - parsers.blankline)^0 +parsers.css_identifier_char = R("AZ", "az", "09") + S("-_") +parsers.css_identifier = (parsers.hash + parsers.period) + * (((parsers.css_identifier_char + - parsers.dash - parsers.digit) + * parsers.css_identifier_char^1) + + (parsers.dash + * (parsers.css_identifier_char + - parsers.digit) + * parsers.css_identifier_char^0)) +parsers.attribute_name_char = parsers.any - parsers.space + - parsers.squote - parsers.dquote + - parsers.more - parsers.slash + - parsers.equal +parsers.attribute_value_char = parsers.any - parsers.dquote + - parsers.more + -- block followed by 0 or more optionally -- indented blocks with first line indented. parsers.indented_blocks = function(bl) @@ -1063,9 +1167,8 @@ parsers.citation_body_postnote parsers.citation_body_chunk = parsers.citation_body_prenote * parsers.spnl * parsers.citation_name - * ((parsers.internal_punctuation - parsers.semicolon) - * parsers.spnl)^-1 - * parsers.citation_body_postnote + * (parsers.internal_punctuation - parsers.semicolon)^-1 + * parsers.spnl * parsers.citation_body_postnote parsers.citation_body = parsers.citation_body_chunk @@ -1255,6 +1358,18 @@ parsers.defstart = ( parsers.defstartchar * #parsers.spacing ) parsers.dlchunk = Cs(parsers.line * (parsers.indentedline - parsers.blankline)^0) +parsers.heading_attribute = C(parsers.css_identifier) + + C((parsers.attribute_name_char + - parsers.rbrace)^1 + * parsers.equal + * (parsers.attribute_value_char + - parsers.rbrace)^1) +parsers.HeadingAttributes = parsers.lbrace + * parsers.heading_attribute + * (parsers.spacechar^1 + * parsers.heading_attribute)^0 + * parsers.rbrace + -- parse Atx heading start and return level parsers.HeadingStart = #parsers.hash * C(parsers.hash^-6) * -parsers.hash / length @@ -1721,6 +1836,9 @@ function M.reader.new(writer, options) local function ordered_list(items,tight,startNumber) if options.startNumber then startNumber = tonumber(startNumber) or 1 -- fallback for '#' + if startNumber ~= nil then + startNumber = math.floor(startNumber) + end else startNumber = nil end @@ -1761,27 +1879,70 @@ function M.reader.new(writer, options) + larsers.Reference + (parsers.tightblocksep / "\n") -- parse atx header - larsers.AtxHeading = Cg(parsers.HeadingStart,"level") - * parsers.optionalspace - * (C(parsers.line) / strip_atx_end / parse_inlines) - * Cb("level") - / writer.heading - - -- parse setext header - larsers.SetextHeading = #(parsers.line * S("=-")) - * Ct(parsers.line / parse_inlines) - * parsers.HeadingLevel - * parsers.optionalspace * parsers.newline - / writer.heading + if options.headerAttributes then + larsers.AtxHeading = Cg(parsers.HeadingStart,"level") + * parsers.optionalspace + * (C(((parsers.linechar + - ((parsers.hash^1 + * parsers.optionalspace + * parsers.HeadingAttributes^-1 + + parsers.HeadingAttributes) + * parsers.optionalspace + * parsers.newline)) + * (parsers.linechar + - parsers.hash + - parsers.lbrace)^0)^1) + / parse_inlines) + * Cg(Ct(parsers.newline + + (parsers.hash^1 + * parsers.optionalspace + * parsers.HeadingAttributes^-1 + + parsers.HeadingAttributes) + * parsers.optionalspace + * parsers.newline), "attributes") + * Cb("level") + * Cb("attributes") + / writer.heading + + larsers.SetextHeading = #(parsers.line * S("=-")) + * (C(((parsers.linechar + - (parsers.HeadingAttributes + * parsers.optionalspace + * parsers.newline)) + * (parsers.linechar + - parsers.lbrace)^0)^1) + / parse_inlines) + * Cg(Ct(parsers.newline + + (parsers.HeadingAttributes + * parsers.optionalspace + * parsers.newline)), "attributes") + * parsers.HeadingLevel + * Cb("attributes") + * parsers.optionalspace + * parsers.newline + / writer.heading + else + larsers.AtxHeading = Cg(parsers.HeadingStart,"level") + * parsers.optionalspace + * (C(parsers.line) / strip_atx_end / parse_inlines) + * Cb("level") + / writer.heading + + larsers.SetextHeading = #(parsers.line * S("=-")) + * Ct(parsers.linechar^1 / parse_inlines) + * parsers.newline + * parsers.HeadingLevel + * parsers.optionalspace + * parsers.newline + / writer.heading + end larsers.Heading = larsers.AtxHeading + larsers.SetextHeading local syntax = { "Blocks", Blocks = larsers.Blank^0 * parsers.Block^-1 - * (larsers.Blank^0 / function() - return writer.interblocksep - end + * (larsers.Blank^0 / writer.interblocksep * parsers.Block)^0 * larsers.Blank^0 * parsers.eof, -- cgit v1.2.3