texlive[65689] Master/texmf-dist: naive-ebnf (30jan23)

commits+karl at tug.org commits+karl at tug.org
Mon Jan 30 21:49:50 CET 2023


Revision: 65689
          http://tug.org/svn/texlive?view=revision&revision=65689
Author:   karl
Date:     2023-01-30 21:49:50 +0100 (Mon, 30 Jan 2023)
Log Message:
-----------
naive-ebnf (30jan23)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/naive-ebnf/naive-ebnf.pdf
    trunk/Master/texmf-dist/source/latex/naive-ebnf/naive-ebnf.dtx
    trunk/Master/texmf-dist/tex/latex/naive-ebnf/naive-ebnf.sty

Modified: trunk/Master/texmf-dist/doc/latex/naive-ebnf/naive-ebnf.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/naive-ebnf/naive-ebnf.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/naive-ebnf/naive-ebnf.dtx	2023-01-30 20:49:28 UTC (rev 65688)
+++ trunk/Master/texmf-dist/source/latex/naive-ebnf/naive-ebnf.dtx	2023-01-30 20:49:50 UTC (rev 65689)
@@ -50,7 +50,7 @@
 %<package>\NeedsTeXFormat{LaTeX2e}
 %<package>\ProvidesPackage{naive-ebnf}
 %<*package>
-[2023-01-29 0.0.2 EBNF in Plain Text]
+[2023-01-30 0.0.3 EBNF in Plain Text]
 %</package>
 %<*driver>
 \documentclass{ltxdoc}
@@ -81,7 +81,7 @@
 %
 % \section{Introduction}
 %
-% This package helps render a
+% This package helps render an
 % \href{https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form}{Extended Backus-Naur Form}
 % using plain text notation:
 % \begin{docshot}
@@ -97,6 +97,8 @@
 % \end{document}
 % \end{docshot}
 
+% \DescribeMacro{ebnf}
+% The |ebnf| environment \emph{doesn't} add any formatting to the paragraph, but only replaces the plain text symbols, such as ``|:=|'' and ``|<Var>|'' with proper \LaTeX{} commands.
 % The following syntax is understood inside the |ebnf| environment:
 % \begin{itemize}
 % \item |:=| separates the left-hand side from the right-hand side of the production rule;
@@ -133,6 +135,19 @@
 % with \terminal{)}.
 % \end{document}
 % \end{docshot}
+% It's possible to use them in math-mode too, for example:
+% \docshotOptions{firstline=6,lastline=8}
+% \begin{docshot}
+% \documentclass{article}
+% \pagestyle{empty}
+% \usepackage[paperwidth=3in]{geometry}
+% \usepackage{naive-ebnf}
+% \begin{document}
+% If $\terminal{(} f_1 \nonterminal{Var}
+% \terminal{)}$ is always true, then
+% $f_1$ is a tautology.
+% \end{document}
+% \end{docshot}
 
 % \section{Package Options}
 
@@ -187,12 +202,15 @@
 
 % \begin{macro}{\terminal}
 % \changes{0.0.2}{2023/01/29}{New command \texttt{\char`\\terminal} added, to enable rendering terminal symbols outside of the \texttt{ebnf} environment.}
+% \changes{0.0.3}{2023/01/30}{Quotes fixed in both text and math modes.}
 % Then, we a command to render a single terminal:
 %    \begin{macrocode}
 \makeatletter
-\newcommand\terminal[1]{%
+\newcommand\terminal[1]{{%
   \relax\ifmmode\else\ttfamily\fi%
-  \ebnf at color{gray}{"}#1\ebnf at color{gray}{"}}
+  \ebnf at color{gray}{\relax\ifmmode\textsf{``}\else{\sffamily``}\fi}%
+  #1%
+  \ebnf at color{gray}{\relax\ifmmode\textsf{''}\else{\sffamily''}\fi}}}
 \makeatother
 %    \end{macrocode}
 % \end{macro}
@@ -202,8 +220,10 @@
 % Then, we a command to render a single non-terminal:
 %    \begin{macrocode}
 \makeatletter
-\newcommand\nonterminal[1]
-  {\(\ebnf at color{gray}{\langle}\textsf{#1}\ebnf at color{gray}{\rangle}\)}
+\newcommand\nonterminal[1]{%
+  \ebnf at color{gray}{\relax\ifmmode\langle\else\(\langle\)\fi}%
+  \relax\ifmmode\textsf{#1}\else{\sffamily#1}\fi%
+  \ebnf at color{gray}{\relax\ifmmode\rangle\else\(\rangle\)\fi}}
 \makeatother
 %    \end{macrocode}
 % \end{macro}

Modified: trunk/Master/texmf-dist/tex/latex/naive-ebnf/naive-ebnf.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/naive-ebnf/naive-ebnf.sty	2023-01-30 20:49:28 UTC (rev 65688)
+++ trunk/Master/texmf-dist/tex/latex/naive-ebnf/naive-ebnf.sty	2023-01-30 20:49:50 UTC (rev 65689)
@@ -31,7 +31,7 @@
 
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage{naive-ebnf}
-[2023-01-29 0.0.2 EBNF in Plain Text]
+[2023-01-30 0.0.3 EBNF in Plain Text]
 
 
 
@@ -60,14 +60,18 @@
 \makeatother
 
 \makeatletter
-\newcommand\terminal[1]{%
+\newcommand\terminal[1]{{%
   \relax\ifmmode\else\ttfamily\fi%
-  \ebnf at color{gray}{"}#1\ebnf at color{gray}{"}}
+  \ebnf at color{gray}{\relax\ifmmode\textsf{``}\else{\sffamily``}\fi}%
+  #1%
+  \ebnf at color{gray}{\relax\ifmmode\textsf{''}\else{\sffamily''}\fi}}}
 \makeatother
 
 \makeatletter
-\newcommand\nonterminal[1]
-  {\(\ebnf at color{gray}{\langle}\textsf{#1}\ebnf at color{gray}{\rangle}\)}
+\newcommand\nonterminal[1]{%
+  \ebnf at color{gray}{\relax\ifmmode\langle\else\(\langle\)\fi}%
+  \relax\ifmmode\textsf{#1}\else{\sffamily#1}\fi%
+  \ebnf at color{gray}{\relax\ifmmode\rangle\else\(\rangle\)\fi}}
 \makeatother
 
 \makeatletter



More information about the tex-live-commits mailing list.