Skip to content

Commit

Permalink
Separate example files for pdfLaTeX, XeLaTeX, LuaLaTeX, and TeX4ht
Browse files Browse the repository at this point in the history
  • Loading branch information
Witiko committed Apr 14, 2023
1 parent cf96f7c commit e65f9af
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 42 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,18 @@ examples/latex-luatex.aux
examples/latex-luatex.log
examples/latex-luatex.markdown.in
examples/latex-luatex.pdf
examples/latex-luatex.tex
examples/latex-pdftex.aux
examples/latex-pdftex.log
examples/latex-pdftex.markdown.in
examples/latex-pdftex.markdown.lua
examples/latex-pdftex.markdown.out
examples/latex-pdftex.pdf
examples/latex-pdftex.tex
examples/latex-xetex.aux
examples/latex-xetex.log
examples/latex-xetex.markdown.in
examples/latex-xetex.markdown.lua
examples/latex-xetex.markdown.out
examples/latex-xetex.pdf
examples/latex-xetex.tex
examples/_markdown_context-mkii/
examples/_markdown_context-mkiv/
examples/_markdown_example/
Expand Down
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Documentation:

- Add a link to a preprint from TUGboat 44(1) to `README.md`.
(#234, a4d9fbf)
- Separate example files for pdfLaTeX, XeLaTeX, LuaLaTeX, and
TeX4ht. (#291)

Refactoring:

Expand Down
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ CTANARCHIVE=markdown.ctan.zip
DISTARCHIVE=markdown.zip
ARCHIVES=$(TDSARCHIVE) $(CTANARCHIVE) $(DISTARCHIVE)
EXAMPLES_RESOURCES=examples/example.md examples/scientists.csv
EXAMPLES_SOURCES=examples/context-mkii.tex examples/context-mkiv.tex examples/latex.tex
EXAMPLES_SOURCES=examples/context-mkii.tex examples/context-mkiv.tex \
examples/latex-pdftex.tex examples/latex-xetex.tex examples/latex-luatex.tex
EXAMPLES=examples/context-mkii.pdf examples/context-mkiv.pdf \
examples/latex-pdftex.pdf examples/latex-luatex.pdf \
examples/latex-pdftex.pdf examples/latex-xetex.pdf examples/latex-luatex.pdf \
examples/latex-tex4ht.html examples/latex-tex4ht.css
TESTS=tests/test.sh tests/support/*.tex tests/templates/*/*.tex.m4 \
tests/templates/*/COMMANDS.m4 tests/testfiles/*/*.test
Expand Down Expand Up @@ -183,23 +184,23 @@ $(TDSARCHIVE): $(DTXARCHIVE) $(INSTALLER) $(INSTALLABLES) $(DOCUMENTATION) $(EXA
cp $(DOCUMENTATION) doc/generic/markdown/
cp examples/context-mkii.tex examples/context-mkiv.tex $(EXAMPLES_RESOURCES) \
doc/context/third/markdown/examples/
cp examples/latex.tex $(EXAMPLES_RESOURCES) doc/latex/markdown/examples/
cp -L examples/latex-*.tex $(EXAMPLES_RESOURCES) doc/latex/markdown/examples/
@# Installing the sources.
mkdir -p source/generic/markdown
cp $(DTXARCHIVE) $(INSTALLER) source/generic/markdown
zip -r -v -nw $@ doc scripts source tex
zip -MM -r -v -nw $@ doc scripts source tex
rm -rf doc scripts source tex

# This target produces the distribution archive.
$(DISTARCHIVE): $(EVERYTHING) $(TDSARCHIVE)
-ln -s . markdown
zip -MM -r -v -nw $@ $(addprefix markdown/,$(EVERYTHING)) $(TDSARCHIVE)
zip -MM -r -v -nw --symlinks $@ $(addprefix markdown/,$(EVERYTHING)) $(TDSARCHIVE)
rm -f markdown

# This target produces the CTAN archive.
$(CTANARCHIVE): $(DTXARCHIVE) $(INSTALLER) $(DOCUMENTATION) $(EXAMPLES_RESOURCES) $(EXAMPLES_SOURCES) $(LIBRARIES) $(TDSARCHIVE)
-ln -s . markdown
zip -MM -r -v -nw $@ $(addprefix markdown/,$(DTXARCHIVE) $(INSTALLER) $(DOCUMENTATION) $(EXAMPLES_RESOURCES) $(EXAMPLES_SOURCES) $(LIBRARIES)) $(TDSARCHIVE)
zip -MM -r -v -nw --symlinks $@ $(addprefix markdown/,$(DTXARCHIVE) $(INSTALLER) $(DOCUMENTATION) $(EXAMPLES_RESOURCES) $(EXAMPLES_SOURCES) $(LIBRARIES)) $(TDSARCHIVE)
rm -f markdown

# This pseudo-target removes any existing auxiliary files and directories.
Expand Down
28 changes: 15 additions & 13 deletions examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

AUXFILES=*.tmp *.tui *.tuo *.mp *.tuc *.markdown.in *.markdown.out \
*.markdown.lua *.log *.aux *.dvi *.idv *.lg *.tmp *.xref *.4ct *.4tc \
latex-pdftex.tex latex-luatex.tex latex-tex4ht.tex \
example.tex *.debug-extensions.json debug-extensions.json
AUXDIRS=_markdown_*/
LUACLI_OPTIONS=\
Expand All @@ -27,8 +26,9 @@ LUACLI_OPTIONS=\
texMathDollars=true \
texMathDoubleBackslash=true \
texMathSingleBackslash=true
OUTPUT=context-mkii.pdf context-mkiv.pdf latex-pdftex.pdf \
latex-luatex.pdf latex-tex4ht.html latex-tex4ht.css
OUTPUT=context-mkii.pdf context-mkiv.pdf \
latex-pdftex.pdf latex-xetex.pdf latex-luatex.pdf \
latex-tex4ht.html latex-tex4ht.css

# This is the default pseudo-target.
all: $(OUTPUT)
Expand All @@ -43,20 +43,22 @@ context-mkiv.pdf: context-mkiv.tex example.tex
context context-mkiv.tex

# This target typesets the LaTeX example using the pdfTeX engine.
latex-pdftex.pdf: latex.tex example.tex
cp latex.tex latex-pdftex.tex
pdflatex --shell-escape latex-pdftex
pdflatex --shell-escape latex-pdftex
latex-pdftex.pdf: latex-pdftex.tex example.tex
pdflatex --shell-escape $<
pdflatex --shell-escape $<

# This target typesets the LaTeX example using the XeTeX engine.
latex-xetex.pdf: latex-xetex.tex example.tex
xelatex --shell-escape $<
xelatex --shell-escape $<

# This target typesets the LaTeX example using the LuaTeX engine.
latex-luatex.pdf: latex.tex example.tex
cp latex.tex latex-luatex.tex
lualatex latex-luatex
lualatex latex-luatex
latex-luatex.pdf: latex-luatex.tex example.tex
lualatex $<
lualatex $<

# This target typesets the LaTeX example using TeX4ht.
latex-tex4ht.html latex-tex4ht.css: latex.tex example.tex
cp latex.tex latex-tex4ht.tex
latex-tex4ht.html latex-tex4ht.css: latex-tex4ht.tex example.tex
make4ht --shell-escape latex-tex4ht fn-in

# This target converts the markdown example to a plain TeX representation
Expand Down
18 changes: 3 additions & 15 deletions examples/latex.tex → examples/latex-luatex.tex
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
\documentclass{book}
\usepackage{ifxetex,ifluatex}
\ifxetex
\usepackage{polyglossia}
\setmainlanguage{english}
\usepackage{fontspec}
\else\ifluatex
\usepackage{polyglossia}
\setmainlanguage{english}
\usepackage{fontspec}
\else
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\fi\fi
\usepackage{polyglossia}
\setmainlanguage{english}
\usepackage{fontspec}
\usepackage{booktabs}
\usepackage[
contentBlocks,
Expand Down
73 changes: 73 additions & 0 deletions examples/latex-pdftex.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
\documentclass{book}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{booktabs}
\usepackage[
contentBlocks,
debugExtensions,
definitionLists,
fancy_lists,
fencedCode,
hashEnumerators,
inlineNotes,
jekyllData,
lineBlocks,
notes,
pipeTables,
rawAttribute,
smartEllipses,
strikeThrough,
subscripts,
superscripts,
tableCaptions,
taskLists,
texMathDollars,
texMathDoubleBackslash,
texMathSingleBackslash,
]{markdown}
\begin{markdown*}{hybrid}
---
title: An Example *Markdown* Document
author: Vít Novotný
date: \today
---
\end{markdown*}
\begin{document}
% Typeset the document `example.md` by letting the Markdown package handle
% the conversion internally.
\markdownInput{./example.md}

% Typeset the document `example.tex` that we prepared separately using the
% Lua command-line interface of the Markdown package and that contains a
% plain TeX representation of the document `example.md`.
\catcode`\%=12\relax
\catcode`\#=12\relax
\InputIfFileExists{./example.tex}{}{}
\catcode`\%=14\relax
\catcode`\#=6\relax

\begin{markdown}
Here are some non-ASCII characters: *ěščřžýáíé*.
\end{markdown}

\begin{markdown*}{html, hybrid}
Here is some <b>HTML code</b> mixed *with Markdown*. In \TeX, the HTML code
will be silently ignored, whereas in \TeX 4ht, the HTML code will be passed
through to the output:

<table border="1">
<tr>
<td>Emil</td>
<td>Tobias</td>
<td>Linus</td>
</tr>
<tr>
<td>16</td>
<td>14</td>
<td>10</td>
</tr>
</table>
\end{markdown*}
\end{document}
1 change: 1 addition & 0 deletions examples/latex-tex4ht.tex
1 change: 1 addition & 0 deletions examples/latex-xetex.tex
11 changes: 6 additions & 5 deletions markdown.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -1603,13 +1603,14 @@ the Markdown package:
``` sh
git clone https://github.com/witiko/markdown
cd markdown/examples
lualatex latex.tex
lualatex latex-luatex.tex
``````
A PDF document named `latex.pdf` should be produced. Open the text documents
`latex.tex` and `example.md` in a text editor to see how the example documents
are structured. Try changing the documents and typesetting them as follows:
A PDF document named `latex-luatex.pdf` should be produced. Open the text
documents `latex-luatex.tex` and `example.md` in a text editor to see how the
example documents are structured. Try changing the documents and typesetting
them as follows:
``` sh
lualatex latex.tex
lualatex latex-luatex.tex
``````
to see the effect of your changes.

Expand Down

0 comments on commit e65f9af

Please sign in to comment.