Skip to content

Commit

Permalink
Merge pull request #524 from Witiko/feat/first-class-yaml
Browse files Browse the repository at this point in the history
Add first-class support for YAML documents
  • Loading branch information
Witiko authored Oct 28, 2024
2 parents 4c4138b + 62b7d64 commit 4fa44cd
Show file tree
Hide file tree
Showing 6 changed files with 445 additions and 81 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ Development:

[matrix-514]: https://matrix.to/#/!UeAwznpYwwsinVTetR:matrix.org/$TTc-m7B5NSdsLBNNyIuFWQ-u2nOZ03lJ5js88hnyFiU?via=matrix.org&via=im.f3l.de

- Add first-class support for YAML documents. (#452, #473, #524)
- Add plain TeX macros `\yamlSetup`, `\yamlInput`, `\yamlBegin`, and `\yamlEnd`.
- Add LaTeX environment `yaml` and redefine command `\yamlInput` for LaTeX.
- Add ConTeXt commands `\setupyaml`, `\inputyaml`, `\startyaml`, and `\stopyaml`.

Documentation:

- Document LaTeX hooks. (#464, #507)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ $(LIBRARIES): force
# This target typesets the manual.
$(TECHNICAL_DOCUMENTATION): $(DTXARCHIVE) $(TECHNICAL_DOCUMENTATION_RESOURCES)
latexmk -silent $< || (cat $(basename $@).log 1>&2; exit 1)
test `tail $(basename $<).log | sed -rn 's/.*\(([0-9]*) pages.*/\1/p'` -ge 380
test `tail $(basename $<).log | sed -rn 's/.*\(([0-9]*) pages.*/\1/p'` -ge 450

# This pseudotarget continuously typesets the manual.
preview: $(DTXARCHIVE) $(TECHNICAL_DOCUMENTATION_RESOURCES)
Expand Down
31 changes: 31 additions & 0 deletions examples/context-mkiv.tex
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,37 @@

\starttext

% Set and typeset the document metadata using a YAML metadata block.
\setupyaml
[
jekyllDataRenderers = {
title = {\gdef\doctitle{#1}},
author = {\gdef\author{#1}},
date = {\gdef\date{#1}},
},
renderers = {
jekyllDataEnd = {%
\startalignment[center]
\blank[force,2*big]
{\tfd \doctitle}
\blank[3*medium]
{\tfa \author}
\blank[2*medium]
{\tfa \date}
\blank[3*medium]
\stopalignment
},
},
]

\startyaml

title: An Example *Markdown* Document
author: Vít Starý Novotný
date: `\currentdate`{=tex}

\stopyaml

% Typeset the document `example.md` by letting the Markdown package handle
% the conversion internally. Optionally, we can specify additional options
% between the square brackets similarly to the command `\setupmarkdown`.
Expand Down
9 changes: 3 additions & 6 deletions examples/latex-luatex.tex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
fencedCode,
hashEnumerators,
inlineNotes,
jekyllData,
lineBlocks,
notes,
pipeTables,
Expand All @@ -28,13 +27,11 @@
texMathSingleBackslash,
]{markdown}
% Set the document metadata using a YAML metadata block.
\begin{markdown}[hybrid]
---
\begin{yaml}
title: An Example *Markdown* Document
author: Vít Starý Novotný
date: \today
---
\end{markdown}
date: `\today`{=tex}
\end{yaml}
\begin{document}
% Typeset the document `example.md` by letting the Markdown package handle
% the conversion internally.
Expand Down
9 changes: 3 additions & 6 deletions examples/latex-pdftex.tex
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
fencedCode,
hashEnumerators,
inlineNotes,
jekyllData,
lineBlocks,
notes,
pipeTables,
Expand All @@ -29,13 +28,11 @@
texMathSingleBackslash,
]{markdown}
% Set the document metadata using a YAML metadata block.
\begin{markdown}[hybrid]
---
\begin{yaml}
title: An Example *Markdown* Document
author: Vít Starý Novotný
date: \today
---
\end{markdown}
date: `\today`{=tex}
\end{yaml}
\begin{document}
% Typeset the document `example.md` by letting the Markdown package handle
% the conversion internally.
Expand Down
Loading

0 comments on commit 4fa44cd

Please sign in to comment.