texlive[65032] Master/texmf-dist: ffcode (16nov22)
commits+karl at tug.org
commits+karl at tug.org
Wed Nov 16 22:25:05 CET 2022
Revision: 65032
http://tug.org/svn/texlive?view=revision&revision=65032
Author: karl
Date: 2022-11-16 22:25:04 +0100 (Wed, 16 Nov 2022)
Log Message:
-----------
ffcode (16nov22)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/ffcode/DEPENDS.txt
trunk/Master/texmf-dist/doc/latex/ffcode/ffcode.pdf
trunk/Master/texmf-dist/source/latex/ffcode/ffcode.dtx
trunk/Master/texmf-dist/tex/latex/ffcode/ffcode.sty
Modified: trunk/Master/texmf-dist/doc/latex/ffcode/DEPENDS.txt
===================================================================
--- trunk/Master/texmf-dist/doc/latex/ffcode/DEPENDS.txt 2022-11-16 21:24:50 UTC (rev 65031)
+++ trunk/Master/texmf-dist/doc/latex/ffcode/DEPENDS.txt 2022-11-16 21:25:04 UTC (rev 65032)
@@ -1,3 +1,3 @@
-hard xkeyval
+hard pgfopts
hard minted
hard tcolorbox
Modified: trunk/Master/texmf-dist/doc/latex/ffcode/ffcode.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/source/latex/ffcode/ffcode.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/ffcode/ffcode.dtx 2022-11-16 21:24:50 UTC (rev 65031)
+++ trunk/Master/texmf-dist/source/latex/ffcode/ffcode.dtx 2022-11-16 21:25:04 UTC (rev 65032)
@@ -50,7 +50,7 @@
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{ffcode}
%<*package>
-[2022-10-30 0.5.1 Fixed Font Code]
+[2022-11-16 0.6.0 Fixed Font Code]
%</package>
%<*driver>
\documentclass{ltxdoc}
@@ -93,8 +93,7 @@
% \usepackage{ffcode}
% \pagestyle{empty}
% \begin{document}
-% The function \ff{fibo()}
-% is recursive:
+% The function |fibo()| is recursive:
% \begin{ffcode}
% int fibo(int n) {
% if (n < 2) {
@@ -103,8 +102,8 @@
% return fibo(n-1)+fibo(n-2);
% }
% \end{ffcode}
-% The line no.~\ref{ln:ret}
-% terminates it.
+% Line no.~\ref{ln:ret} returns \ff{n}
+% and terminates it.
% \end{document}
% \end{docshot}
@@ -141,10 +140,11 @@
% A pair of vertical lines decorate a TeX command inside the snippet.
% If you want to print a single vertical line, use this:
-% \ff{|\char`\\vert|}.
+% ``\verb+|\char`\\vert|+''.
% The command |\ff| behaves differently in math mode --- it doesn't
% add gray frames:
+% \docshotOptions{firstline=6,lastline=8}
% \begin{docshot}
% \documentclass{article}
% \usepackage{ffcode}
@@ -152,7 +152,7 @@
% \pagestyle{empty}
% \begin{document}
% \begin{equation*}
-% x = \int_\ff{home}^N f(x).
+% x = \int_{|home|}^N f(x).
% \end{equation*}
% \end{document}
% \end{docshot}
@@ -162,6 +162,7 @@
% You can highlight some lines in your |ffcode| environment,
% or can use any other additional configuration parameters from
% |minted| package:
+% \docshotOptions{firstline=6,lastline=13}
% \begin{docshot}
% \documentclass{article}
% \usepackage[paperwidth=3in]{geometry}
@@ -168,8 +169,7 @@
% \usepackage{ffcode}
% \pagestyle{empty}
% \begin{document}
-% \begin{ffcode*}
-% {highlightlines={1,4-5}}
+% \begin{ffcode*}{highlightlines={1,4-5}}
% while (true) {
% print("Hello!")
% print("Enter your name:")
@@ -189,29 +189,36 @@
% \section{Implementation}
% \changes{v0.1.0}{2021/06/10}{Initial version}
-% First, we parse package options:
+% First, we parse package options with the help of
+% \href{https://ctan.org/pkg/pgfopts}{pgfopts} package:
+% \changes{v0.2.0}{2021/06/13}{Package options \texttt{nonumbers} and \texttt{noframes} added.}
+% \changes{v0.3.0}{2021/09/07}{Package option \texttt{nocn} added.}
+% \changes{v0.4.0}{2022/01/09}{Package option \texttt{nobars} added.}
+% \changes{v0.6.0}{2021/11/14}{We use \texttt{pgfopts} instead of \texttt{xkeyval}.}
+% \changes{v0.6.0}{2021/11/14}{Package option \texttt{novert} added, to disable redefinition of vertical bar.}
% \begin{macrocode}
-\RequirePackage{xkeyval}
-\makeatletter
-\DeclareOptionX{nopygments}{\PassOptionsToPackage{draft=true}{minted}}
-\newif\ifff at noframes
-\DeclareOptionX{noframes}{\ff at noframestrue}
-% \changes{v0.4.0}{2022/01/09}{Package option "nobars" added.}
-\newif\ifff at nobars
-\DeclareOptionX{nobars}{\ff at nobarstrue}
-% \changes{v0.2.0}{2021/06/13}{Package options "nonumbers"
-% and "noframes" added.}
-\newif\ifff at nonumbers
-\DeclareOptionX{nonumbers}{\ff at nonumberstrue}
-% \changes{v0.3.0}{2021/09/07}{Package option "nocn" added.}
-\newif\ifff at nocn
-\DeclareOptionX{nocn}{\ff at nocntrue}
-\ProcessOptionsX\relax
-\makeatother
+\RequirePackage{pgfopts}
+\pgfkeys{
+ /ff/.cd,
+ nopygments/.store in=\ff at nopygments,
+ noframes/.store in=\ff at noframes,
+ nonumbers/.store in=\ff at nonumbers,
+ nobars/.store in=\ff at nobars,
+ novert/.store in=\ff at novert,
+ nocn/.store in=\ff at nocn,
+}
+\ProcessPgfOptions{/ff}
% \end{macrocode}
-% Then, we configure |minted| package:
+% Then, we disable pygments for \href{https://ctan.org/pkg/minted}{minted}, if necessary:
% \begin{macrocode}
+\makeatletter\ifdefined\ff at nopygments
+ \PassOptionsToPackage{draft=true}{minted}
+\fi\makeatother
+% \end{macrocode}
+
+% Then, we configure \href{https://ctan.org/pkg/minted}{minted} package:
+% \begin{macrocode}
\RequirePackage{minted}
\setminted{breaklines}
\setminted{escapeinside=||,mathescape}
@@ -222,8 +229,8 @@
% \begin{macro}{ffcode}
% Then, we define |ffcode| environment:
% \begin{macrocode}
-\makeatletter\ifff at nonumbers
- \ifff at nobars
+\makeatletter\ifdefined\ff at nonumbers
+ \ifdefined\ff at nobars
\newminted[ffcode]{text}{}
\else
\newminted[ffcode]{text}{framesep=6pt,
@@ -232,8 +239,8 @@
\else
\renewcommand{\theFancyVerbLine}{\textcolor{gray}%
{\tiny\oldstylenums{\ttfamily\arabic{FancyVerbLine}}}}
- \ifff at nocn
- \ifff at nobars
+ \ifdefined\ff at nocn
+ \ifdefined\ff at nobars
\newminted[ffcode]{text}{
linenos,numbersep=2pt
}
@@ -244,7 +251,7 @@
}
\fi
\else
- \ifff at nobars
+ \ifdefined\ff at nobars
\newminted[ffcode]{text}{
firstnumber=last,linenos,numbersep=2pt
}
@@ -260,12 +267,11 @@
% \end{macro}
% \begin{macro}{\ff at print}
-% Then, we define supplementary commands |\ff at print| and |\ff at printx|:
-% \changes{v0.5.1}{2022/10/30}{Now, the command "ff" ignores italic and bold and always prints "texttt" as it should be.}
+% Then, we define a supplementary macro |\ff at print|:
+% \changes{v0.5.1}{2022/10/30}{Now, the command \texttt{ff} ignores italic and bold and always prints \texttt{\char`\\texttt} as it should be.}
% \begin{macrocode}
\makeatletter
-\newcommand\ff at print{\begingroup\obeyspaces\ff at printx}
-\newcommand\ff at printx[1]{\textnormal{\texttt{#1}}\endgroup}
+\newcommand\ff at print[1]{\textnormal{\texttt{#1}}}
\makeatother
% \end{macrocode}
% \end{macro}
@@ -279,22 +285,60 @@
% \end{macrocode}
% \end{macro}
-% \begin{macro}{\ff}
-% Finally, we define |\ff| command:
+% \begin{macro}{tcolorbox}
+% Then, we use \href{https://ctan.org/pkg/tcolorbox}{tcolorbox} to define |\ff at box|
+% command for a gray box around verbatim text block:
% \begin{macrocode}
-\makeatletter\ifff at noframes
- \newcommand\ff[1]{\ff at rule\ff at print{#1}}
-\else
+\makeatletter
+\ifdefined\ff at noframes\else
\RequirePackage{tcolorbox}
- \newtcbox\ff at box{nobeforeafter,colframe=gray!80!white,
+ \newtcbox\ff at box{nobeforeafter,colframe=gray!80!white,
colback=gray!5!white,boxrule=0.1pt,arc=1pt,
boxsep=1.2pt,left=0.5pt,right=0.5pt,top=0.2pt,bottom=0.2pt,
tcbox raise base}
- \newcommand\ff[1]{\relax\ifmmode%
- {\ff at rule\ff at print{#1}}%
+\fi
+\makeatother
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{\ff at x}
+% Then, we define |\ff at x| internal command for printing a piece of fixed-width-font text:
+% \begin{macrocode}
+\makeatletter
+\NewDocumentCommand\ff at x{v}{%
+ \ifdefined\ff at noframes%
+ \ff at rule\ff at print{#1}%
\else%
- {\ff at box{\ff at rule\ff at print{#1}}}%
- \fi}
+ \relax\ifmmode%
+ \ff at rule\ff at print{#1}%
+ \else%
+ \ff at box{\ff at rule\ff at print{#1}}%
+ \fi%
+ \fi%
+}
+\makeatother
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{\ff}
+% Then, we define |\ff| macro:
+% \begin{macrocode}
+\makeatletter
+\def\ff{\ff at x}
+\makeatother
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{novert}
+% Finally, we let vertical bars work similar to |\ff|, as suggested
+% \href{https://tex.stackexchange.com/a/665105/1449}{here}
+% and \href{https://tex.stackexchange.com/a/665303/1449}{here}
+% (unless |novert| package option is used):
+% \begin{macrocode}
+\makeatletter\ifdefined\ff at novert\else
+ \catcode`\|\active
+ \AtBeginDocument{\catcode`\|\active\protected\def|{\ff at x|}}
+ \catcode`\| 12 %
\fi\makeatother
% \end{macrocode}
% \end{macro}
Modified: trunk/Master/texmf-dist/tex/latex/ffcode/ffcode.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/ffcode/ffcode.sty 2022-11-16 21:24:50 UTC (rev 65031)
+++ trunk/Master/texmf-dist/tex/latex/ffcode/ffcode.sty 2022-11-16 21:25:04 UTC (rev 65032)
@@ -31,7 +31,7 @@
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{ffcode}
-[2022-10-30 0.5.1 Fixed Font Code]
+[2022-11-16 0.6.0 Fixed Font Code]
@@ -49,20 +49,22 @@
-\RequirePackage{xkeyval}
-\makeatletter
-\DeclareOptionX{nopygments}{\PassOptionsToPackage{draft=true}{minted}}
-\newif\ifff at noframes
-\DeclareOptionX{noframes}{\ff at noframestrue}
-\newif\ifff at nobars
-\DeclareOptionX{nobars}{\ff at nobarstrue}
-\newif\ifff at nonumbers
-\DeclareOptionX{nonumbers}{\ff at nonumberstrue}
-\newif\ifff at nocn
-\DeclareOptionX{nocn}{\ff at nocntrue}
-\ProcessOptionsX\relax
-\makeatother
+\RequirePackage{pgfopts}
+\pgfkeys{
+ /ff/.cd,
+ nopygments/.store in=\ff at nopygments,
+ noframes/.store in=\ff at noframes,
+ nonumbers/.store in=\ff at nonumbers,
+ nobars/.store in=\ff at nobars,
+ novert/.store in=\ff at novert,
+ nocn/.store in=\ff at nocn,
+}
+\ProcessPgfOptions{/ff}
+\makeatletter\ifdefined\ff at nopygments
+ \PassOptionsToPackage{draft=true}{minted}
+\fi\makeatother
+
\RequirePackage{minted}
\setminted{breaklines}
\setminted{escapeinside=||,mathescape}
@@ -69,8 +71,8 @@
\setminted{highlightcolor=gray!25}
\usemintedstyle{bw}
-\makeatletter\ifff at nonumbers
- \ifff at nobars
+\makeatletter\ifdefined\ff at nonumbers
+ \ifdefined\ff at nobars
\newminted[ffcode]{text}{}
\else
\newminted[ffcode]{text}{framesep=6pt,
@@ -79,8 +81,8 @@
\else
\renewcommand{\theFancyVerbLine}{\textcolor{gray}%
{\tiny\oldstylenums{\ttfamily\arabic{FancyVerbLine}}}}
- \ifff at nocn
- \ifff at nobars
+ \ifdefined\ff at nocn
+ \ifdefined\ff at nobars
\newminted[ffcode]{text}{
linenos,numbersep=2pt
}
@@ -91,7 +93,7 @@
}
\fi
\else
- \ifff at nobars
+ \ifdefined\ff at nobars
\newminted[ffcode]{text}{
firstnumber=last,linenos,numbersep=2pt
}
@@ -105,8 +107,7 @@
\fi\makeatother
\makeatletter
-\newcommand\ff at print{\begingroup\obeyspaces\ff at printx}
-\newcommand\ff at printx[1]{\textnormal{\texttt{#1}}\endgroup}
+\newcommand\ff at print[1]{\textnormal{\texttt{#1}}}
\makeatother
\makeatletter\newcommand\ff at rule
@@ -113,19 +114,38 @@
{\vrule height 6pt depth 1pt width 0pt}
\makeatother
-\makeatletter\ifff at noframes
- \newcommand\ff[1]{\ff at rule\ff at print{#1}}
-\else
+\makeatletter
+\ifdefined\ff at noframes\else
\RequirePackage{tcolorbox}
- \newtcbox\ff at box{nobeforeafter,colframe=gray!80!white,
+ \newtcbox\ff at box{nobeforeafter,colframe=gray!80!white,
colback=gray!5!white,boxrule=0.1pt,arc=1pt,
boxsep=1.2pt,left=0.5pt,right=0.5pt,top=0.2pt,bottom=0.2pt,
tcbox raise base}
- \newcommand\ff[1]{\relax\ifmmode%
- {\ff at rule\ff at print{#1}}%
+\fi
+\makeatother
+
+\makeatletter
+\NewDocumentCommand\ff at x{v}{%
+ \ifdefined\ff at noframes%
+ \ff at rule\ff at print{#1}%
\else%
- {\ff at box{\ff at rule\ff at print{#1}}}%
- \fi}
+ \relax\ifmmode%
+ \ff at rule\ff at print{#1}%
+ \else%
+ \ff at box{\ff at rule\ff at print{#1}}%
+ \fi%
+ \fi%
+}
+\makeatother
+
+\makeatletter
+\def\ff{\ff at x}
+\makeatother
+
+\makeatletter\ifdefined\ff at novert\else
+ \catcode`\|\active
+ \AtBeginDocument{\catcode`\|\active\protected\def|{\ff at x|}}
+ \catcode`\| 12 %
\fi\makeatother
More information about the tex-live-commits
mailing list.