Skip to content

Commit

Permalink
#21 minted replaced with fancyvrb
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jan 10, 2024
1 parent 022844c commit afbf8d1
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 133 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/l3build.yml
Expand Up @@ -15,14 +15,6 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- run: sudo apt-get install -y python3-pygments && sudo pip3 install pygments
if: matrix.os == 'ubuntu-22.04'
- run: |
pip3 install --upgrade pip
pip3 install pygments
# easy_install Pygments
pygmentize -V
if: matrix.os == 'macos-12'
- run: sudo apt-get -y install ghostscript
if: matrix.os == 'ubuntu-22.04'
- uses: teatimeguest/setup-texlive-action@v3.0.1
Expand Down
3 changes: 2 additions & 1 deletion DEPENDS.txt
@@ -1,4 +1,4 @@
hard minted
hard fancyvrb
hard pgfopts
hard tcolorbox
soft docshots
Expand All @@ -16,4 +16,5 @@ soft pgfopts
soft scheme-basic
soft tools
soft xetex
soft fvextra
soft upquote
1 change: 0 additions & 1 deletion aspell.en.pws
Expand Up @@ -5,4 +5,3 @@ ffcode
LaTeX
fibo
CTAN
Pygments
91 changes: 31 additions & 60 deletions ffcode.dtx
Expand Up @@ -97,7 +97,7 @@
% \begin{ffcode}
% int fibo(int n) {
% if (n < 2) {
% return n; |\label{ln:ret}|
% return n; \label{ln:ret}
% }
% return fibo(n-1)+fibo(n-2);
% }
Expand All @@ -109,12 +109,6 @@

% \section{Package Options}

% \DescribeMacro{nopygments}
% You have to run |pdflatex| with |--shell-escape| flag
% in order to let |minted| (the package we use) to run Pygments
% and format the code. If you don't want this to happen,
% just use |nopygments| option.

% \DescribeMacro{noframes}
% If you want to omit the light gray frames around |\ff|
% texts, use the package option |noframes|.
Expand Down Expand Up @@ -194,27 +188,28 @@

% 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}
% |fancyvrb| and |fvextra| packages:
% \docshotOptions{firstline=7,lastline=14}
% \begin{docshot}
% \documentclass{article}
% \usepackage[paperwidth=3in]{geometry}
% \usepackage{ffcode}
% \usepackage{fvextra}
% \pagestyle{empty}
% \begin{document}
% \begin{ffcode*}{highlightlines={1,4-5}}
% while (true) {
% print("Hello!")
% print("Enter your name:")
% scan(x)
% print("You name is " + x)
% print("You name | " + x)
% }
% \end{ffcode*}
% \end{document}
% \end{docshot}

% Using this second argument of |ffcode*| (with the trailing asterisk),
% you can provide any other options from |minted| package to the
% you can provide any other options from |fancyvrb| package to the
% snippet.

% \StopEventually{}
Expand All @@ -237,7 +232,6 @@
/ff/.cd,
bold/.store in=\ff@bold,
sf/.store in=\ff@sf,
nopygments/.store in=\ff@nopygments,
noframes/.store in=\ff@noframes,
nonumbers/.store in=\ff@nonumbers,
nobars/.store in=\ff@nobars,
Expand All @@ -247,59 +241,36 @@
\ProcessPgfPackageOptions{/ff}
% \end{macrocode}

% Then, we disable pygments for \href{https://ctan.org/pkg/minted}{minted}, if necessary:
% \begin{macrocode}
\makeatletter\ifdefined\ff@nopygments
\PassOptionsToPackage{draft=true}{minted}
\fi\makeatother
% \end{macrocode}

% Then, we configure \href{https://ctan.org/pkg/minted}{minted} package:
% Then, we configure the \href{https://ctan.org/pkg/fancyvrb}{fancyvrb} package:
% \changes{v0.9.0}{2024/01/09}{The \texttt{minted} package is replaced by the \texttt{fancyvrb} package.}
% \begin{macrocode}
\RequirePackage{minted}
\setminted{breaklines}
\setminted{escapeinside=||,mathescape}
\setminted{highlightcolor=gray!25}
\usemintedstyle{bw}
\RequirePackage{xcolor}
\RequirePackage{fancyvrb}
\makeatletter
\def\ff@opts{baselinestretch=1,codes={\catcode`\|=12}}
\ifdefined\ff@nonumbers\else
\edef\ff@opts{\unexpanded\expandafter{\ff@opts},
numbers=left,numbersep=2pt}
\fi
\ifdefined\ff@nobars\else
\edef\ff@opts{\unexpanded\expandafter{\ff@opts},
frame=leftline,framerule=.2pt}\fi
\ifdefined\ff@nocn\else\fi
\makeatother
% \end{macrocode}

% \begin{macro}{ffcode}
% Then, we define |ffcode| environment:
% Then, we define the |ffcode| environment and its supplementary |ffcode*| counterpart:
% \begin{macrocode}
\makeatletter\ifdefined\ff@nonumbers
\ifdefined\ff@nobars
\newminted[ffcode]{text}{}
\else
\newminted[ffcode]{text}{framesep=6pt,
framerule=1pt,rulecolor=gray,frame=leftline}
\fi
\else
\renewcommand{\theFancyVerbLine}{\textcolor{gray}%
{\tiny\oldstylenums{\ttfamily\arabic{FancyVerbLine}}}}
\ifdefined\ff@nocn
\ifdefined\ff@nobars
\newminted[ffcode]{text}{
linenos,numbersep=2pt
}
\else
\newminted[ffcode]{text}{
framesep=6pt,framerule=1pt,rulecolor=gray,
frame=leftline,linenos,numbersep=2pt
}
\fi
\else
\ifdefined\ff@nobars
\newminted[ffcode]{text}{
firstnumber=last,linenos,numbersep=2pt
}
\else
\newminted[ffcode]{text}{
framesep=6pt,framerule=1pt,rulecolor=gray,
frame=leftline,firstnumber=last,linenos,numbersep=2pt
}
\fi
\fi
\fi\makeatother
\makeatletter
\newenvironment{ffcode}
{\VerbatimEnvironment\expanded{\noexpand\begin{Verbatim}[\ff@opts]}%
}{\end{Verbatim}}
\newenvironment{ffcode*}[1]
{\edef\xopts{\unexpanded\expandafter{\ff@opts},#1}
\VerbatimEnvironment\expanded{\noexpand\begin{Verbatim}[\xopts]}%
}{\end{Verbatim}}
\makeatother
% \end{macrocode}
% \end{macro}

Expand Down
9 changes: 0 additions & 9 deletions testfiles/simple.luatex.tlg
@@ -1,14 +1,5 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
runsystem(pygmentize -S bw -f latex -P commandprefix=PYG > _minted-simple-lua/bw.pygstyle)...executed.
(_minted-simple-lua/bw.pygstyle)
runsystem(pygmentize -l 'text' -f latex -P commandprefix=PYG -F tokenmerge -P stripnl='False' -P escapeinside='||' -P mathescape='True' -o _minted-simple-lua/677FC047998CC2207A0E8277AD996845D25CC8B59E59840920DBB35654E4BCFA.pygtex simple.pyg)...executed.
(_minted-simple-lua/677FC047998CC2207A0E8277AD996845D25CC8B59E59840920DBB35654E4BCFA.pygtex
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <7> on input line ....
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <5> on input line ....
)
LaTeX Warning: Reference `ln:ret' on page 1 undefined on input line ....
! Missing $ inserted.
<inserted text>
Expand Down
9 changes: 0 additions & 9 deletions testfiles/simple.tlg
@@ -1,14 +1,5 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
runsystem(pygmentize -S bw -f latex -P commandprefix=PYG > _minted-simple/bw.pygstyle)...executed.
(_minted-simple/bw.pygstyle)
runsystem(pygmentize -l 'text' -f latex -P commandprefix=PYG -F tokenmerge -P stripnl='False' -P escapeinside='||' -P mathescape='True' -o _minted-simple/677FC047998CC2207A0E8277AD996845D25CC8B59E59840920DBB35654E4BCFA.pygtex simple.pyg)...executed.
(_minted-simple/677FC047998CC2207A0E8277AD996845D25CC8B59E59840920DBB35654E4BCFA.pygtex
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <7> on input line ....
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <5> on input line ....
)
LaTeX Warning: Reference `ln:ret' on page 1 undefined on input line ....
! Missing $ inserted.
<inserted text>
Expand Down
9 changes: 0 additions & 9 deletions testfiles/simple.xetex.tlg
@@ -1,14 +1,5 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
runsystem(pygmentize -S bw -f latex -P commandprefix=PYG > _minted-simple-xe/bw.pygstyle)...executed.
(_minted-simple-xe/bw.pygstyle)
runsystem(pygmentize -l 'text' -f latex -P commandprefix=PYG -F tokenmerge -P stripnl='False' -P escapeinside='||' -P mathescape='True' -o _minted-simple-xe/677FC047998CC2207A0E8277AD996845D25CC8B59E59840920DBB35654E4BCFA.pygtex simple.pyg)...executed.
(_minted-simple-xe/677FC047998CC2207A0E8277AD996845D25CC8B59E59840920DBB35654E4BCFA.pygtex
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <7> on input line ....
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <5> on input line ....
)
LaTeX Warning: Reference `ln:ret' on page 1 undefined on input line ....
! Missing $ inserted.
<inserted text>
Expand Down
5 changes: 0 additions & 5 deletions testfiles/without-bars.luatex.tlg
@@ -1,7 +1,2 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
runsystem(pygmentize -S bw -f latex -P commandprefix=PYG > _minted-without-bars-lua/bw.pygstyle)...executed.
(_minted-without-bars-lua/bw.pygstyle)
runsystem(pygmentize -l 'text' -f latex -P commandprefix=PYG -F tokenmerge -P stripnl='False' -P escapeinside='||' -P mathescape='True' -o _minted-without-bars-lua/746308829575E17C3331BBCB00C0898BBD71687C5DAEFCF1B0B195EF586C1523.pygtex without-bars.pyg)...executed.
(_minted-without-bars-lua/746308829575E17C3331BBCB00C0898BBD71687C5DAEFCF1B0B195EF586C1523.pygtex
LaTeX Font Info: Trying to load font information for TS1+lmtt on input line ....
5 changes: 0 additions & 5 deletions testfiles/without-bars.tlg
@@ -1,7 +1,2 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
runsystem(pygmentize -S bw -f latex -P commandprefix=PYG > _minted-without-bars/bw.pygstyle)...executed.
(_minted-without-bars/bw.pygstyle)
runsystem(pygmentize -l 'text' -f latex -P commandprefix=PYG -F tokenmerge -P stripnl='False' -P escapeinside='||' -P mathescape='True' -o _minted-without-bars/746308829575E17C3331BBCB00C0898BBD71687C5DAEFCF1B0B195EF586C1523.pygtex without-bars.pyg)...executed.
(_minted-without-bars/746308829575E17C3331BBCB00C0898BBD71687C5DAEFCF1B0B195EF586C1523.pygtex
LaTeX Font Info: Trying to load font information for TS1+cmtt on input line ....
5 changes: 0 additions & 5 deletions testfiles/without-bars.xetex.tlg
@@ -1,7 +1,2 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
runsystem(pygmentize -S bw -f latex -P commandprefix=PYG > _minted-without-bars-xe/bw.pygstyle)...executed.
(_minted-without-bars-xe/bw.pygstyle)
runsystem(pygmentize -l 'text' -f latex -P commandprefix=PYG -F tokenmerge -P stripnl='False' -P escapeinside='||' -P mathescape='True' -o _minted-without-bars-xe/746308829575E17C3331BBCB00C0898BBD71687C5DAEFCF1B0B195EF586C1523.pygtex without-bars.pyg)...executed.
(_minted-without-bars-xe/746308829575E17C3331BBCB00C0898BBD71687C5DAEFCF1B0B195EF586C1523.pygtex
LaTeX Font Info: Trying to load font information for TS1+lmtt on input line ....
3 changes: 0 additions & 3 deletions testfiles/without-pygments.luatex.tlg

This file was deleted.

12 changes: 0 additions & 12 deletions testfiles/without-pygments.lvt

This file was deleted.

3 changes: 0 additions & 3 deletions testfiles/without-pygments.tlg

This file was deleted.

3 changes: 0 additions & 3 deletions testfiles/without-pygments.xetex.tlg

This file was deleted.

0 comments on commit afbf8d1

Please sign in to comment.