diff options
Diffstat (limited to 'Master/texmf-dist/source/generic')
-rw-r--r-- | Master/texmf-dist/source/generic/markdown/markdown.dtx | 1942 |
1 files changed, 1332 insertions, 610 deletions
diff --git a/Master/texmf-dist/source/generic/markdown/markdown.dtx b/Master/texmf-dist/source/generic/markdown/markdown.dtx index 2e3e12e15dd..b1659244769 100644 --- a/Master/texmf-dist/source/generic/markdown/markdown.dtx +++ b/Master/texmf-dist/source/generic/markdown/markdown.dtx @@ -79,11 +79,11 @@ citations, definitionLists, fencedCode, - footnotes, + notes, headerAttributes, html, hybrid, - inlineFootnotes, + inlineNotes, jekyllData, relativeReferences, stripPercentSigns, @@ -109,14 +109,14 @@ % Set up the catcodes. \catcode`\_=12 % We won't be typesetting much math and Lua contains lots of `_`. -\catcode`\^^B=8 % When we occasionally need subscripts , we will use `^^B` (STX). +\catcode`\^^B=8 % When we occasionally need subscripts, we will use `^^B` (STX). % Set up the title page. \begin{markdown} --- title: A Markdown Interpreter for \TeX url: https://github.com/witiko/markdown -author: Vít Novotný +authors: [Vít Novotný] email: witiko@mail.muni.cz revision: \markdownVersion date: \markdownLastModified @@ -709,6 +709,13 @@ abbr { version = {v2.5}, url = {https://mirrors.ctan.org/macros/latex/contrib/minted/minted.pdf}, urldate = {2020-09-01}} +@online{macfarlane22, + title = {Pandoc}, + subtitle = {a universal document converter}, + author = {John MacFarlane}, + year = {2022}, + url = {https://pandoc.org/}, + urldate = {2022-10-05}} @online{novotny15, author = {Novotný, Vít}, year = {2015}, @@ -759,9 +766,16 @@ abbr { subtitle = {A \TeX nician's Reference}, isbn = {0-201-56882-0}, pagetotal = {307}, - date = {1992-02-01}, - location = {Wokingham, England}, + date = {1992-02-01}, + location = {Wokingham, England}, publisher = {Addison-Wesley}} +@inproceedings{sharif10, + author = {Sharif, Bonita and Maletic, Jonathan I.}, + booktitle = {2010 IEEE 18th International Conference on Program Comprehension}, + title = {An Eye Tracking Study on camelCase and under\_score Identifier Styles}, + year = {2010}, + pages = {196-205}, + doi = {10.1109/ICPC.2010.41}} %</techdoc-bibliography> %<*latex-themes-witiko-markdown-techdoc> \ProvidesPackage{markdownthemewitiko_markdown_techdoc}[2022/02/23] @@ -807,7 +821,7 @@ abbr { }, }, jekyllDataRenderers = { - author = {% + /authors/* = {% \gdef\ltd@title@author{#1}% \hypersetup{pdfauthor={#1}}% }, @@ -963,15 +977,15 @@ make base `````` This should produce the following files: - * `markdown.lua`, the Lua module, - * `libraries/markdown-tinyyaml.lua`, an external library for reading \acro{yaml}, - * `markdown-cli.lua`, the Lua command-line interface, - * `markdown.tex`, the plain \TeX{} macro package, - * `markdown.sty`, the \LaTeX{} package, - * `markdownthemewitiko_dot.sty`, the `witiko/dot` \LaTeX{} theme, - * `markdownthemewitiko_graphicx_http.sty`, the `witiko/graphicx/http` \LaTeX{} theme, - * `markdownthemewitiko_tilde.sty`, the `witiko/tilde` \LaTeX{} theme, and - * `t-markdown.tex`, the \Hologo{ConTeXt} module. +* `markdown.lua`, the Lua module, +* `libraries/markdown-tinyyaml.lua`, an external library for reading \acro{yaml}, +* `markdown-cli.lua`, the Lua command-line interface, +* `markdown.tex`, the plain \TeX{} macro package, +* `markdown.sty`, the \LaTeX{} package, +* `markdownthemewitiko_dot.sty`, the `witiko/dot` \LaTeX{} theme, +* `markdownthemewitiko_graphicx_http.sty`, the `witiko/graphicx/http` \LaTeX{} theme, +* `markdownthemewitiko_tilde.sty`, the `witiko/tilde` \LaTeX{} theme, and +* `t-markdown.tex`, the \Hologo{ConTeXt} module. ### Local Installation @@ -979,15 +993,15 @@ To perform a local installation, place the above files into your \TeX{} directory structure. This is generally where the individual files should be placed: - * `⟨TEXMF⟩/tex/luatex/markdown/markdown.lua` - * `⟨TEXMF⟩/tex/luatex/markdown/markdown-tinyyaml.lua` - * `⟨TEXMF⟩/scripts/markdown/markdown-cli.lua` - * `⟨TEXMF⟩/tex/generic/markdown/markdown.tex` - * `⟨TEXMF⟩/tex/latex/markdown/markdown.sty` - * `⟨TEXMF⟩/tex/latex/markdown/markdownthemewitiko_dot.sty` - * `⟨TEXMF⟩/tex/latex/markdown/markdownthemewitiko_graphicx_http.sty` - * `⟨TEXMF⟩/tex/latex/markdown/markdownthemewitiko_tilde.sty` - * `⟨TEXMF⟩/tex/context/third/markdown/t-markdown.tex` +* `⟨TEXMF⟩/tex/luatex/markdown/markdown.lua` +* `⟨TEXMF⟩/tex/luatex/markdown/markdown-tinyyaml.lua` +* `⟨TEXMF⟩/scripts/markdown/markdown-cli.lua` +* `⟨TEXMF⟩/tex/generic/markdown/markdown.tex` +* `⟨TEXMF⟩/tex/latex/markdown/markdown.sty` +* `⟨TEXMF⟩/tex/latex/markdown/markdownthemewitiko_dot.sty` +* `⟨TEXMF⟩/tex/latex/markdown/markdownthemewitiko_graphicx_http.sty` +* `⟨TEXMF⟩/tex/latex/markdown/markdownthemewitiko_tilde.sty` +* `⟨TEXMF⟩/tex/context/third/markdown/t-markdown.tex` where `⟨TEXMF⟩` corresponds to a root of your \TeX{} distribution, such as `/usr/share/texmf` and `~/texmf` on UN\*X systems or @@ -1039,7 +1053,7 @@ local lpeg = require("lpeg") % \pkg{Selene Unicode} % %: A library that provides support for the processing of wide strings. It is -% used by the \pkg{Lunamark} library to cast image, link, and footnote tags +% used by the \pkg{Lunamark} library to cast image, link, and note tags % to the lower case. \pkg{Selene Unicode} is included in all releases of % Lua\TeX{} (\TeX Live${}\geq{}2008$). % @@ -1206,7 +1220,7 @@ local md5 = require("md5") % %: A package that provides a concise syntax for the inspection of macro % values. It is used in the `witiko/dot` \LaTeX{} theme (see Section -% <#sec:latexthemes>), and to provide default token renderer prototypes. +% <#sec:latexthemes>). % % \pkg{fancyvrb} % @@ -1620,7 +1634,7 @@ local walkable_syntax = { Block = { "Blockquote", "Verbatim", - "HorizontalRule", + "ThematicBreak", "BulletList", "OrderedList", "Heading", @@ -1888,7 +1902,7 @@ interfaces and all the way up to the \LaTeX{} and \Hologo{ConTeXt} interfaces. \prop_new:N \g_@@_default_lua_options_prop \seq_new:N \g_@@_option_layers_seq \tl_const:Nn \c_@@_option_layer_lua_tl { lua } -\seq_put_right:NV \g_@@_option_layers_seq \c_@@_option_layer_lua_tl +\seq_gput_right:NV \g_@@_option_layers_seq \c_@@_option_layer_lua_tl \cs_new:Nn \@@_add_lua_option:nnn { @@ -1901,14 +1915,14 @@ interfaces and all the way up to the \LaTeX{} and \Hologo{ConTeXt} interfaces. \cs_new:Nn \@@_add_option:nnnn { - \seq_put_right:cn + \seq_gput_right:cn { g_@@_ #1 _options_seq } { #2 } - \prop_put:cnn + \prop_gput:cnn { g_@@_ #1 _option_types_prop } { #2 } { #3 } - \prop_put:cnn + \prop_gput:cnn { g_@@_default_ #1 _options_prop } { #2 } { #4 } @@ -1967,19 +1981,19 @@ interfaces and all the way up to the \LaTeX{} and \Hologo{ConTeXt} interfaces. { nnnV } \seq_new:N \g_@@_option_types_seq \tl_const:Nn \c_@@_option_type_clist_tl { clist } -\seq_put_right:NV \g_@@_option_types_seq \c_@@_option_type_clist_tl +\seq_gput_right:NV \g_@@_option_types_seq \c_@@_option_type_clist_tl \tl_const:Nn \c_@@_option_type_counter_tl { counter } -\seq_put_right:NV \g_@@_option_types_seq \c_@@_option_type_counter_tl +\seq_gput_right:NV \g_@@_option_types_seq \c_@@_option_type_counter_tl \tl_const:Nn \c_@@_option_type_boolean_tl { boolean } -\seq_put_right:NV \g_@@_option_types_seq \c_@@_option_type_boolean_tl +\seq_gput_right:NV \g_@@_option_types_seq \c_@@_option_type_boolean_tl \tl_const:Nn \c_@@_option_type_number_tl { number } -\seq_put_right:NV \g_@@_option_types_seq \c_@@_option_type_number_tl +\seq_gput_right:NV \g_@@_option_types_seq \c_@@_option_type_number_tl \tl_const:Nn \c_@@_option_type_path_tl { path } -\seq_put_right:NV \g_@@_option_types_seq \c_@@_option_type_path_tl +\seq_gput_right:NV \g_@@_option_types_seq \c_@@_option_type_path_tl \tl_const:Nn \c_@@_option_type_slice_tl { slice } -\seq_put_right:NV \g_@@_option_types_seq \c_@@_option_type_slice_tl +\seq_gput_right:NV \g_@@_option_types_seq \c_@@_option_type_slice_tl \tl_const:Nn \c_@@_option_type_string_tl { string } -\seq_put_right:NV \g_@@_option_types_seq \c_@@_option_type_string_tl +\seq_gput_right:NV \g_@@_option_types_seq \c_@@_option_type_string_tl \cs_new:Nn \@@_get_option_type:nN { @@ -2110,6 +2124,49 @@ interfaces and all the way up to the \LaTeX{} and \Hologo{ConTeXt} interfaces. \tl_tail:n { #1 } } } +\seq_new:N \g_@@_cases_seq +\cs_new:Nn \@@_with_various_cases:nn + { + \seq_clear:N + \l_tmpa_seq + \seq_map_inline:Nn + \g_@@_cases_seq + { + \tl_set:Nn + \l_tmpa_tl + { #1 } + \use:c { ##1 } + \l_tmpa_tl + \seq_put_right:NV + \l_tmpa_seq + \l_tmpa_tl + } + \seq_map_inline:Nn + \l_tmpa_seq + { #2 } + } +\cs_new:Nn \@@_camel_case:N + { + \regex_replace_all:nnN + { _ ([a-z]) } + { \c { str_uppercase:n } \cB\{ \1 \cE\} } + #1 + \tl_set:Nx + #1 + { #1 } + } +\seq_gput_right:Nn \g_@@_cases_seq { @@_camel_case:N } +\cs_new:Nn \@@_snake_case:N + { + \regex_replace_all:nnN + { ([a-z])([A-Z]) } + { \1 _ \c { str_lowercase:n } \cB\{ \2 \cE\} } + #1 + \tl_set:Nx + #1 + { #1 } + } +\seq_gput_right:Nn \g_@@_cases_seq { @@_snake_case:N } % \end{macrocode} % \iffalse %</tex> @@ -2461,13 +2518,13 @@ defaultOptions.contentBlocksLanguageMap = "markdown-languages.json" extensible subset of the \acro{peg} grammar of markdown % (see the \luamref{walkable_syntax} hash table) after built-in syntax extensions -% (see Section <#luabuiltinextensions>) +% (see Section <#sec:luabuiltinextensions>) % \iffalse (see options \Opt{citations}, \Opt{contentBlocks}, \Opt{definitionLists}, etc.) % \fi and user-defined syntax extensions -% (see Section <#luauserextensions>) +% (see Section <#sec:luauserextensions>) % \iffalse (see option \Opt{extensions}) % \fi @@ -3730,7 +3787,7 @@ following text, where the middot (`·`) denotes a non-breaking space: > > ### References > [1] Donald·Ervin Knuth. _The TeXbook, volume A of Computers and typesetting._ -> Addison-Wesley, 1984. +> Addison-Wesley, 1984. %</manual-options> %<*tex> @@ -3831,7 +3888,7 @@ following text: > > ### References > [1] Donald Ervin Knuth. _The \TeX{}book, volume A of Computers and typesetting._ -> Addison-Wesley, 1984. +> Addison-Wesley, 1984. %</manual-options> %<*tex> @@ -4257,23 +4314,23 @@ defaultOptions.contentBlocks = false % : true - : Produce a \acro{JSON} file that will contain the - extensible subset of the \acro{peg} grammar of markdown -% (see the \luamref{walkable_syntax} hash table) - after built-in syntax extensions -% (see Section <#luabuiltinextensions>) -% \iffalse - (see options \Opt{citations}, \Opt{contentBlocks}, - \Opt{definitionLists}, etc.) -% \fi - and user-defined syntax extensions -% (see Section <#luauserextensions>) -% \iffalse - (see option \Opt{extensions}) -% \fi - have been applied. This helps you to see how the different - extensions interact. The name of the produced \acro{JSON} file is - controlled by the \Opt{debugExtensionsFileName} option. + : Produce a \acro{JSON} file that will contain the + extensible subset of the \acro{peg} grammar of markdown +% (see the \luamref{walkable_syntax} hash table) + after built-in syntax extensions +% (see Section <#sec:luabuiltinextensions>) +% \iffalse + (see options \Opt{citations}, \Opt{contentBlocks}, + \Opt{definitionLists}, etc.) +% \fi + and user-defined syntax extensions +% (see Section <#sec:luauserextensions>) +% \iffalse + (see option \Opt{extensions}) +% \fi + have been applied. This helps you to see how the different + extensions interact. The name of the produced \acro{JSON} file is + controlled by the \Opt{debugExtensionsFileName} option. : false @@ -4290,7 +4347,7 @@ following content: ``` lua local strike_through = { api_version = 2, - grammar_version = 1, + grammar_version = 2, finalize_grammar = function(reader) local nonspacechar = lpeg.P(1) - lpeg.S("\t ") local doubleslashes = lpeg.P("//") @@ -4342,7 +4399,7 @@ be produced and contain the following text: "Block": [ "Blockquote", "Verbatim", - "HorizontalRule", + "ThematicBreak", "BulletList", "OrderedList", "Heading", @@ -4656,7 +4713,7 @@ defaultOptions.eagerCache = true % ``` lua % local strike_through = { % api_version = 2, -% grammar_version = 1, +% grammar_version = 2, % finalize_grammar = function(reader) % local nonspacechar = lpeg.P(1) - lpeg.S("\t ") % local doubleslashes = lpeg.P("//") @@ -4691,7 +4748,7 @@ defaultOptions.eagerCache = true % \fi % \begin{macrocode} metadata.user_extension_api_version = 2 -metadata.grammar_version = 1 +metadata.grammar_version = 2 % \end{macrocode} % \iffalse %</lua> @@ -4721,7 +4778,7 @@ following content: ``` lua local strike_through = { api_version = 2, - grammar_version = 1, + grammar_version = 2, finalize_grammar = function(reader) local nonspacechar = lpeg.P(1) - lpeg.S("\t ") local doubleslashes = lpeg.P("//") @@ -5087,11 +5144,11 @@ lualatex --shell-escape document.tex A PDF document named `document.pdf` should be produced and contain the following text: -> ~~~ js +> ``` js > if (a > 3) { > moveShip(5 * gravity, DOWN); > } -> ~~~~~~ +> ``` > > ``` html > <pre> @@ -5142,11 +5199,11 @@ context document.tex A PDF document named `document.pdf` should be produced and contain the following text: -> ~~~ js +> ``` js > if (a > 3) { > moveShip(5 * gravity, DOWN); > } -> ~~~~~~ +> ``` > > ``` html > <pre> @@ -5344,33 +5401,33 @@ defaultOptions.finalizeCache = false %</lua,lua-cli> %<*manual-options> -#### Option `footnotes` +#### Option `notes` -`footnotes` (default value: `false`) +`notes` (default value: `false`) % \fi % \begin{markdown} % -% \Optitem[false]{footnotes}{\opt{true}, \opt{false}} +% \Optitem[false]{notes}{\opt{true}, \opt{false}} % : true - : Enable the Pandoc footnote syntax extension: + : Enable the Pandoc note syntax extension: ``` md - Here is a footnote reference,[^1] and another.[^longnote] + Here is a note reference,[^1] and another.[^longnote] - [^1]: Here is the footnote. + [^1]: Here is the note. [^longnote]: Here's one with multiple blocks. Subsequent paragraphs are indented to show that they - belong to the previous footnote. + belong to the previous note. { some.code } The whole paragraph can be indented, or just the - first line. In this way, multi-paragraph footnotes + first line. In this way, multi-paragraph notes work like multi-paragraph list items. This paragraph won't be part of the note, because it @@ -5379,7 +5436,7 @@ defaultOptions.finalizeCache = false : false - : Disable the Pandoc footnote syntax extension. + : Disable the Pandoc note syntax extension. % \end{markdown} % \iffalse @@ -5390,22 +5447,22 @@ Using a text editor, create a text document named `document.tex` with the following content: ``` tex \documentclass{article} -\usepackage[footnotes]{markdown} +\usepackage[notes]{markdown} \begin{document} \begin{markdown} -Here is a footnote reference,[^1] and another.[^longnote] +Here is a note reference,[^1] and another.[^longnote] -[^1]: Here is the footnote. +[^1]: Here is the note. [^longnote]: Here's one with multiple blocks. Subsequent paragraphs are indented to show that they -belong to the previous footnote. +belong to the previous note. { some.code } The whole paragraph can be indented, or just the - first line. In this way, multi-paragraph footnotes + first line. In this way, multi-paragraph notes work like multi-paragraph list items. This paragraph won't be part of the note, because it @@ -5420,19 +5477,19 @@ 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] +> Here is a note reference,[^1] and another.[^longnote] > -> [^1]: Here is the footnote. +> [^1]: Here is the note. > > [^longnote]: Here's one with multiple blocks. > > Subsequent paragraphs are indented to show that they -> belong to the previous footnote. +> belong to the previous note. > > { some.code } > > The whole paragraph can be indented, or just the -> first line. In this way, multi-paragraph footnotes +> first line. In this way, multi-paragraph notes > work like multi-paragraph list items. > > This paragraph won't be part of the note, because it @@ -5444,22 +5501,22 @@ Using a text editor, create a text document named `document.tex` with the following content: ``` tex \usemodule[t][markdown] -\setupmarkdown[footnotes = yes] +\setupmarkdown[notes = yes] \starttext \startmarkdown -Here is a footnote reference,[^1] and another.[^longnote] +Here is a note reference,[^1] and another.[^longnote] -[^1]: Here is the footnote. +[^1]: Here is the note. [^longnote]: Here's one with multiple blocks. Subsequent paragraphs are indented to show that they -belong to the previous footnote. +belong to the previous note. { some.code } The whole paragraph can be indented, or just the - first line. In this way, multi-paragraph footnotes + first line. In this way, multi-paragraph notes work like multi-paragraph list items. This paragraph won't be part of the note, because it @@ -5474,19 +5531,19 @@ 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] +> Here is a note reference,[^1] and another.[^longnote] > -> [^1]: Here is the footnote. +> [^1]: Here is the note. > > [^longnote]: Here's one with multiple blocks. > > Subsequent paragraphs are indented to show that they -> belong to the previous footnote. +> belong to the previous note. > > { some.code } > > The whole paragraph can be indented, or just the -> first line. In this way, multi-paragraph footnotes +> first line. In this way, multi-paragraph notes > work like multi-paragraph list items. > > This paragraph won't be part of the note, because it @@ -5495,11 +5552,21 @@ following text: %</manual-options> %<*tex> % \fi +% \begin{markdown} +% +% The footnotes option has been deprecated and will be removed in +% Markdown 3.0.0. +% +% \end{markdown} % \begin{macrocode} \@@_add_lua_option:nnn { footnotes } { boolean } { false } +\@@_add_lua_option:nnn + { notes } + { boolean } + { false } % \end{macrocode} % \iffalse %</tex> @@ -5507,6 +5574,7 @@ following text: % \fi % \begin{macrocode} defaultOptions.footnotes = false +defaultOptions.notes = false % \end{macrocode} % \par % \iffalse @@ -6321,18 +6389,18 @@ defaultOptions.hybrid = false %</lua,lua-cli> %<*manual-options> -#### Option `inlineFootnotes` +#### Option `inlineNotes` -`inlineFootnotes` (default value: `false`) +`inlineNotes` (default value: `false`) % \fi % \begin{markdown} % -% \Optitem[false]{inlineFootnotes}{\opt{true}, \opt{false}} +% \Optitem[false]{inlineNotes}{\opt{true}, \opt{false}} % : true - : Enable the Pandoc inline footnote syntax extension: + : Enable the Pandoc inline note syntax extension: ``` md Here is an inline note.^[Inlines notes are easier to @@ -6342,7 +6410,7 @@ defaultOptions.hybrid = false : false - : Disable the Pandoc inline footnote syntax extension. + : Disable the Pandoc inline note syntax extension. % \end{markdown} % \iffalse @@ -6353,7 +6421,7 @@ Using a text editor, create a text document named `document.tex` with the following content: ``` tex \documentclass{article} -\usepackage[inlineFootnotes]{markdown} +\usepackage[inlineNotes]{markdown} \begin{document} \begin{markdown} Here is an inline note.^[Inlines notes are easier to @@ -6379,7 +6447,7 @@ Using a text editor, create a text document named `document.tex` with the following content: ``` tex \usemodule[t][markdown] -\setupmarkdown[inlineFootnotes = yes] +\setupmarkdown[inlineNotes = yes] \starttext \startmarkdown Here is an inline note.^[Inlines notes are easier to @@ -6402,11 +6470,21 @@ following text: %</manual-options> %<*tex> % \fi +% \begin{markdown} +% +% The inlineFootnotes option has been deprecated and will be removed in +% Markdown 3.0.0. +% +% \end{markdown} % \begin{macrocode} \@@_add_lua_option:nnn { inlineFootnotes } { boolean } { false } +\@@_add_lua_option:nnn + { inlineNotes } + { boolean } + { false } % \end{macrocode} % \iffalse %</tex> @@ -6414,6 +6492,7 @@ following text: % \fi % \begin{macrocode} defaultOptions.inlineFootnotes = false +defaultOptions.inlineNotes = false % \end{macrocode} % \par % \iffalse @@ -6733,6 +6812,97 @@ defaultOptions.preserveTabs = false %</lua,lua-cli> %<*manual-options> +#### Option `rawAttribute` + +`rawAttribute` (default value: `false`) + +% \fi +% \begin{markdown} +% +% \Optitem[false]{rawAttribute}{\opt{true}, \opt{false}} +% +: true + + : Enable the Pandoc raw attribute syntax extension: + + ``` md + `$H_2 O$`{=tex} is a liquid. + ``` + + To enable raw blocks, the \Opt{fencedCode} option must also be enabled: + + ~~~~~~~~ md + Here is a mathematical formula: + ``` {=tex} + \[distance[i] = + \begin{dcases} + a & b \\ + c & d + \end{dcases} + \] + ``` + ~~~~~~~~~~~ + + The \Opt{rawAttribute} option is a good alternative to the \Opt{hybrid} + option. Unlike the \Opt{hybrid} option, which affects the entire + document, the \Opt{rawAttribute} option allows you to isolate the parts + of your documents that use TeX: + +: false + + : Disable the Pandoc raw attribute syntax extension. + +% \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[rawAttribute, fencedCode]{markdown} +\usepackage{expl3} +\begin{document} +\begin{markdown} +`$H_2 O$`{=tex} is a liquid. + +``` {=html} +<p>Here is some HTML content that will be ignored.</p> +``` +\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: + +> H~2~O is a liquid. + +%</manual-options> +%<*tex> +% \fi +% \begin{macrocode} +\@@_add_lua_option:nnn + { rawAttribute } + { boolean } + { false } +% \end{macrocode} +% \iffalse +%</tex> +%<*lua,lua-cli> +% \fi +% \begin{macrocode} +defaultOptions.rawAttribute = true +% \end{macrocode} +% \par +% \iffalse +%</lua,lua-cli> +%<*manual-options> + #### Option `relativeReferences` `relativeReferences` (default value: `false`) @@ -7977,7 +8147,7 @@ following content: | 123 | 123 | 123 | 123 | | 1 | 1 | 1 | 1 | - : Demonstration of pipe table syntax. +: Demonstration of pipe table syntax. \end{markdown} \end{document} ``````` @@ -7994,7 +8164,7 @@ following text: > | 123 | 123 | 123 | 123 | > | 1 | 1 | 1 | 1 | > -> : Demonstration of pipe table syntax. +> : Demonstration of pipe table syntax. ##### \Hologo{ConTeXt} Example {.unnumbered} @@ -8015,7 +8185,7 @@ following content: | 123 | 123 | 123 | 123 | | 1 | 1 | 1 | 1 | - : Demonstration of pipe table syntax. +: Demonstration of pipe table syntax. \stopmarkdown \stoptext ```````` @@ -8032,7 +8202,7 @@ following text: > | 123 | 123 | 123 | 123 | > | 1 | 1 | 1 | 1 | > -> : Demonstration of pipe table syntax. +> : Demonstration of pipe table syntax. %</manual-options> %<*tex> @@ -8330,25 +8500,25 @@ following content: \begin{markdown} The following list is tight: - - first item - - second item - - third item +- first item +- second item +- third item The following list is loose: - - first item - - second item that spans +- first item +- second item that spans - multiple paragraphs - - third item + multiple paragraphs +- third item \end{markdown} \begin{markdown*}{tightLists=false} The following list is now also loose: - - first item - - second item - - third item +- first item +- second item +- third item \end{markdown*} \end{document} @@ -8362,25 +8532,25 @@ following text: > The following list is tight: > -> - first item -> - second item -> - third item +> - first item +> - second item +> - third item > > The following list is loose: > -> - first item -> - second item that spans +> - first item +> - second item that spans > -> multiple paragraphs -> - third item +> multiple paragraphs +> - third item > > The following list is now also loose: > -> - first item +> - first item > -> - second item +> - second item > -> - third item +> - third item %</manual-options> %<*tex> @@ -8633,7 +8803,40 @@ local function warn(s) local function error(s) io.stderr:write("Error: " .. s .. "\n") - os.exit(1) end + os.exit(1) +end +% \end{macrocode} +% \begin{markdown} +% +% To make it easier to copy-and-paste options from Pandoc [@macfarlane22] such +% as `fancy_lists`, `header_attributes`, and `pipe_tables`, we accept +% snake\\\_case in addition to camelCase variants of options. As a bonus, +% studies [@sharif10] also show that snake\\\_case is faster to read than +% camelCase. +% +% \end{markdown} +% \begin{macrocode} +local function camel_case(option_name) + local cased_option_name = option_name:gsub("_(%l)", function(match) + return match:sub(2, 2):upper() + end) + return cased_option_name +end + +local function snake_case(option_name) + local cased_option_name = option_name:gsub("%l%u", function(match) + return match:sub(1, 1) .. "_" .. match:sub(2, 2):lower() + end) + return cased_option_name +end + +local cases = {camel_case, snake_case} +local various_case_options = {} +for option_name, _ in pairs(defaultOptions) do + for _, case in ipairs(cases) do + various_case_options[case(option_name)] = option_name + end +end local process_options = true local options = {} @@ -8662,10 +8865,13 @@ for i = 1, #arg do % \begin{macrocode} elseif arg[i]:match("=") then local key, value = arg[i]:match("(.-)=(.*)") + if defaultOptions[key] == nil then + key = various_case_options[key] + end % \end{macrocode} % \begin{markdown} % The \luamref{defaultOptions} table is consulted to identify whether \meta{value} -% should be parsed as a string or as a boolean. +% should be parsed as a string, number, table, or boolean. % \end{markdown} % \begin{macrocode} local default_type = type(defaultOptions[key]) @@ -8840,8 +9046,8 @@ pdftex --shell-escape document.tex % %### Typesetting Markdown {#textypesetting} % -% The interface exposes the \mdef{markdownBegin}, \mdef{markdownEnd}, and -% \mdef{markdownInput} macros. +% The interface exposes the \mdef{markdownBegin}, \mdef{markdownEnd}, +% \mdef{markdownInput}, and \mdef{markdownEscape} macros. % % The \mref{markdownBegin} macro marks the beginning of a markdown document % fragment and the \mref{markdownEnd} macro marks its end. @@ -8899,9 +9105,9 @@ pdftex --shell-escape document.tex % \bye % ``````` % -% The \mref{markdownInput} macro accepts a single parameter containing the -% filename of a markdown document and expands to the result of the conversion -% of the input markdown document to plain \TeX{}. +% The \mref{markdownInput} macro accepts a single parameter with the filename +% of a markdown document and expands to the result of the conversion of the +% input markdown document to plain \TeX{}. % % \end{markdown} % \begin{macrocode} @@ -8922,6 +9128,19 @@ pdftex --shell-escape document.tex % \bye % ``````` % +% The \mref{markdownEscape} macro accepts a single parameter with the filename +% of a \TeX{} document and executes the \TeX{} document in the middle of a +% markdown document fragment. Unlike the `\input` built-in of \TeX, +% \mref{markdownEscape} guarantees that the standard catcode regime of your +% \TeX{} format will be used. +% +% \end{markdown} +% \begin{macrocode} +\let\markdownEscape\relax +% \end{macrocode} +% \par +% \begin{markdown} +% %### Options {#texoptions} % % The plain \TeX{} options are represented by \TeX{} commands. Some of them map @@ -8948,7 +9167,7 @@ pdftex --shell-escape document.tex \prop_new:N \g_@@_plain_tex_option_types_prop \prop_new:N \g_@@_default_plain_tex_options_prop \tl_const:Nn \c_@@_option_layer_plain_tex_tl { plain_tex } -\seq_put_right:NV \g_@@_option_layers_seq \c_@@_option_layer_plain_tex_tl +\seq_gput_right:NV \g_@@_option_layers_seq \c_@@_option_layer_plain_tex_tl \cs_new:Nn \@@_add_plain_tex_option:nnn { @@ -9400,14 +9619,14 @@ A PDF document named `document.pdf` should be produced and contain the text % % \end{markdown} % \begin{macrocode} -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_plain_tex_options_seq { stripPercentSigns } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_plain_tex_option_types_prop { stripPercentSigns } { boolean } -\prop_put:Nnx +\prop_gput:Nnx \g_@@_default_plain_tex_options_prop { stripPercentSigns } { false } @@ -9553,10 +9772,10 @@ following text: \def\markdownRendererTickedBox{% \markdownRendererTickedBoxPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { tickedBox } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { tickedBox } { 0 } @@ -9564,10 +9783,10 @@ following text: \def\markdownRendererHalfTickedBox{% \markdownRendererHalfTickedBoxPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { halfTickedBox } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { halfTickedBox } { 0 } @@ -9575,10 +9794,10 @@ following text: \def\markdownRendererUntickedBox{% \markdownRendererUntickedBoxPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { untickedBox } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { untickedBox } { 0 } @@ -9717,10 +9936,10 @@ following text: \def\markdownRendererDocumentBegin{% \markdownRendererDocumentBeginPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { documentBegin } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { documentBegin } { 0 } @@ -9728,10 +9947,10 @@ following text: \def\markdownRendererDocumentEnd{% \markdownRendererDocumentEndPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { documentEnd } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { documentEnd } { 0 } @@ -9862,10 +10081,10 @@ following text: \def\markdownRendererInterblockSeparator{% \markdownRendererInterblockSeparatorPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { interblockSeparator } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { interblockSeparator } { 0 } @@ -10008,10 +10227,10 @@ following text: \def\markdownRendererLineBreak{% \markdownRendererLineBreakPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { lineBreak } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { lineBreak } { 0 } @@ -10119,10 +10338,10 @@ following text: \def\markdownRendererEllipsis{% \markdownRendererEllipsisPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { ellipsis } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { ellipsis } { 0 } @@ -10194,7 +10413,7 @@ following text: > > ### References > [1] Donald Ervin Knuth. _The TeXbook, volume A of Computers and typesetting._ -> Addison-Wesley, 1984. +> Addison-Wesley, 1984. %</manual-tokens> %<*tex> @@ -10204,10 +10423,10 @@ following text: \def\markdownRendererNbsp{% \markdownRendererNbspPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { nbsp } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { nbsp } { 0 } @@ -10329,10 +10548,10 @@ following text, where the middot (`·`) denotes a non-breaking space: \def\markdownRendererLeftBrace{% \markdownRendererLeftBracePrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { leftBrace } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { leftBrace } { 0 } @@ -10340,10 +10559,10 @@ following text, where the middot (`·`) denotes a non-breaking space: \def\markdownRendererRightBrace{% \markdownRendererRightBracePrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { rightBrace } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { rightBrace } { 0 } @@ -10351,10 +10570,10 @@ following text, where the middot (`·`) denotes a non-breaking space: \def\markdownRendererDollarSign{% \markdownRendererDollarSignPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { dollarSign } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { dollarSign } { 0 } @@ -10362,10 +10581,10 @@ following text, where the middot (`·`) denotes a non-breaking space: \def\markdownRendererPercentSign{% \markdownRendererPercentSignPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { percentSign } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { percentSign } { 0 } @@ -10373,10 +10592,10 @@ following text, where the middot (`·`) denotes a non-breaking space: \def\markdownRendererAmpersand{% \markdownRendererAmpersandPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { ampersand } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { ampersand } { 0 } @@ -10384,10 +10603,10 @@ following text, where the middot (`·`) denotes a non-breaking space: \def\markdownRendererUnderscore{% \markdownRendererUnderscorePrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { underscore } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { underscore } { 0 } @@ -10395,10 +10614,10 @@ following text, where the middot (`·`) denotes a non-breaking space: \def\markdownRendererHash{% \markdownRendererHashPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { hash } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { hash } { 0 } @@ -10406,10 +10625,10 @@ following text, where the middot (`·`) denotes a non-breaking space: \def\markdownRendererCircumflex{% \markdownRendererCircumflexPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { circumflex } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { circumflex } { 0 } @@ -10417,10 +10636,10 @@ following text, where the middot (`·`) denotes a non-breaking space: \def\markdownRendererBackslash{% \markdownRendererBackslashPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { backslash } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { backslash } { 0 } @@ -10428,10 +10647,10 @@ following text, where the middot (`·`) denotes a non-breaking space: \def\markdownRendererTilde{% \markdownRendererTildePrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { tilde } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { tilde } { 0 } @@ -10439,10 +10658,10 @@ following text, where the middot (`·`) denotes a non-breaking space: \def\markdownRendererPipe{% \markdownRendererPipePrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { pipe } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { pipe } { 0 } @@ -10458,8 +10677,8 @@ following text, where the middot (`·`) denotes a non-breaking space: % \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 +The \mdef{markdownRendererCodeSpan} macro represents inline code span in the +input text. It receives a single argument that corresponds to the inline code span. % \end{markdown} @@ -10584,10 +10803,10 @@ following text: \def\markdownRendererCodeSpan{% \markdownRendererCodeSpanPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { codeSpan } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { codeSpan } { 1 } @@ -10708,10 +10927,10 @@ following text: \def\markdownRendererLink{% \markdownRendererLinkPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { link } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { link } { 4 } @@ -10788,7 +11007,7 @@ 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") +> ![TUGboat](https://tug.org/tugboat/noword.jpg "The Communications of the TeX Users Group") %</manual-tokens> %<*tex> @@ -10798,10 +11017,10 @@ that the \TeX{} engine has shell access. \def\markdownRendererImage{% \markdownRendererImagePrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { image } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { image } { 4 } @@ -10835,10 +11054,10 @@ and the title of the content block. \def\markdownRendererContentBlock{% \markdownRendererContentBlockPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { contentBlock } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { contentBlock } { 4 } @@ -10868,10 +11087,10 @@ as \mref{markdownRendererContentBlock}. \def\markdownRendererContentBlockOnlineImage{% \markdownRendererContentBlockOnlineImagePrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { contentBlockOnlineImage } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { contentBlockOnlineImage } { 4 } @@ -10889,8 +11108,8 @@ as \mref{markdownRendererContentBlock}. 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{Filenames other than `markdown-languages.json` may -be specified using the `contentBlocksLanguageMap` Lua option.} contains a +by \pkg{kpathsea}^[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$. @@ -11063,10 +11282,10 @@ following text: \def\markdownRendererContentBlockCode{% \markdownRendererContentBlockCodePrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { contentBlockCode } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { contentBlockCode } { 5 } @@ -11097,10 +11316,10 @@ list is not tight). The macro receives no arguments. \def\markdownRendererUlBegin{% \markdownRendererUlBeginPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { ulBegin } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { ulBegin } { 0 } @@ -11131,10 +11350,10 @@ is disabled. The macro receives no arguments. \def\markdownRendererUlBeginTight{% \markdownRendererUlBeginTightPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { ulBeginTight } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { ulBeginTight } { 0 } @@ -11163,10 +11382,10 @@ list. The macro receives no arguments. \def\markdownRendererUlItem{% \markdownRendererUlItemPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { ulItem } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { ulItem } { 0 } @@ -11195,10 +11414,10 @@ bulleted list. The macro receives no arguments. \def\markdownRendererUlItemEnd{% \markdownRendererUlItemEndPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { ulItemEnd } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { ulItemEnd } { 0 } @@ -11228,10 +11447,10 @@ tight). The macro receives no arguments. \def\markdownRendererUlEnd{% \markdownRendererUlEndPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { ulEnd } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { ulEnd } { 0 } @@ -11464,10 +11683,10 @@ following text: \def\markdownRendererUlEndTight{% \markdownRendererUlEndTightPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { ulEndTight } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { ulEndTight } { 0 } @@ -11499,10 +11718,10 @@ option is disabled. The macro receives no arguments. \def\markdownRendererOlBegin{% \markdownRendererOlBeginPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { olBegin } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { olBegin } { 0 } @@ -11534,10 +11753,10 @@ receives no arguments. \def\markdownRendererOlBeginTight{% \markdownRendererOlBeginTightPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { olBeginTight } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { olBeginTight } { 0 } @@ -11571,10 +11790,10 @@ and the style of delimiters between list item labels and texts (`Default`, \def\markdownRendererFancyOlBegin{% \markdownRendererFancyOlBeginPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { fancyOlBegin } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { fancyOlBegin } { 2 } @@ -11608,10 +11827,10 @@ the valid style values. \def\markdownRendererFancyOlBeginTight{% \markdownRendererFancyOlBeginTightPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { fancyOlBeginTight } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { fancyOlBeginTight } { 2 } @@ -11642,10 +11861,10 @@ arguments. \def\markdownRendererOlItem{% \markdownRendererOlItemPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { olItem } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { olItem } { 0 } @@ -11675,10 +11894,10 @@ option is disabled. The macro receives no arguments. \def\markdownRendererOlItemEnd{% \markdownRendererOlItemEndPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { olItemEnd } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { olItemEnd } { 0 } @@ -11709,10 +11928,10 @@ receives a single numeric argument that corresponds to the item number. \def\markdownRendererOlItemWithNumber{% \markdownRendererOlItemWithNumberPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { olItemWithNumber } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { olItemWithNumber } { 1 } @@ -11743,10 +11962,10 @@ no arguments. \def\markdownRendererFancyOlItem{% \markdownRendererFancyOlItemPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { fancyOlItem } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { fancyOlItem } { 0 } @@ -11776,10 +11995,10 @@ option is enabled. The macro receives no arguments. \def\markdownRendererFancyOlItemEnd{% \markdownRendererFancyOlItemEndPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { fancyOlItemEnd } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { fancyOlItemEnd } { 0 } @@ -11810,10 +12029,10 @@ argument that corresponds to the item number. \def\markdownRendererFancyOlItemWithNumber{% \markdownRendererFancyOlItemWithNumberPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { fancyOlItemWithNumber } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { fancyOlItemWithNumber } { 1 } @@ -11844,10 +12063,10 @@ disabled. The macro receives no arguments. \def\markdownRendererOlEnd{% \markdownRendererOlEndPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { olEnd } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { olEnd } { 0 } @@ -11879,10 +12098,10 @@ arguments. \def\markdownRendererOlEndTight{% \markdownRendererOlEndTightPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { olEndTight } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { olEndTight } { 0 } @@ -11913,10 +12132,10 @@ option is enabled. The macro receives no arguments. \def\markdownRendererFancyOlEnd{% \markdownRendererFancyOlEndPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { fancyOlEnd } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { fancyOlEnd } { 0 } @@ -12204,10 +12423,10 @@ following text: \def\markdownRendererFancyOlEndTight{% \markdownRendererFancyOlEndTightPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { fancyOlEndTight } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { fancyOlEndTight } { 0 } @@ -12241,10 +12460,10 @@ list is not tight). The macro receives no arguments. \def\markdownRendererDlBegin{% \markdownRendererDlBeginPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { dlBegin } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { dlBegin } { 0 } @@ -12275,10 +12494,10 @@ list is not tight). This macro will only be produced, when the \def\markdownRendererDlBeginTight{% \markdownRendererDlBeginTightPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { dlBeginTight } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { dlBeginTight } { 0 } @@ -12308,10 +12527,10 @@ being defined. \def\markdownRendererDlItem{% \markdownRendererDlItemPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { dlItem } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { dlItem } { 1 } @@ -12340,10 +12559,10 @@ definitions for a single term. \def\markdownRendererDlItemEnd{% \markdownRendererDlItemEndPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { dlItemEnd } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { dlItemEnd } { 0 } @@ -12373,10 +12592,10 @@ a single term. \def\markdownRendererDlDefinitionBegin{% \markdownRendererDlDefinitionBeginPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { dlDefinitionBegin } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { dlDefinitionBegin } { 0 } @@ -12406,10 +12625,10 @@ single term. \def\markdownRendererDlDefinitionEnd{% \markdownRendererDlDefinitionEndPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { dlDefinitionEnd } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { dlDefinitionEnd } { 0 } @@ -12439,10 +12658,10 @@ tight). The macro receives no arguments. \def\markdownRendererDlEnd{% \markdownRendererDlEndPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { dlEnd } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { dlEnd } { 0 } @@ -12808,10 +13027,10 @@ following text: \def\markdownRendererDlEndTight{% \markdownRendererDlEndTightPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { dlEndTight } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { dlEndTight } { 0 } @@ -12928,10 +13147,10 @@ following text: \def\markdownRendererEmphasis{% \markdownRendererEmphasisPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { emphasis } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { emphasis } { 1 } @@ -12961,10 +13180,10 @@ corresponds to the emphasized span of text. \def\markdownRendererStrongEmphasis{% \markdownRendererStrongEmphasisPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { strongEmphasis } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { strongEmphasis } { 1 } @@ -12994,10 +13213,10 @@ a block quote. The macro receives no arguments. \def\markdownRendererBlockQuoteBegin{% \markdownRendererBlockQuoteBeginPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { blockQuoteBegin } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { blockQuoteBegin } { 0 } @@ -13139,10 +13358,10 @@ following text: \def\markdownRendererBlockQuoteEnd{% \markdownRendererBlockQuoteEndPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { blockQuoteEnd } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { blockQuoteEnd } { 0 } @@ -13173,10 +13392,10 @@ filename of a file contaning the code block contents. \def\markdownRendererInputVerbatim{% \markdownRendererInputVerbatimPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { inputVerbatim } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { inputVerbatim } { 1 } @@ -13289,10 +13508,10 @@ following text except for the filename, which may differ: \def\markdownRendererInputFencedCode{% \markdownRendererInputFencedCodePrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { inputFencedCode } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { inputFencedCode } { 2 } @@ -13323,10 +13542,10 @@ option is enabled. The macro receives no arguments. \def\markdownRendererJekyllDataBegin{% \markdownRendererJekyllDataBeginPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { jekyllDataBegin } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { jekyllDataBegin } { 0 } @@ -13356,10 +13575,10 @@ The \mdef{markdownRendererJekyllDataEnd} macro represents the end of a \def\markdownRendererJekyllDataEnd{% \markdownRendererJekyllDataEndPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { jekyllDataEnd } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { jekyllDataEnd } { 0 } @@ -13391,10 +13610,10 @@ arguments: the scalar key in the parent structure, cast to a string following \def\markdownRendererJekyllDataMappingBegin{% \markdownRendererJekyllDataMappingBeginPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { jekyllDataMappingBegin } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { jekyllDataMappingBegin } { 2 } @@ -13424,10 +13643,10 @@ when the \Opt{jekyllData} option is enabled. The macro receives no arguments. \def\markdownRendererJekyllDataMappingEnd{% \markdownRendererJekyllDataMappingEndPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { jekyllDataMappingEnd } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { jekyllDataMappingEnd } { 0 } @@ -13459,10 +13678,10 @@ arguments: the scalar key in the parent structure, cast to a string following \def\markdownRendererJekyllDataSequenceBegin{% \markdownRendererJekyllDataSequenceBeginPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { jekyllDataSequenceBegin } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { jekyllDataSequenceBegin } { 2 } @@ -13492,10 +13711,10 @@ when the \Opt{jekyllData} option is enabled. The macro receives no arguments. \def\markdownRendererJekyllDataSequenceEnd{% \markdownRendererJekyllDataSequenceEndPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { jekyllDataSequenceEnd } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { jekyllDataSequenceEnd } { 0 } @@ -13527,10 +13746,10 @@ following \acro{yaml} serialization rules. \def\markdownRendererJekyllDataBoolean{% \markdownRendererJekyllDataBooleanPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { jekyllDataBoolean } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { jekyllDataBoolean } { 2 } @@ -13562,10 +13781,10 @@ following \acro{yaml} serialization rules. \def\markdownRendererJekyllDataNumber{% \markdownRendererJekyllDataNumberPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { jekyllDataNumber } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { jekyllDataNumber } { 2 } @@ -13597,10 +13816,10 @@ serialization rules, and the scalar value. \def\markdownRendererJekyllDataString{% \markdownRendererJekyllDataStringPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { jekyllDataString } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { jekyllDataString } { 2 } @@ -13636,10 +13855,10 @@ serialization rules. \def\markdownRendererJekyllDataEmpty{% \markdownRendererJekyllDataEmptyPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { jekyllDataEmpty } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { jekyllDataEmpty } { 1 } @@ -13763,10 +13982,10 @@ The macro receives a single argument that corresponds to the heading text. \def\markdownRendererHeadingOne{% \markdownRendererHeadingOnePrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { headingOne } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { headingOne } { 1 } @@ -13796,10 +14015,10 @@ text. \def\markdownRendererHeadingTwo{% \markdownRendererHeadingTwoPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { headingTwo } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { headingTwo } { 1 } @@ -13829,10 +14048,10 @@ text. \def\markdownRendererHeadingThree{% \markdownRendererHeadingThreePrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { headingThree } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { headingThree } { 1 } @@ -13862,10 +14081,10 @@ text. \def\markdownRendererHeadingFour{% \markdownRendererHeadingFourPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { headingFour } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { headingFour } { 1 } @@ -13895,10 +14114,10 @@ text. \def\markdownRendererHeadingFive{% \markdownRendererHeadingFivePrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { headingFive } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { headingFive } { 1 } @@ -14029,10 +14248,10 @@ following text: \def\markdownRendererHeadingSix{% \markdownRendererHeadingSixPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { headingSix } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { headingSix } { 1 } @@ -14047,8 +14266,8 @@ following text: % % \begin{markdown} -#### Horizontal Rule Renderer -The \mdef{markdownRendererHorizontalRule} macro represents a horizontal rule. +#### Thematic Break Renderer +The \mdef{markdownRendererThematicBreak} macro represents a thematic break. The macro receives no arguments. % \end{markdown} @@ -14061,7 +14280,7 @@ Using a text editor, create a text document named `document.tex` with the following content: ``` tex \input markdown -\def\markdownRendererHorizontalRule{\vfil\break} +\def\markdownRendererThematicBreak{\vfil\break} \markdownBegin This is the first page. @@ -14093,7 +14312,7 @@ following content: \usepackage{markdown} \markdownSetup{ renderers = { - horizontalRule = \newpage, + thematicBreak = \newpage, }, } \begin{document} @@ -14125,7 +14344,7 @@ Using a text editor, create a text document named `document.tex` with the following content: ``` tex \usemodule[t][markdown] -\def\markdownRendererHorizontalRule{\page[yes]} +\def\markdownRendererThematicBreak{\page[yes]} \starttext \startmarkdown This is the first page. @@ -14152,18 +14371,58 @@ following text: %</manual-tokens> %<*tex> % \fi +% \begin{markdown} +% +% The \mdef{markdownRendererHorizontalRule} and +% \mdef{markdownRendererHorizontalRulePrototype} macros have been deprecated +% and will be removed in Markdown 3.0.0. % +% \end{markdown} % \begin{macrocode} -\def\markdownRendererHorizontalRule{% - \markdownRendererHorizontalRulePrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\cs_new:Npn + \markdownRendererThematicBreak + { + \cs_if_exist:NTF + \markdownRendererHorizontalRule + { + \markdownWarning + { + Horizontal~rule~renderer~has~been~deprecated,~ + to~be~removed~in~Markdown~3.0.0 + } + \markdownRendererHorizontalRule + } + { + \cs_if_exist:NTF + \markdownRendererHorizontalRulePrototype + { + \markdownWarning + { + Horizontal~rule~renderer~prototype~has~been~deprecated,~ + to~be~removed~in~Markdown~3.0.0 + } + \markdownRendererHorizontalRulePrototype + } + { + \markdownRendererThematicBreakPrototype + } + } + } +\seq_gput_right:Nn \g_@@_renderers_seq { horizontalRule } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { horizontalRule } { 0 } +\seq_gput_right:Nn + \g_@@_renderers_seq + { thematicBreak } +\prop_gput:Nnn + \g_@@_renderer_arities_prop + { thematicBreak } + { 0 } \ExplSyntaxOff % \end{macrocode} % \par @@ -14175,10 +14434,10 @@ following text: % % \begin{markdown} -#### Footnote Renderer -The \mdef{markdownRendererFootnote} macro represents a footnote. This macro -will only be produced, when the \Opt{footnotes} option is enabled. The -macro receives a single argument that corresponds to the footnote text. +#### Note Renderer +The \mdef{markdownRendererNote} macro represents a note. This macro +will only be produced, when the \Opt{notes} option is enabled. The +macro receives a single argument that corresponds to the note text. % \end{markdown} % @@ -14190,14 +14449,14 @@ 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})} +\def\markdownOptionNotes{true} +\def\markdownRendererNote#1{ (and \lowercase{#1})} \markdownBegin This is some text[^1] and this is some other text[^2]. - [^1]: this is a footnote + [^1]: this is a note - [^2]: this is some other footnote + [^2]: this is some other note \markdownEnd \bye ``````` @@ -14208,8 +14467,8 @@ 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). +> This is some text (and this is a note) and this is some other +> text (and this is some other note). ##### \LaTeX{} Example {.unnumbered} @@ -14217,19 +14476,19 @@ Using a text editor, create a text document named `document.tex` with the following content: ``` tex \documentclass{article} -\usepackage[footnotes]{markdown} +\usepackage[notes]{markdown} \markdownSetup{ renderers = { - footnote = { (and \MakeLowercase{#1})}, + note = { (and \MakeLowercase{#1})}, }, } \begin{document} \begin{markdown} This is some text[^1] and this is some other text[^2]. - [^1]: this is a footnote + [^1]: this is a note - [^2]: this is some other footnote + [^2]: this is some other note \end{markdown} \end{document} ``````` @@ -14240,8 +14499,8 @@ 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). +> This is some text (and this is a note) and this is some other +> text (and this is some other note). ##### \Hologo{ConTeXt} Example {.unnumbered} @@ -14249,15 +14508,15 @@ Using a text editor, create a text document named `document.tex` with the following content: ``` tex \usemodule[t][markdown] -\setupmarkdown[footnotes = yes] -\def\markdownRendererFootnote#1{ (and \lowercase{#1})} +\setupmarkdown[notes = yes] +\def\markdownRendererNote#1{ (and \lowercase{#1})} \starttext \startmarkdown This is some text[^1] and this is some other text[^2]. - [^1]: this is a footnote + [^1]: this is a note - [^2]: this is some other footnote + [^2]: this is some other note \stopmarkdown \stoptext ``````` @@ -14268,24 +14527,64 @@ 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). +> This is some text (and this is a note) and this is some other +> text (and this is some other note). %</manual-tokens> %<*tex> % \fi +% \begin{markdown} +% +% The \mdef{markdownRendererFootnote} and +% \mdef{markdownRendererFootnotePrototype} macros have been deprecated +% and will be removed in Markdown 3.0.0. % +% \end{markdown} % \begin{macrocode} -\def\markdownRendererFootnote{% - \markdownRendererFootnotePrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\cs_new:Npn + \markdownRendererNote + { + \cs_if_exist:NTF + \markdownRendererFootnote + { + \markdownWarning + { + Footnote~renderer~has~been~deprecated,~ + to~be~removed~in~Markdown~3.0.0 + } + \markdownRendererFootnote + } + { + \cs_if_exist:NTF + \markdownRendererFootnotePrototype + { + \markdownWarning + { + Footnote~renderer~prototype~has~been~deprecated,~ + to~be~removed~in~Markdown~3.0.0 + } + \markdownRendererFootnotePrototype + } + { + \markdownRendererNotePrototype + } + } + } +\seq_gput_right:Nn \g_@@_renderers_seq { footnote } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { footnote } { 1 } +\seq_gput_right:Nn + \g_@@_renderers_seq + { note } +\prop_gput:Nnn + \g_@@_renderer_arities_prop + { note } + { 1 } \ExplSyntaxOff % \end{macrocode} % \par @@ -14376,10 +14675,10 @@ following text: \def\markdownRendererCite{% \markdownRendererCitePrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { cite } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { cite } { 1 } @@ -14468,10 +14767,10 @@ following text: \def\markdownRendererTextCite{% \markdownRendererTextCitePrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { textCite } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { textCite } { 1 } @@ -14595,10 +14894,10 @@ following text: \def\markdownRendererTable{% \markdownRendererTablePrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { table } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { table } { 3 } @@ -14647,7 +14946,7 @@ following content: \begin{markdown} A useful use of inline HTML comments are side notes. <!-- Side notes are displayed in the horizontal margins next to the relevant -passages, which makes them *easier for the reader to find* than footnotes. --> +passages, which makes them *easier for the reader to find* than notes. --> We can render block HTML comments as blockquotes: @@ -14679,7 +14978,7 @@ following body text: The horizontal margins should contain the following text: > Side notes are displayed in the horizontal margins next to the relevant -> passages, which makes them *easier for the reader to find* than footnotes. +> passages, which makes them *easier for the reader to find* than notes. %</manual-tokens> %<*tex> @@ -14689,10 +14988,10 @@ The horizontal margins should contain the following text: \def\markdownRendererInlineHtmlComment{% \markdownRendererInlineHtmlCommentPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { inlineHtmlComment } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { inlineHtmlComment } { 1 } @@ -14700,10 +14999,10 @@ The horizontal margins should contain the following text: \def\markdownRendererBlockHtmlCommentBegin{% \markdownRendererBlockHtmlCommentBeginPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { blockHtmlCommentBegin } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { blockHtmlCommentBegin } { 0 } @@ -14711,10 +15010,10 @@ The horizontal margins should contain the following text: \def\markdownRendererBlockHtmlCommentEnd{% \markdownRendererBlockHtmlCommentEndPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { blockHtmlCommentEnd } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { blockHtmlCommentEnd } { 0 } @@ -14788,10 +15087,10 @@ following body text: \def\markdownRendererInlineHtmlTag{% \markdownRendererInlineHtmlTagPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { inlineHtmlTag } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { inlineHtmlTag } { 1 } @@ -14799,10 +15098,10 @@ following body text: \def\markdownRendererInputBlockHtmlElement{% \markdownRendererInputBlockHtmlElementPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { inputBlockHtmlElement } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { inputBlockHtmlElement } { 1 } @@ -14906,10 +15205,10 @@ following text: \def\markdownRendererAttributeIdentifier{% \markdownRendererAttributeIdentifierPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { attributeIdentifier } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { attributeIdentifier } { 1 } @@ -14917,10 +15216,10 @@ following text: \def\markdownRendererAttributeClassName{% \markdownRendererAttributeClassNamePrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { attributeClassName } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { attributeClassName } { 1 } @@ -14928,10 +15227,10 @@ following text: \def\markdownRendererAttributeKeyValue{% \markdownRendererAttributeKeyValuePrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { attributeKeyValue } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { attributeKeyValue } { 2 } @@ -15021,10 +15320,10 @@ following text: \def\markdownRendererHeaderAttributeContextBegin{% \markdownRendererHeaderAttributeContextBeginPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { headerAttributeContextBegin } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { headerAttributeContextBegin } { 0 } @@ -15032,10 +15331,10 @@ following text: \def\markdownRendererHeaderAttributeContextEnd{% \markdownRendererHeaderAttributeContextEndPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { headerAttributeContextEnd } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { headerAttributeContextEnd } { 0 } @@ -15142,10 +15441,10 @@ following text: \def\markdownRendererStrikeThrough{% \markdownRendererStrikeThroughPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { strikeThrough } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { strikeThrough } { 1 } @@ -15250,10 +15549,10 @@ following text: \def\markdownRendererSuperscript{% \markdownRendererSuperscriptPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { superscript } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { superscript } { 1 } @@ -15298,7 +15597,7 @@ luatex document.tex A PDF document named `document.pdf` should be produced and contain the following text: -> H (2 moles) and O is liquid. +> H (2 moles) and O is a liquid. ##### \LaTeX{} Example {.unnumbered} @@ -15325,7 +15624,7 @@ lualatex document.tex A PDF document named `document.pdf` should be produced and contain the following text: -> H (2 moles) and O is liquid. +> H (2 moles) and O is a liquid. ##### \Hologo{ConTeXt} Example {.unnumbered} @@ -15348,7 +15647,7 @@ context document.tex A PDF document named `document.pdf` should be produced and contain the following text: -> H (2 moles) and O is liquid. +> H (2 moles) and O is a liquid. %</manual-tokens> %<*tex> @@ -15358,13 +15657,130 @@ following text: \def\markdownRendererSubscript{% \markdownRendererSubscriptPrototype}% \ExplSyntaxOn -\seq_put_right:Nn +\seq_gput_right:Nn \g_@@_renderers_seq { subscript } -\prop_put:Nnn +\prop_gput:Nnn \g_@@_renderer_arities_prop { subscript } { 1 } +% \end{macrocode} +% \par +% +% \iffalse +%</tex> +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +#### Raw Content Renderers +The \mdef{markdownRendererInputRawInline} macro represents an inline raw span. +The macro receives two arguments: the filename of a file contaning the inline +raw span contents and the raw attribute that designates the format of the +inline raw span. This macro will only be produced, when the \Opt{rawAttribute} +option is enabled. + +% \end{markdown} +% +% \iffalse +%</manual-tokens> +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererInputRawInline{% + \markdownRendererInputRawInlinePrototype}% +\ExplSyntaxOn +\seq_gput_right:Nn + \g_@@_renderers_seq + { inputRawInline } +\prop_gput:Nnn + \g_@@_renderer_arities_prop + { inputRawInline } + { 2 } +\ExplSyntaxOff +% \end{macrocode} +% \par +% +% \iffalse +%</tex> +%<*manual-tokens> +% \fi +% +% \begin{markdown} + +The \mdef{markdownRendererInputRawBlock} macro represents a raw block. The +macro receives two arguments: the filename of a file contaning the raw block +and the raw attribute that designates the format of the raw block. This macro +will only be produced, when the \Opt{rawAttribute} and \Opt{fencedCode} options +are enabled. + +% \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[rawAttribute, fencedCode]{markdown} +\usepackage{expl3} +\ExplSyntaxOn +\cs_new:Nn + \display_raw_content:nn + { + % If the raw attribute is TeX, execute the content as a TeX document. + \str_if_eq:nnTF + { #2 } + { tex } + { \markdownEscape { #1 } } + % Otherwise, ignore the content. + { } + } +\markdownSetup{ + renderers = { + rawInline = { \display_raw_content:nn { #1 } { #2 } }, + rawBlock = { \display_raw_content:nn { #1 } { #2 } } + }, +} +\ExplSyntaxOff +\begin{document} +\begin{markdown} +`$H_2 O$`{=tex} is a liquid. + +``` {=html} +<p>Here is some HTML content that will be ignored.</p> +``` +\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: + +> H~2~O is a liquid. + +%</manual-tokens> +%<*tex> +% \fi +% +% \begin{macrocode} +\def\markdownRendererInputRawBlock{% + \markdownRendererInputRawBlockPrototype}% +\ExplSyntaxOn +\seq_gput_right:Nn + \g_@@_renderers_seq + { inputRawBlock } +\prop_gput:Nnn + \g_@@_renderer_arities_prop + { inputRawBlock } + { 2 } \ExplSyntaxOff % \end{macrocode} % \par @@ -15494,7 +15910,7 @@ following text: By default, the renderer prototypes for YAML metadata provide a high-level interface that can be programmed using the `markdown/jekyllData` key--values -from the l3keys module of the \LaTeX3 kernel. +from the l3keys module of the \LaTeX{}3 kernel. % \end{markdown} % \iffalse @@ -15616,7 +16032,6 @@ following text: { } \ExplSyntaxOff % \end{macrocode} -% % \begin{markdown} % % The following \TeX{} macros provide definitions for the token renderers (see @@ -15638,6 +16053,28 @@ following text: \let\markdownRendererBlockHtmlCommentBegin=\iffalse \let\markdownRendererBlockHtmlCommentEndPrototype=\fi \let\markdownRendererBlockHtmlCommentEnd=\fi +% \end{macrocode} +% \begin{markdown} +% +% The \mdef{markdownRendererFootnote} and +% \mdef{markdownRendererFootnotePrototype} macros have been deprecated +% and will be removed in Markdown 3.0.0. +% +% \end{markdown} +% \begin{macrocode} + \cs_undefine:N \markdownRendererFootnote + \cs_undefine:N \markdownRendererFootnotePrototype +% \end{macrocode} +% \begin{markdown} +% +% The \mdef{markdownRendererHorizontalRule} and +% \mdef{markdownRendererHorizontalRulePrototype} macros have been deprecated +% and will be removed in Markdown 3.0.0. +% +% \end{markdown} +% \begin{macrocode} + \cs_undefine:N \markdownRendererHorizontalRule + \cs_undefine:N \markdownRendererHorizontalRulePrototype } \cs_new:Nn \@@_plaintex_define_renderer_prototype:n { @@ -16094,7 +16531,7 @@ document: \prop_new:N \g_@@_latex_option_types_prop \prop_new:N \g_@@_default_latex_options_prop \tl_const:Nn \c_@@_option_layer_latex_tl { latex } -\seq_put_right:NV \g_@@_option_layers_seq \c_@@_option_layer_latex_tl +\seq_gput_right:NV \g_@@_option_layers_seq \c_@@_option_layer_latex_tl \cs_new:Nn \@@_add_latex_option:nnn { @@ -16479,7 +16916,7 @@ A PDF document named `document.pdf` should be produced and contain the following image: > ![img](https://github.com/witiko/markdown/raw/main/markdown.png -> "The banner of the Markdown package") +> "The banner of the Markdown package") %</manual-options> %<*latex-themes-witiko-graphicx-http> @@ -16661,13 +17098,29 @@ The following ordered list will be preceded by roman numerals: \seq_map_inline:cn { g_@@_ ##1 _options_seq } { - \@@_latex_define_option_keyval:nn - { ##1 } +% \end{macrocode} +% \begin{markdown} +% +% To make it easier to copy-and-paste options from Pandoc [@macfarlane22] such +% as `fancy_lists`, `header_attributes`, and `pipe_tables`, we accept +% snake\\\_case in addition to camelCase variants of options. As a bonus, +% studies [@sharif10] also show that snake\\\_case is faster to read than +% camelCase. +% +% \end{markdown} +% \begin{macrocode} + \@@_with_various_cases:nn { ####1 } + { + \@@_latex_define_option_keyval:nnn + { ##1 } + { ####1 } + { ########1 } + } } } } -\cs_new:Nn \@@_latex_define_option_keyval:nn +\cs_new:Nn \@@_latex_define_option_keyval:nnn { \prop_get:cnN { g_@@_ #1 _option_types_prop } @@ -16676,7 +17129,7 @@ The following ordered list will be preceded by roman numerals: \keys_define:nn { markdown/latex-options } { - #2 .code:n = { + #3 .code:n = { \@@_set_option_value:nn { #2 } { ##1 } @@ -16689,7 +17142,7 @@ The following ordered list will be preceded by roman numerals: \keys_define:nn { markdown/latex-options } { - #2 .default:n = { true }, + #3 .default:n = { true }, } } % \end{macrocode} @@ -16710,7 +17163,7 @@ The following ordered list will be preceded by roman numerals: { \tl_set:Nn \l_tmpa_tl - { #2 } + { #3 } \tl_reverse:N \l_tmpa_tl \str_if_eq:enF @@ -16723,7 +17176,7 @@ The following ordered list will be preceded by roman numerals: \msg_error:nnn { @@ } { malformed-name-for-clist-option } - { #2 } + { #3 } } \tl_set:Nx \l_tmpa_tl @@ -16865,16 +17318,20 @@ The following ordered list will be preceded by roman numerals: } \cs_new:Nn \@@_latex_define_renderer:nNn { - \keys_define:nn - { markdown/latex-options/renderers } + \@@_with_various_cases:nn + { #1 } { - #1 .code:n = { - \cs_generate_from_arg_count:NNnn - #2 - \cs_set:Npn - { #3 } - { ##1 } - }, + \keys_define:nn + { markdown/latex-options/renderers } + { + ##1 .code:n = { + \cs_generate_from_arg_count:NNnn + #2 + \cs_set:Npn + { #3 } + { ####1 } + }, + } } } \cs_generate_variant:Nn @@ -16929,16 +17386,20 @@ The following ordered list will be preceded by roman numerals: } \cs_new:Nn \@@_latex_define_renderer_prototype:nNn { - \keys_define:nn - { markdown/latex-options/renderer-prototypes } + \@@_with_various_cases:nn + { #1 } { - #1 .code:n = { - \cs_generate_from_arg_count:NNnn - #2 - \cs_set:Npn - { #3 } - { ##1 } - }, + \keys_define:nn + { markdown/latex-options/renderer-prototypes } + { + ##1 .code:n = { + \cs_generate_from_arg_count:NNnn + #2 + \cs_set:Npn + { #3 } + { ####1 } + }, + } } } \cs_generate_variant:Nn @@ -17160,13 +17621,48 @@ texexec --passon=--shell-escape document.tex \seq_map_inline:cn { g_@@_ ##1 _options_seq } { - \@@_context_define_option_keyval:nn - { ##1 } +% \end{macrocode} +% \begin{markdown} +% +% To make it easier to copy-and-paste options from Pandoc [@macfarlane22] such +% as `fancy_lists`, `header_attributes`, and `pipe_tables`, we accept +% snake\\\_case in addition to camelCase variants of options. As a bonus, +% studies [@sharif10] also show that snake\\\_case is faster to read than +% camelCase. +% +% \end{markdown} +% \begin{macrocode} + \@@_with_various_cases:nn { ####1 } + { + \@@_context_define_option_keyval:nnn + { ##1 } + { ####1 } + { ########1 } + } } } } -\cs_new:Nn \@@_context_define_option_keyval:nn +% \end{macrocode} +% \begin{markdown} +% +% Furthermore, we also accept caseless variants of options in line with the +% style of \Hologo{ConTeXt}. +% +% \end{markdown} +% \begin{macrocode} +\cs_new:Nn \@@_caseless:N + { + \regex_replace_all:nnN + { ([a-z])([A-Z]) } + { \1 \c { str_lowercase:n } \cB\{ \2 \cE\} } + #1 + \tl_set:Nx + #1 + { #1 } + } +\seq_gput_right:Nn \g_@@_cases_seq { @@_caseless:N } +\cs_new:Nn \@@_context_define_option_keyval:nnn { \prop_get:cnN { g_@@_ #1 _option_types_prop } @@ -17175,7 +17671,7 @@ texexec --passon=--shell-escape document.tex \keys_define:nn { markdown/context-options } { - #2 .code:n = { + #3 .code:n = { \tl_set:Nx \l_tmpa_tl { @@ -17199,7 +17695,7 @@ texexec --passon=--shell-escape document.tex \keys_define:nn { markdown/context-options } { - #2 .default:n = { true }, + #3 .default:n = { true }, } } } @@ -17312,6 +17808,21 @@ end % \par % \begin{markdown} % +% The \luamdef{util.cache_verbatim} method strips whitespaces from the +% end of `string` and calls \luamref{util.cache} with `dir`, `string`, +% no salt or transformations, and the `.verbatim` suffix. +% +% \end{markdown} +% \begin{macrocode} +function util.cache_verbatim(dir, string) + string = string:gsub('[\r\n%s]*$', '') + local name = util.cache(dir, string, nil, nil, ".verbatim") + return name +end +% \end{macrocode} +% \par +% \begin{markdown} +% % The \luamdef{util.table_copy} method creates a shallow copy of a table `t` % and its metatable. % @@ -19868,13 +20379,14 @@ function M.writer.new(options) % \par % \begin{markdown} % -% Define \luamdef{writer->hrule} as the output format of a horizontal rule. +% Define \luamdef{writer->thematic_break} as the output format of a thematic +% break. % % \end{markdown} % \begin{macrocode} - function self.hrule() + function self.thematic_break() if not self.is_writing then return "" end - return "\\markdownRendererHorizontalRule{}" + return "\\markdownRendererThematicBreak{}" end % \end{macrocode} % \par @@ -19961,7 +20473,7 @@ function M.writer.new(options) % \begin{markdown} % % Define \luamdef{writer->code} as a function that will transform an input -% inlined code span `s` to the output format. +% inline code span `s` to the output format. % % \end{markdown} % \begin{macrocode} @@ -20212,8 +20724,7 @@ function M.writer.new(options) % \begin{macrocode} function self.verbatim(s) if not self.is_writing then return "" end - s = string.gsub(s, '[\r\n%s]*$', '') - local name = util.cache(options.cacheDir, s, nil, nil, ".verbatim") + local name = util.cache_verbatim(options.cacheDir, s) return {"\\markdownRendererInputVerbatim{",name,"}"} end % \end{macrocode} @@ -20633,6 +21144,20 @@ parsers.attribute_value = ( (parsers.dquote / "") + ( parsers.anyescaped - parsers.dquote - parsers.rbrace - parsers.space)^0 +parsers.attribute = (parsers.dash * Cc(".unnumbered")) + + C((parsers.hash + parsers.period) + * parsers.attribute_key) + + Cs( parsers.attribute_key + * parsers.optionalspace * parsers.equal * parsers.optionalspace + * parsers.attribute_value) +parsers.attributes = parsers.lbrace + * parsers.optionalspace + * parsers.attribute + * (parsers.spacechar^1 + * parsers.attribute)^0 + * parsers.optionalspace + * parsers.rbrace + -- block followed by 0 or more optionally -- indented blocks with first line indented. parsers.indented_blocks = function(bl) @@ -20707,8 +21232,8 @@ local function captures_geq_length(_,i,a,b) return #a >= #b and i end -parsers.infostring = (parsers.linechar - (parsers.backtick - + parsers.space^1 * (parsers.newline + parsers.eof)))^0 +parsers.infostring = (parsers.linechar - (parsers.backtick + + parsers.space^1 * (parsers.newline + parsers.eof)))^0 local fenceindent parsers.fencehead = function(char) @@ -20977,6 +21502,16 @@ parsers.urlchar = parsers.anyescaped - parsers.newline - parsers.more % % \end{markdown} % \begin{macrocode} +parsers.TildeFencedCode + = parsers.fencehead(parsers.tilde) + * Cs(parsers.fencedline(parsers.tilde)^0) + * parsers.fencetail(parsers.tilde) + +parsers.BacktickFencedCode + = parsers.fencehead(parsers.backtick) + * Cs(parsers.fencedline(parsers.backtick)^0) + * parsers.fencetail(parsers.backtick) + parsers.lineof = function(c) return (parsers.leader * (P(c) * parsers.optionalspace)^3 * (parsers.newline * parsers.blankline^1 @@ -20990,26 +21525,12 @@ end % % \end{markdown} % \begin{macrocode} -parsers.heading_attribute = (parsers.dash * Cc(".unnumbered")) - + C((parsers.hash + parsers.period) - * parsers.attribute_key) - + Cs( parsers.attribute_key - * parsers.optionalspace * parsers.equal * parsers.optionalspace - * parsers.attribute_value) -parsers.HeadingAttributes = parsers.lbrace - * parsers.optionalspace - * parsers.heading_attribute - * (parsers.spacechar^1 - * parsers.heading_attribute)^0 - * parsers.optionalspace - * parsers.rbrace - -- parse Atx heading start and return level -parsers.HeadingStart = #parsers.hash * C(parsers.hash^-6) - * -parsers.hash / length +parsers.heading_start = #parsers.hash * C(parsers.hash^-6) + * -parsers.hash / length -- parse setext header ending and return level -parsers.HeadingLevel = parsers.equal^1 * Cc(1) + parsers.dash^1 * Cc(2) +parsers.heading_level = parsers.equal^1 * Cc(1) + parsers.dash^1 * Cc(2) local function strip_atx_end(s) return s:gsub("[#%s]*\n$","") @@ -21188,8 +21709,8 @@ function M.reader.new(writer, options) % \end{markdown} % \begin{macrocode} if toplevel and (options.texComments or options.hybrid) then - str = lpeg.match(Ct(parsers.commented_line^1), str) - str = util.rope_to_string(str) + str = lpeg.match(Ct(parsers.commented_line^1), str) + str = util.rope_to_string(str) end local res = lpeg.match(grammar(), str) if res == nil then @@ -21274,7 +21795,7 @@ function M.reader.new(writer, options) * (-(parsers.leader * parsers.more + parsers.blankline) * parsers.linechar^1 * parsers.newline)^0 - + if not options.breakableBlockquotes then parsers.blockquote_body = parsers.blockquote_body * (parsers.blankline^0 / "") @@ -21283,7 +21804,7 @@ function M.reader.new(writer, options) % \par % \begin{markdown} % -%#### Parsers Used for Footnotes (local) +%#### Parsers Used for Notes (local) % % \end{markdown} % \begin{macrocode} @@ -21550,10 +22071,10 @@ function M.reader.new(writer, options) / self.parser_functions.parse_blocks_nested / writer.blockquote - parsers.HorizontalRule = ( parsers.lineof(parsers.asterisk) - + parsers.lineof(parsers.dash) - + parsers.lineof(parsers.underscore) - ) / writer.hrule + parsers.ThematicBreak = ( parsers.lineof(parsers.asterisk) + + parsers.lineof(parsers.dash) + + parsers.lineof(parsers.underscore) + ) / writer.thematic_break parsers.Reference = parsers.define_reference_parser / register_link @@ -21604,14 +22125,14 @@ function M.reader.new(writer, options) * parsers.ListBlock parsers.TightListItem = function(starter) - return -parsers.HorizontalRule + return -parsers.ThematicBreak * (Cs(starter / "" * parsers.tickbox^-1 * parsers.ListBlock * parsers.NestedList^-1) / self.parser_functions.parse_blocks_nested) * -(parsers.blanklines * parsers.indent) end parsers.LooseListItem = function(starter) - return -parsers.HorizontalRule + return -parsers.ThematicBreak * Cs( starter / "" * parsers.tickbox^-1 * parsers.ListBlock * Cc("\n") * (parsers.NestedList + parsers.ListContinuationBlock^0) * (parsers.blanklines / "\n\n") @@ -21664,7 +22185,7 @@ function M.reader.new(writer, options) % \end{markdown} % \begin{macrocode} -- parse atx header - parsers.AtxHeading = Cg(parsers.HeadingStart,"level") + parsers.AtxHeading = Cg(parsers.heading_start, "level") * parsers.optionalspace * (C(parsers.line) / strip_atx_end @@ -21676,7 +22197,7 @@ function M.reader.new(writer, options) * Ct(parsers.linechar^1 / self.parser_functions.parse_inlines) * parsers.newline - * parsers.HeadingLevel + * parsers.heading_level * parsers.optionalspace * parsers.newline / writer.heading @@ -21794,7 +22315,7 @@ function M.reader.new(writer, options) Blockquote = parsers.Blockquote, Verbatim = parsers.Verbatim, - HorizontalRule = parsers.HorizontalRule, + ThematicBreak = parsers.ThematicBreak, BulletList = parsers.BulletList, OrderedList = parsers.OrderedList, Heading = parsers.Heading, @@ -21969,7 +22490,7 @@ function M.reader.new(writer, options) % \begin{markdown} % % Although the interface of the \luamref{reader->insert_pattern} method does -% document this (see Section <#luauserextensions>), we allow the +% document this (see Section <#sec:luauserextensions>), we allow the % \luamref{reader->insert_pattern} and \luamref{reader->update_rule} % methods to insert not just \acro{peg} patterns, but also rule names that % reference the \acro{peg} grammar of Markdown. @@ -22654,74 +23175,22 @@ M.extensions.fenced_code = function(blank_before_code_fence) % % \end{markdown} % \begin{macrocode} - function self.fencedCode(i, s) + function self.fencedCode(s, i) if not self.is_writing then return "" end - s = string.gsub(s, '[\r\n%s]*$', '') - local name = util.cache(options.cacheDir, s, nil, nil, ".verbatim") - return {"\\markdownRendererInputFencedCode{",name,"}{",i,"}"} + local name = util.cache_verbatim(options.cacheDir, s) + return {"\\markdownRendererInputFencedCode{", + name,"}{",self.string(i),"}"} end end, extend_reader = function(self) local parsers = self.parsers local writer = self.writer - local function captures_geq_length(_,i,a,b) - return #a >= #b and i - end - - local infostring = (parsers.linechar - (parsers.backtick - + parsers.space^1 * (parsers.newline + parsers.eof)))^0 - - local fenceindent - local fencehead = function(char) - return C(parsers.nonindentspace) / function(s) fenceindent = #s end - * Cg(char^3, "fencelength") - * parsers.optionalspace * C(infostring) - * parsers.optionalspace * (parsers.newline + parsers.eof) - end - - local fencetail = function(char) - return parsers.nonindentspace - * Cmt(C(char^3) * Cb("fencelength"), captures_geq_length) - * parsers.optionalspace * (parsers.newline + parsers.eof) - + parsers.eof - end - - local fencedline = function(char) - return C(parsers.line - fencetail(char)) - / function(s) - local i = 1 - local remaining = fenceindent - while true do - local c = s:sub(i, i) - if c == " " and remaining > 0 then - remaining = remaining - 1 - i = i + 1 - elseif c == "\t" and remaining > 3 then - remaining = remaining - 4 - i = i + 1 - else - break - end - end - return s:sub(i) - end - end - - local TildeFencedCode - = fencehead(parsers.tilde) - * Cs(fencedline(parsers.tilde)^0) - * fencetail(parsers.tilde) - - local BacktickFencedCode - = fencehead(parsers.backtick) - * Cs(fencedline(parsers.backtick)^0) - * fencetail(parsers.backtick) - - local FencedCode = (TildeFencedCode - + BacktickFencedCode) + local FencedCode = (parsers.TildeFencedCode + + parsers.BacktickFencedCode) / function(infostring, code) - return writer.fencedCode(writer.string(infostring), - self.expandtabs(code)) + local expanded_code = self.expandtabs(code) + return writer.fencedCode(expanded_code, + infostring) end self.insert_pattern("Block after Verbatim", @@ -22731,8 +23200,8 @@ M.extensions.fenced_code = function(blank_before_code_fence) if blank_before_code_fence then fencestart = parsers.fail else - fencestart = fencehead(parsers.backtick) - + fencehead(parsers.tilde) + fencestart = parsers.fencehead(parsers.backtick) + + parsers.fencehead(parsers.tilde) end local EndlineExceptions = parsers.EndlineExceptions + fencestart @@ -22745,38 +23214,38 @@ end % \end{macrocode} % \begin{markdown} % -%#### Footnotes +%#### Notes % -% The \luamdef{extensions.footnotes} function implements the Pandoc footnote -% and inline footnote syntax extensions. When the `footnote` parameter is -% `true`, the Pandoc footnote syntax extension will be enabled. When the -% `inline_footnotes` parameter is `true`, the Pandoc inline footnote syntax +% The \luamdef{extensions.notes} function implements the Pandoc note +% and inline note syntax extensions. When the `note` parameter is +% `true`, the Pandoc note syntax extension will be enabled. When the +% `inline_notes` parameter is `true`, the Pandoc inline note syntax % extension will be enabled. % % \end{markdown} % \begin{macrocode} -M.extensions.footnotes = function(footnotes, inline_footnotes) - assert(footnotes or inline_footnotes) +M.extensions.notes = function(notes, inline_notes) + assert(notes or inline_notes) return { - name = "built-in footnotes syntax extension", + name = "built-in notes syntax extension", extend_writer = function(self) % \end{macrocode} % \par % \begin{markdown} % % Define \luamdef{writer->note} as a function that will transform an -% input footnote `s` to the output format. +% input note `s` to the output format. % % \end{markdown} % \begin{macrocode} function self.note(s) - return {"\\markdownRendererFootnote{",s,"}"} + return {"\\markdownRendererNote{",s,"}"} end end, extend_reader = function(self) local parsers = self.parsers local writer = self.writer - if inline_footnotes then + if inline_notes then local InlineNote = parsers.circumflex * (parsers.tag / self.parser_functions.parse_inlines_no_inline_note) @@ -22785,7 +23254,7 @@ M.extensions.footnotes = function(footnotes, inline_footnotes) self.insert_pattern("Inline after Emph", InlineNote, "InlineNote") end - if footnotes then + if notes then local function strip_first_char(s) return s:sub(2) end @@ -22851,49 +23320,49 @@ M.extensions.header_attributes = function() local parsers = self.parsers local writer = self.writer - parsers.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) - / self.parser_functions.parse_inlines) - * Cg(Ct(parsers.newline - + (parsers.hash^1 - * parsers.optionalspace - * parsers.HeadingAttributes^-1 - + parsers.HeadingAttributes) + local AtxHeading = Cg(parsers.heading_start, "level") + * parsers.optionalspace + * (C(((parsers.linechar + - ((parsers.hash^1 * parsers.optionalspace - * parsers.newline), "attributes") - * Cb("level") - * Cb("attributes") - / writer.heading - - parsers.SetextHeading = #(parsers.line * S("=-")) - * (C(((parsers.linechar - - (parsers.HeadingAttributes - * parsers.optionalspace - * parsers.newline)) - * (parsers.linechar - - parsers.lbrace)^0)^1) - / self.parser_functions.parse_inlines) - * Cg(Ct(parsers.newline - + (parsers.HeadingAttributes - * parsers.optionalspace - * parsers.newline)), "attributes") - * parsers.HeadingLevel - * Cb("attributes") - * parsers.optionalspace - * parsers.newline - / writer.heading - - local Heading = parsers.AtxHeading + parsers.SetextHeading + * parsers.attributes^-1 + + parsers.attributes) + * parsers.optionalspace + * parsers.newline)) + * (parsers.linechar + - parsers.hash + - parsers.lbrace)^0)^1) + / self.parser_functions.parse_inlines) + * Cg(Ct(parsers.newline + + (parsers.hash^1 + * parsers.optionalspace + * parsers.attributes^-1 + + parsers.attributes) + * parsers.optionalspace + * parsers.newline), "attributes") + * Cb("level") + * Cb("attributes") + / writer.heading + + local SetextHeading = #(parsers.line * S("=-")) + * (C(((parsers.linechar + - (parsers.attributes + * parsers.optionalspace + * parsers.newline)) + * (parsers.linechar + - parsers.lbrace)^0)^1) + / self.parser_functions.parse_inlines) + * Cg(Ct(parsers.newline + + (parsers.attributes + * parsers.optionalspace + * parsers.newline)), "attributes") + * parsers.heading_level + * Cb("attributes") + * parsers.optionalspace + * parsers.newline + / writer.heading + + local Heading = AtxHeading + SetextHeading self.update_rule("Heading", Heading) end } @@ -23035,14 +23504,14 @@ M.extensions.jekyll_data = function(expect_jekyll_data) local UnexpectedJekyllData = P("---") * parsers.blankline / 0 - * #(-parsers.blankline) -- if followed by blank, it's an hrule + * #(-parsers.blankline) -- if followed by blank, it's thematic break * JekyllData * (P("---") + P("...")) local ExpectedJekyllData = ( P("---") * parsers.blankline / 0 - * #(-parsers.blankline) -- if followed by blank, it's an hrule + * #(-parsers.blankline) -- if followed by blank, it's thematic break )^-1 * JekyllData * (P("---") + P("..."))^-1 @@ -23221,6 +23690,93 @@ end % \end{macrocode} % \begin{markdown} % +%#### Raw Attributes +% +% The \luamdef{extensions.raw_attribute} function implements the Pandoc +% raw attribute syntax extension. +% +% \end{markdown} +% \begin{macrocode} +M.extensions.raw_attribute = function() + return { + name = "built-in raw_attribute syntax extension", + extend_writer = function(self) + local options = self.options + +% \end{macrocode} +% \par +% \begin{markdown} +% +% Define \luamdef{writer->rawInline} as a function that will transform an +% input inline raw span `s` with the raw attribute `i` to the output format. +% +% \end{markdown} +% \begin{macrocode} + function self.rawInline(s, attr) + if not self.is_writing then return "" end + local name = util.cache_verbatim(options.cacheDir, s) + return {"\\markdownRendererInputRawInline{", + name,"}{", self.string(attr),"}"} + end + + if options.fencedCode then +% \end{macrocode} +% \par +% \begin{markdown} +% +% Define \luamdef{writer->rawBlock} as a function that will transform an +% input raw block `s` with the raw attribute `i` to the output format. +% +% \end{markdown} +% \begin{macrocode} + function self.rawBlock(s, attr) + if not self.is_writing then return "" end + local name = util.cache_verbatim(options.cacheDir, s) + return {"\\markdownRendererInputRawBlock{", + name,"}{", self.string(attr),"}"} + end + end + end, extend_reader = function(self) + local options = self.options + local writer = self.writer + + local raw_attribute = parsers.lbrace + * parsers.optionalspace + * parsers.equal + * C(parsers.attribute_key) + * parsers.optionalspace + * parsers.rbrace + + local RawInline = parsers.inticks + * raw_attribute + / writer.rawInline + + self.insert_pattern("Inline before Code", + RawInline, "RawInline") + + if options.fencedCode then + local RawBlock = (parsers.TildeFencedCode + + parsers.BacktickFencedCode) + / function(infostring, code) + local expanded_code = self.expandtabs(code) + local attr = lpeg.match(raw_attribute, infostring) + if attr then + return writer.rawBlock(expanded_code, attr) + else + return writer.fencedCode(expanded_code, + infostring) + end + end + + self.insert_pattern("Block after Verbatim", + RawBlock, "RawBlock") + end + end + } +end +% \end{macrocode} +% \begin{markdown} +% %#### Strike-Through % % The \luamdef{extensions.strike_through} function implements the Pandoc @@ -23456,14 +24012,14 @@ M.extensions.fancy_lists = function() * ListBlock local TightListItem = function(starter) - return -parsers.HorizontalRule + return -parsers.ThematicBreak * (Cs(starter / "" * parsers.tickbox^-1 * ListBlock * NestedList^-1) / self.parser_functions.parse_blocks_nested) * -(parsers.blanklines * parsers.indent) end local LooseListItem = function(starter) - return -parsers.HorizontalRule + return -parsers.ThematicBreak * Cs( starter / "" * parsers.tickbox^-1 * ListBlock * Cc("\n") * (NestedList + ListContinuationBlock^0) * (parsers.blanklines / "\n\n") @@ -23550,7 +24106,7 @@ end % % The \luamref{new} function returns a conversion function that takes a % markdown string and turns it into a plain \TeX{} output. See Section -% <#luaconversion>. +% <#sec:luaconversion>. % % \end{markdown} % \begin{macrocode} @@ -23611,6 +24167,11 @@ function M.new(options) table.insert(extensions, pipe_tables_extension) end + if options.rawAttribute then + local raw_attribute_extension = M.extensions.raw_attribute() + table.insert(extensions, raw_attribute_extension) + end + if options.strikeThrough then local strike_through_extension = M.extensions.strike_through() table.insert(extensions, strike_through_extension) @@ -23626,10 +24187,20 @@ function M.new(options) table.insert(extensions, superscript_extension) end - if options.footnotes or options.inlineFootnotes then - local footnotes_extension = M.extensions.footnotes( - options.footnotes, options.inlineFootnotes) - table.insert(extensions, footnotes_extension) +% \end{macrocode} +% \begin{markdown} +% +% The footnotes and inlineFootnotes option has been deprecated and will be +% removed in Markdown 3.0.0. +% +% \end{markdown} +% \begin{macrocode} + if options.footnotes or options.inlineFootnotes or + options.notes or options.inlineNotes then + local notes_extension = M.extensions.notes( + options.footnotes or options.notes, + options.inlineFootnotes or options.inlineNotes) + table.insert(extensions, notes_extension) end if options.citations then @@ -23724,7 +24295,7 @@ function M.new(options) % % Finally, cast the user-defined syntax extension to the internal format % of user extensions used by the Markdown package (see Section -% <#luabuiltinextensions>.) +% <#sec:luabuiltinextensions>.) % % \end{markdown} % \begin{macrocode} @@ -23930,8 +24501,8 @@ end \def\markdownRendererHeadingFourPrototype#1{#1}% \def\markdownRendererHeadingFivePrototype#1{#1}% \def\markdownRendererHeadingSixPrototype#1{#1}% -\def\markdownRendererHorizontalRulePrototype{}% -\def\markdownRendererFootnotePrototype#1{#1}% +\def\markdownRendererThematicBreakPrototype{}% +\def\markdownRendererNotePrototype#1{#1}% \def\markdownRendererCitePrototype#1{}% \def\markdownRendererTextCitePrototype#1{}% \def\markdownRendererTickedBoxPrototype{[X]}% @@ -23944,6 +24515,33 @@ end % \par % \begin{markdown} % +%#### Raw Attribute Renderer Prototypes +% +% In the raw block and inline raw span renderer prototypes, execute the content +% with TeX when the raw attribute is `tex`, display the content as markdown when +% the raw attribute is `md`, and ignore the content otherwise. +% +% \end{markdown} +% \begin{macrocode} +\ExplSyntaxOn +\cs_gset:Npn + \markdownRendererInputRawInlinePrototype#1#2 + { + \str_case:nn + { #2 } + { + { tex } { \markdownEscape{#1} } + { md } { \markdownInput{#1} } + } + } +\cs_gset_eq:NN + \markdownRendererInputRawBlockPrototype + \markdownRendererInputRawInlinePrototype +\ExplSyntaxOff +% \end{macrocode} +% \par +% \begin{markdown} +% %#### YAML Metadata Renderer Prototypes {#expl3yamlmetadataimplementation} % % To keep track of the current type of structure we inhabit when we are @@ -24867,6 +25465,22 @@ end }% |endgroup % \end{macrocode} +% \par +% \begin{markdown} +% The \mref{markdownEscape} macro resets the category codes of the percent sign +% and the hash sign back to comment and parameter, respectively, before using +% the `\input` built-in of \TeX{} to execute a \TeX{} document in the middle of +% a markdown document fragment. +% \end{markdown} +% \begin{macrocode} +\gdef\markdownEscape#1{% + \catcode`\%=14\relax + \catcode`\#=6\relax + \input #1\relax + \catcode`\%=12\relax + \catcode`\#=12\relax +}% +% \end{macrocode} % \iffalse %</tex> %<*latex> @@ -24983,13 +25597,13 @@ end % \begin{macrocode} \newcommand\markdownLaTeXThemeName{} \seq_new:N \g_@@_latex_themes_seq -\seq_put_right:NV +\seq_gput_right:NV \g_@@_latex_themes_seq \markdownLaTeXThemeName \newcommand\markdownLaTeXThemeLoad[2]{ \def\@tempa{% \def\markdownLaTeXThemeName{#2} - \seq_put_right:NV + \seq_gput_right:NV \g_@@_latex_themes_seq \markdownLaTeXThemeName \RequirePackage{#1} @@ -25266,11 +25880,20 @@ end { markdown/latex-options/renderers } { #1 } }, - rendererPrototypes .code:n = { - \keys_set:nn - { markdown/latex-options/renderer-prototypes } - { #1 } - }, + } +\@@_with_various_cases:nn + { rendererPrototypes } + { + \keys_define:nn + { markdown/latex-options } + { + #1 .code:n = { + \keys_set:nn + { markdown/latex-options/renderer-prototypes } + { ##1 } + }, + } + } % \end{macrocode} % \begin{markdown} % @@ -25279,7 +25902,11 @@ end % % \end{markdown} % \begin{macrocode} +\keys_define:nn + { markdown/latex-options } + { code .code:n = { #1 }, + } % \end{macrocode} % \begin{markdown} % @@ -25289,11 +25916,36 @@ end % % \end{markdown} % \begin{macrocode} - jekyllDataRenderers .code:n = { - \keys_set:nn - { markdown/latex-options/jekyll-data-renderers } - { #1 } - }, +\@@_with_various_cases:nn + { jekyllDataRenderers } + { + \keys_define:nn + { markdown/latex-options } + { + #1 .code:n = { + \tl_set:Nn + \l_tmpa_tl + { ##1 } +% \end{macrocode} +% \begin{markdown} +% +% To ensure that keys containing forward slashes get passed correctly, we +% replace all forward slashes in the nput with backslash tokens with category +% code letter and then undo the replacement. This means that if any unbraced +% backslash tokens with category code letter exist in the input, they will be +% replaced with forward slashes. However, this should be extremely rare. +% +% \end{markdown} +% \begin{macrocode} + \tl_replace_all:NnV + \l_tmpa_tl + { / } + \c_backslash_str + \keys_set:nV + { markdown/latex-options/jekyll-data-renderers } + \l_tmpa_tl + }, + } } \keys_define:nn { markdown/latex-options/jekyll-data-renderers } @@ -25302,6 +25954,10 @@ end \tl_set_eq:NN \l_tmpa_tl \l_keys_key_str + \tl_replace_all:NVn + \l_tmpa_tl + \c_backslash_str + { / } \tl_put_right:Nn \l_tmpa_tl { @@ -25315,6 +25971,12 @@ end \cs_generate_variant:Nn \keys_define:nn { nV } +\cs_generate_variant:Nn + \tl_replace_all:Nnn + { NVn } +\cs_generate_variant:Nn + \tl_replace_all:Nnn + { NnV } \ExplSyntaxOff % \end{macrocode} % \par @@ -25483,7 +26145,7 @@ end dlEndTight = {\markdownRendererDlEnd}}} } \ExplSyntaxOff -\RequirePackage{amsmath,ifthen} +\RequirePackage{amsmath} % \end{macrocode} % \par % \begin{markdown} @@ -25540,29 +26202,33 @@ end \else \texttt{#1}% \fi + }}} +\ExplSyntaxOn +\markdownSetup{ + rendererPrototypes = { + contentBlock = { + \str_case:nnF + { #1 } + { + { csv } + { + \begin{table} + \begin{center} + \csvautotabular{#3} + \end{center} + \tl_if_empty:nF + { #4 } + { \caption{#4} } + \end{table} + } + { tex } { \markdownEscape{#3} } + } + { \markdownInput{#3} } + }, }, - contentBlock = {% - \ifthenelse{\equal{#1}{csv}}{% - \begin{table}% - \begin{center}% - \csvautotabular{#3}% - \end{center} - \ifx\empty#4\empty\else - \caption{#4}% - \fi - \end{table}% - }{% - \ifthenelse{\equal{#1}{tex}}{% - \catcode`\%=14\relax - \catcode`\#=6\relax - \input #3\relax - \catcode`\%=12\relax - \catcode`\#=12\relax - }{% - \markdownInput{#3}% - }% - }% - }, +} +\ExplSyntaxOff +\markdownSetup{rendererPrototypes={ image = {% \begin{figure}% \begin{center}% @@ -25653,8 +26319,8 @@ end \catcode`\#=12\relax }% \fi}, - horizontalRule = {\noindent\rule[0.5ex]{\linewidth}{1pt}}, - footnote = {\footnote{#1}}}} + thematicBreak = {\noindent\rule[0.5ex]{\linewidth}{1pt}}, + note = {\footnote{#1}}}} % \end{macrocode} % \par % \begin{markdown} @@ -26177,7 +26843,6 @@ end \addto@hook\markdownLaTeXTable{#1\\}% \expandafter\@gobble \fi\markdownLaTeXRenderTableCell} -\fi % \end{macrocode} % \par % \begin{markdown} @@ -26257,6 +26922,35 @@ end % \par % \begin{markdown} % +%#### Raw Attribute Renderer Prototypes +% +% In the raw block and inline raw span renderer prototypes, execute the content +% with TeX when the raw attribute is `tex` or `latex`, display the content as +% markdown when the raw attribute is `md`, and ignore the content otherwise. +% +% \end{markdown} +% \begin{macrocode} +\ExplSyntaxOn +\cs_gset:Npn + \markdownRendererInputRawInlinePrototype#1#2 + { + \str_case:nn + { #2 } + { + { tex } { \markdownEscape{#1} } + { latex } { \markdownEscape{#1} } + { md } { \markdownInput{#1} } + } + } +\cs_gset_eq:NN + \markdownRendererInputRawBlockPrototype + \markdownRendererInputRawInlinePrototype +\ExplSyntaxOff +\fi % Closes `\markdownIfOption{Plain}{\iffalse}{iftrue}` +% \end{macrocode} +% \par +% \begin{markdown} +% %### Miscellanea % When buffering user input, we should disable the bytes with the high bit set, % since these are made active by the \pkg{inputenc} package. We will do this by @@ -26504,9 +27198,9 @@ end \def\markdownRendererHeadingFourPrototype#1{\subsubsection{#1}}% \def\markdownRendererHeadingFivePrototype#1{\subsubsubsection{#1}}% \def\markdownRendererHeadingSixPrototype#1{\subsubsubsubsection{#1}}% -\def\markdownRendererHorizontalRulePrototype{% +\def\markdownRendererThematicBreakPrototype{% \blackrule[height=1pt, width=\hsize]}% -\def\markdownRendererFootnotePrototype#1{\footnote{#1}}% +\def\markdownRendererNotePrototype#1{\footnote{#1}}% \def\markdownRendererTickedBoxPrototype{$\boxtimes$} \def\markdownRendererHalfTickedBoxPrototype{$\boxdot$} \def\markdownRendererUntickedBoxPrototype{$\square$} @@ -26587,6 +27281,34 @@ end \ifnum\markdownConTeXtColumnCounter<\markdownConTeXtColumnTotal\relax\else \expandafter\gobbleoneargument \fi\markdownConTeXtRenderTableCell} +% \end{macrocode} +% \par +% \begin{markdown} +% +%#### Raw Attribute Renderer Prototypes +% +% In the raw block and inline raw span renderer prototypes, execute the content +% with TeX when the raw attribute is `tex` or `context`, display the content as +% markdown when the raw attribute is `md`, and ignore the content otherwise. +% +% \end{markdown} +% \begin{macrocode} +\ExplSyntaxOn +\cs_gset:Npn + \markdownRendererInputRawInlinePrototype#1#2 + { + \str_case:nn + { #2 } + { + { tex } { \markdownEscape{#1} } + { context } { \markdownEscape{#1} } + { md } { \markdownInput{#1} } + } + } +\cs_gset_eq:NN + \markdownRendererInputRawBlockPrototype + \markdownRendererInputRawInlinePrototype +\ExplSyntaxOff \stopmodule\protect % \end{macrocode} % \iffalse |