diff options
author | Karl Berry <karl@freefriends.org> | 2023-01-30 20:49:50 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-01-30 20:49:50 +0000 |
commit | c79b6e8de73216421aaab3099383f6d69c3aa01c (patch) | |
tree | 5b38b3817f9ad94e7ef469585eaa543ed74e81aa /Master/texmf-dist/source | |
parent | 1b69cff971f4d00759ccead9d6c3a808668e3f50 (diff) |
naive-ebnf (30jan23)
git-svn-id: svn://tug.org/texlive/trunk@65689 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r-- | Master/texmf-dist/source/latex/naive-ebnf/naive-ebnf.dtx | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/Master/texmf-dist/source/latex/naive-ebnf/naive-ebnf.dtx b/Master/texmf-dist/source/latex/naive-ebnf/naive-ebnf.dtx index 6213cf6d529..cdd047a30f0 100644 --- a/Master/texmf-dist/source/latex/naive-ebnf/naive-ebnf.dtx +++ b/Master/texmf-dist/source/latex/naive-ebnf/naive-ebnf.dtx @@ -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@color{gray}{"}#1\ebnf@color{gray}{"}} + \ebnf@color{gray}{\relax\ifmmode\textsf{``}\else{\sffamily``}\fi}% + #1% + \ebnf@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@color{gray}{\langle}\textsf{#1}\ebnf@color{gray}{\rangle}\)} +\newcommand\nonterminal[1]{% + \ebnf@color{gray}{\relax\ifmmode\langle\else\(\langle\)\fi}% + \relax\ifmmode\textsf{#1}\else{\sffamily#1}\fi% + \ebnf@color{gray}{\relax\ifmmode\rangle\else\(\rangle\)\fi}} \makeatother % \end{macrocode} % \end{macro} |