Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add first-class support for YAML documents #524

Merged
merged 16 commits into from
Oct 28, 2024
Merged
Prev Previous commit
Next Next commit
Add commands \startyaml, \stopyaml, and \inputyaml
  • Loading branch information
Witiko committed Oct 28, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 481a01b7064ba9f0dc0aae120ff5424c80a6b664
166 changes: 141 additions & 25 deletions markdown.dtx
Original file line number Diff line number Diff line change
@@ -11921,7 +11921,7 @@ pdftex --shell-escape document.tex
%
% ``` tex
% \input markdown
% \markdownSetup{jekyllData, expectJekyllData, ensureJekyllData}
% \yamlSetup{jekyllData, expectJekyllData, ensureJekyllData}
% \markdownBegin
% title: _Hello **world**
% author: John Doe
@@ -12022,7 +12022,7 @@ pdftex --shell-escape document.tex
%
% ``` tex
% \input markdown
% \markdownSetup{jekyllData, expectJekyllData, ensureJekyllData}
% \yamlSetup{jekyllData, expectJekyllData, ensureJekyllData}
% \markdownInput{hello.yml}
% \bye
% ```````
@@ -23014,16 +23014,22 @@ following text:
% \noindent It is expected that the special plain \TeX{} characters have the
% expected category codes, when `\input`ting the file.
%
%### Typesetting Markdown
% The interface exposes the \mdef{startmarkdown} and \mdef{stopmarkdown} macro
% pair for the typesetting of a markdown document fragment, and defines the
% \mdef{inputmarkdown} macro.
%### Typesetting Markdown and YAML
%
% The interface exposes the \mdef{startmarkdown}, \mdef{stopmarkdown},
% \mdef{startyaml}, \mdef{stopyaml}, \mdef{inputmarkdown}, and \mdef{inputyaml}
% macros.
%
%#### Typesetting Markdown and YAML directly
%
% The \mref{startmarkdown} and \mref{stopmarkdown} macros are aliases for the
% macros \mref{markdownBegin} and \mref{markdownEnd} exposed by the plain
% \TeX{} interface.
%
% \end{markdown}
% \begin{macrocode}
\let\startmarkdown\relax
\let\stopmarkdown\relax
\let\inputmarkdown\relax
% \end{macrocode}
% \par
% \begin{markdown}
@@ -23032,12 +23038,12 @@ following text:
% \mref{stopmarkdown} macro to produce special effects before and after the
% markdown block.
%
% Note that the \mref{startmarkdown} and \mref{stopmarkdown} macros
% are subject to the same limitations as the \mref{markdownBegin} and
% \mref{markdownEnd} macros exposed by the plain \TeX{} interface.
% The macros \mref{startmarkdown} and \mref{stopmarkdown} are subject to the
% same limitations as the \mref{markdownBegin} and \mref{markdownEnd} macros.
%
% The following example \Hologo{ConTeXt} code showcases the usage of the
% \mref{startmarkdown} and \mref{stopmarkdown} macros:
%
% ``` tex
% \usemodule[t][markdown]
% \starttext
@@ -23047,22 +23053,117 @@ following text:
% \stoptext
% ```````
%
% The \mref{inputmarkdown} macro accepts a single mandatory parameter
% containing the filename of a markdown document and expands to the result of
% the conversion of the input markdown document to plain \TeX{}. Unlike the
% \mref{markdownInput} macro provided by the plain \TeX{} interface, this macro
% also accepts \Hologo{ConTeXt} interface options (see Section
% <#sec:context-options>) as its optional argument. These options will only
% influnce this markdown document.
% The \mref{startyaml} and \mref{stopyaml} macros are aliases for the macros
% \mref{yamlBegin} and \mref{yamlEnd} exposed by the plain \TeX{} interface.
%
% \end{yaml}
% \begin{macrocode}
\let\startyaml\relax
\let\stopyaml\relax
% \end{macrocode}
% \par
% \begin{yaml}
%
% You may prepend your own code to the \mref{startyaml} macro and redefine the
% \mref{stopyaml} macro to produce special effects before and after the yaml
% block.
%
% The macros \mref{startyaml} and \mref{stopyaml} are subject to the same
% limitations as the \mref{markdownBegin} and \mref{markdownEnd} macros.
%
% The following example \Hologo{ConTeXt} code showcases the usage of the
% \mref{startyaml} and \mref{stopyaml} macros:
%
% ``` tex
% \usemodule[t][markdown]
% \starttext
% \startyaml
% title: _Hello **world**
% author: John Doe
% \stopyaml
% \stoptext
% ```````
%
% The above code has the same effect as the below code:
%
% ``` tex
% \usemodule[t][markdown]
% \starttext
% \setupyaml[jekyllData, expectJekyllData, ensureJekyllData]
% \startyaml
% title: _Hello **world**
% author: John Doe
% \stopyaml
% \stoptext
% ```````
%
%#### Typesetting Markdown and YAML from external documents
%
% The \mref{inputmarkdown} macro aliases the macro \mref{markdownInput} exposed
% by the plain \TeX{} interface.
%
% \end{markdown}
% \begin{macrocode}
\let\inputmarkdown\relax
% \end{macrocode}
% \par
% \begin{markdown}
%
% Furthermore, the \mref{inputmarkdown} macro also accepts \Hologo{ConTeXt}
% interface options (see Section <#sec:context-options>) as its optional
% argument. These options will only influnce this markdown document.
%
% The following example \Hologo{ConTeXt} code showcases the usage of the
% \mref{inputmarkdown} macro:
%
% The following example \LaTeX{} code showcases the usage of the
% \mref{markdownInput} macro:
% ``` tex
% \usemodule[t][markdown]
% \starttext
% % ...
% \inputmarkdown[smartEllipses]{hello.md}
% % ...
% \stoptext
% ```````
%
% The above code has the same effect as the below code:
%
% ``` tex
% \usemodule[t][markdown]
% \starttext
% \setupmarkdown[smartEllipses]
% \inputmarkdown{hello.md}
% \stoptext
% ```````
%
% The \mref{inputyaml} macro aliases the macro \mref{yamlInput} exposed by the
% plain \TeX{} interface.
%
% \end{markdown}
% \begin{macrocode}
\let\inputyaml\relax
% \end{macrocode}
% \par
% \begin{markdown}
%
% Furthermore, the \mref{inputyaml} macro also accepts \Hologo{ConTeXt}
% interface options (see Section <#sec:context-options>) as its optional
% argument. These options will only influnce this \acro{YAML} document.
%
% The following example \Hologo{ConTeXt} code showcases the usage of the
% \mref{inputyaml} macro:
%
% ``` tex
% \usemodule[t][markdown]
% \starttext
% \inputyaml[smartEllipses]{hello.yml}
% \stoptext
% ```````
%
% The above code has the same effect as the below code:
%
% ``` tex
% \usemodule[t][markdown]
% \starttext
% \setupyaml[smartEllipses]
% \inputyaml{hello.yml}
% \stoptext
% ```````
%
@@ -38606,9 +38707,9 @@ end
% \begin{markdown}
%
%### Typesetting Markdown
% The \mref{inputmarkdown} macro is defined to accept an optional argument with
% options recognized by the \Hologo{ConTeXt} interface (see Section
% <#sec:context-options>).
% The \mref{inputmarkdown} and \mref{inputyaml} macros are defined to accept an
% optional argument with options recognized by the \Hologo{ConTeXt} interface
% (see Section <#sec:context-options>).
%
% \end{markdown}
% \begin{macrocode}
@@ -38622,11 +38723,17 @@ end
\fi
\markdownInput{#2}%
\endgroup}%
\long\def\inputyaml{%
\dosingleempty
\doinputyaml}%
\long\def\doinputyaml[#1]#2{%
\doinputmarkdown[jekyllData, expectJekyllData, ensureJekyllData, #1]{#2}}%
% \end{macrocode}
% \par
% \begin{markdown}
%
% The \mref{startmarkdown} and \mref{stopmarkdown} macros are implemented using the
% The \mref{startmarkdown}, \mref{stopmarkdown}, \mref{startyaml}, and
% \mref{stopyaml} macros are implemented using the
% \mref{markdownReadAndConvert} macro.
%
% In Knuth's \TeX, trailing spaces are removed very early on when a line is
@@ -38660,6 +38767,15 @@ end
|gdef|stopmarkdown{%
|ctxlua{document.markdown_buffering = false}%
|markdownEnd}%
|gdef|startyaml{%
|begingroup
|ctxlua{document.markdown_buffering = true}%
|setupyaml[jekyllData, expectJekyllData, ensureJekyllData]%
|markdownReadAndConvert{\stopyaml}%
{|stopyaml|endgroup}}%
|gdef|stopyaml{%
|ctxlua{document.markdown_buffering = false}%
|yamlEnd}%
|endgroup
% \end{macrocode}
% \par