From 605ae8fdee7eecd86ef7470d15dfb8043b1d98fa Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 5 Dec 2024 17:10:00 +0300 Subject: [PATCH 1/3] docs(manual): Add comment about default verbatim font --- packages/verbatim/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/verbatim/init.lua b/packages/verbatim/init.lua index 549f1dea9..ec8954f93 100644 --- a/packages/verbatim/init.lua +++ b/packages/verbatim/init.lua @@ -58,6 +58,7 @@ end \end{raw} If you want to specify what font the verbatim environment should use, you can redefine the \autodoc:command{\verbatim:font} command. +Unless otherwise set, the default verbatim font will be \em{Hack}. For example you could change it from XML like this: \begin[type=autodoc:codeblock]{raw} From 46b01644e72f80a3b1820b7b157f995ade5a3c29 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 5 Dec 2024 17:35:57 +0300 Subject: [PATCH 2/3] feat(packages): Add handler for passing raw content to verbatim --- packages/verbatim/init.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/verbatim/init.lua b/packages/verbatim/init.lua index ec8954f93..a78f3df85 100644 --- a/packages/verbatim/init.lua +++ b/packages/verbatim/init.lua @@ -39,6 +39,12 @@ function package:registerCommands () end) end +function package:registerRawHandlers () + self:registerRawHandler("verbatim", function (options, content) + SILE.call("verbatim", options, { content[1] }) + end) +end + package.documentation = [[ \begin{document} The \autodoc:package{verbatim} package is useful when quoting pieces of computer code and other text for which formatting is significant. From 5c4d91b9a0e9d2e99dbe3c1e21fe6b73bf1dd78c Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 5 Dec 2024 17:46:20 +0300 Subject: [PATCH 3/3] docs(manual): Document how to pair `\raw` with `\verbatim` --- packages/verbatim/init.lua | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/verbatim/init.lua b/packages/verbatim/init.lua index a78f3df85..690e41a79 100644 --- a/packages/verbatim/init.lua +++ b/packages/verbatim/init.lua @@ -52,7 +52,9 @@ It changes SILE’s settings so that text is set ragged right, with no hyphenati It tells SILE to honor multiple spaces, and sets a monospaced font. \autodoc:note{Despite the name, \autodoc:environment{verbatim} does not alter the way that SILE sees special characters. -You still need to escape backslashes and braces: to produce a backslash, you need to write \code{\\\\}.} +You still need to escape backslashes and braces: to produce a backslash, you need to write \code{\\\\}. +See the use of the \\autodoc:environment{raw} with a verbatim type handler for more literal verbatim behavior. +} Here is some text set in the \autodoc:environment{verbatim} environment: @@ -72,6 +74,22 @@ For example you could change it from XML like this: \end{raw} + +This handles spaces, newlines, tabs and other similar whitespace literally in a way that SILE would otherwise have handled specially. +If additionally you want to ignore nested SILE content (e.g. SIL commands in SIL) then you need to use a raw enviroment instead: + +\begin[type=autodoc:codeblock]{raw} +\begin[type=verbatim]{raw} +Sile commands like \em{emphasis} will not be intercepted. +\end‌{raw} +\end{raw} + +Displays as: + +\begin[type=verbatim]{raw} +Sile commands like \em{emphasis} will not be intercepted. +\end{raw} + \end{document} ]]