From: "Vít Novotný" <witiko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Plain TeX writer
Date: Wed, 19 Oct 2022 06:59:04 -0700 (PDT) [thread overview]
Message-ID: <51539828-c876-437b-bb1e-a5efcf752762n@googlegroups.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 5029 bytes --]
In pull request #1541 <https://github.com/jgm/pandoc/issues/1541>, John
MacFarlane floated the idea of having a Pandoc writer whose output could be
“processed by plain tex (or perhaps eplain), without latex or context
macros.” In their proof of concept
<https://github.com/drehak/pandoc-to-markdown>, Dominik Rehák
<https://github.com/drehak> explores what this would look like in practice.
Dominik’s proof of concept contains a custom Lua writer
pandoc-to-markdown.lua that you can use as follows:
*$ cat > example.md*Under his pillow P'raps found
~~A cake that weighed a half a pound.~~
A plenty of space to roll around.
$ pandoc -i example.md -f pandoc-to-markdown.lua -o example.tex
*$ cat example.tex*\pandocDocumentBegin
Under\pandocSpace{}his\pandocSpace{}pillow\pandocSpace{}P’raps\pandocSpace{}found\pandocLineBreak
\pandocStrikeout{A\pandocSpace{}cake\pandocSpace{}that\pandocSpace{}weighed\pandocSpace{}a\pandocSpace{}half\pandocSpace{}a\pandocSpace{}pound.}\pandocLineBreak
A\pandocSpace{}plenty\pandocSpace{}of\pandocSpace{}space\pandocSpace{}to\pandocSpace{}roll\pandocSpace{}around.
\pandocDocumentEnd
To typeset the example document, you can use a macro package that defines
how the various \pandoc... commands should be formatted. For LaTeX, the
proof of concept contains the pandoc-to-markdown.sty style file that you
can use as follows:
*$ cat > example.ltx*\documentclass{article}
\usepackage{pandoc-to-markdown}
\begin{document}
\input example.tex
\end{document}
$ pdflatex example.ltx
Here is the output document example.pdf:
[image: example.png]
The proof-of-concept contains many more examples for you to try out in the
examples/ directory
<https://github.com/drehak/pandoc-to-markdown/tree/main/examples>.
Dominik's work is part of their bachelor's thesis, which is to appear this
fall. Dominik has already published two articles about their work in
hobbyist journals: the CSTUG Bulletin 31:1–4
<https://www.cstug.cz/bulletin/pdf/2021-1-4.pdf#page=85> (in Slovak, see a
machine translation to English
<https://translate.google.com/translate?sl=auto&tl=en&u=https://www.fi.muni.cz/~xnovot32/bulletin/2021-1-4/06-rehak-pandoc/&client=webapp>)
and in TUGboat 43:1
<https://www.tug.org/TUGboat/tb43-1/tb133novotny-markdown.pdf#page=3> (see
Section 2.3). The implementation rests on my Markdown package for TeX
<https://ctan.org/pkg/markdown>, which provides formatting for most
elements of the Pandoc AST across different TeX formats such as plain TeX,
LaTeX, and ConTeXt.
Here are some limitations of the proof of concept:
-
For the sake of convenience, some of the \pandoc... commands that we
produce are in a form that closely mimics the commands provided by the
Markdown package rather than Pandoc’s AST. For example, the \pandocCode,
\pandocLink, and \pandocHeader commands discard attributes, the
\pandocImage and \pandocCaptionedImage commands receive parameters with
TeX’s special characters escaped in a way required by the Markdown package,
and the LineBlock element of Pandoc’s AST is simulated by a series of
\pandocLineBreak commands.
In the future, we would like to make the \pandoc... commands closer to
the Pandoc’s AST, so that a lossless round trip from AST to TeX and back is
possible. In TeX, we can process text using regular expressions (see the
l3regex module of the expl3 macro package
<https://www.ctan.org/pkg/l3kernel>), which allows us to move most
parameter preprocessing code from our Lua writer to the definitions of the
\pandoc… commands.
-
The custom Lua writer pandoc-to-markdown.lua uses the old-style custom
Lua writer API that will no longer be supported in Pandoc 3.0.0. We would
like to rewrite the custom Lua write to Haskell, so that it can become an
integral part of Pandoc independent of Pandoc’s Lua API.
In the future, the ConTeXt and LaTeX writers of Pandoc could be replaced
by a single writer that would produce format-agnostic TeX code. Formatting
for the TeX code would then be provided by format-specific TeX macro
packages such as the pandoc-to-markdown.sty style file for LaTeX. This
approach will reduce the amount of code maintained by Pandoc and increase
the number of supported TeX formats, which is a win-win for both Pandoc
maintainers and Pandoc users. Both Dominik and I would be happy to discuss
with you how to best get there.
--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/51539828-c876-437b-bb1e-a5efcf752762n%40googlegroups.com.
[-- Attachment #1.2: Type: text/html, Size: 7204 bytes --]
[-- Attachment #2: example.png --]
[-- Type: image/png, Size: 30143 bytes --]
next reply other threads:[~2022-10-19 13:59 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-19 13:59 Vít Novotný [this message]
[not found] ` <51539828-c876-437b-bb1e-a5efcf752762n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-10-19 15:43 ` John MacFarlane
[not found] ` <84C142C7-20EF-411E-AF94-D0AA008FA9DA-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-10-19 16:21 ` Vít Novotný
[not found] ` <5e9dfe75-ea0e-4287-a6a0-47842700f292n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-10-20 8:05 ` Bastien DUMONT
2022-10-20 9:13 ` Vít Novotný
[not found] ` <a7d769e7-083c-4cb9-a9a2-b5a21b62c8f0n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-10-20 9:53 ` Bastien DUMONT
2022-10-20 10:32 ` Vít Novotný
[not found] ` <782726a4-9890-4396-9696-4f5a349f9885n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-10-20 10:43 ` Bastien DUMONT
2022-10-26 20:09 ` Vít Novotný
[not found] ` <24c01860-2f35-4ff0-9d31-63d10f764f79n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-10-27 0:24 ` John MacFarlane
[not found] ` <1EC34FB9-2344-40AC-91CD-22B3D9069EE6-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-10-27 7:07 ` Bastien DUMONT
2022-10-27 17:09 ` John MacFarlane
[not found] ` <B180C2FD-5AD9-47F2-8E5D-8133CCD8CE00-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-11-02 14:17 ` Vít Novotný
[not found] ` <9dfc8b26-3fda-4882-93b7-06d44671ef7fn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-11-02 14:23 ` 'William Lupton' via pandoc-discuss
[not found] ` <CAEe_xxiYD8Y5KJVB7WiKOo5xHbFWPq010rMXJEYsu_XNd-hX4A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-11-02 14:35 ` Vít Novotný
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51539828-c876-437b-bb1e-a5efcf752762n@googlegroups.com \
--to=witiko-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).