Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autumn theme breaks code wrapping #399

Open
SG420 opened this issue Aug 2, 2024 · 1 comment
Open

Autumn theme breaks code wrapping #399

SG420 opened this issue Aug 2, 2024 · 1 comment

Comments

@SG420
Copy link

SG420 commented Aug 2, 2024

When using the autumn theme, long unbroken lines are not wrapped when the breaklines and breakanywhere options are set. This does not occur with other themes that I have tested.

For example:

\documentclass{article}
\usepackage{minted}
\usemintedstyle{autumn}

\begin{document}
\begin{minted}[autogobble, breaklines, breakanywhere]{http}
GET /search?query=this\%20is\%20a\%20very\%20long\%20search\%20string\%20with\%20lots\%20of\%20special\%20characters\%20like\%20percent\%20signs\%20\%20and\%20ampersands\%20&&&&&\%20and\%20more\%20special\%20characters\%20%%%%%\%20&&&&&\%20plus\%20some\%20more\%20text\%20to\%20make\%20this\%20even\%20longer\%20and\%20more\%20complex\%20%%%%%\%20&&&&&\%20because\%20we\%20need\%20it\%20to\%20be\%20very\%20long\%20for\%20this\%20example\%20%%%%%\%20&&&&&\%20now\%20let's\%20add\%20more\%20random\%20characters\%20%%%%%\%20&&&&&\%20to\%20make\%20sure\%20it's\%20really\%20long\%20and\%20has\%20enough\%20special\%20characters\%20%%%%%\%20&&&&&\%20keep\%20going\%20%%%%%\%20&&&&&\%20almost\%20there\%20%%%%%\%20&&&&&\%20just\%20a\%20bit\%20more\%20%%%%%\%20&&&&&\%20and\%20we\%20are\%20done\%20%%%%%\%20&&&&&\%20finally\%20%%%%%\%20&&&&&\%20 HTTP/1.0
Host: example.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Upgrade-Insecure-Requests: 1
\end{minted}

\end{document}

Will result in the text going off the page:

image

When changing the style, e.g to colorful, the code will wrap as expected:

image

@muzimuzhi
Copy link
Contributor

muzimuzhi commented Aug 2, 2024

Pygments' autumn style uses underline attribute and its LaTeX formatter converts that attribute to LaTeX command \underline. It is \underline that prevented line breaking.

Unfortunately, it seems none of the two engine-neutral breakable underline commands (\uline and ul from ulem and soul packages, resp.) work for this case. Only the LuaTeX-only \underLine ("L" uppercased) from lua-ul package works.

An example which locally redefines \underline for minted environments and commands:

% !TeX TXS-program:compile = sh -c "TERM=xterm lualatex -shell-escape %.tex"
\documentclass{article}
\usepackage{minted}
\usemintedstyle{autumn}

\makeatletter
\minted@def@optfv{formatcom*}
\makeatother

\usepackage{lua-ul}          % for \underLine
%\usepackage{soul}           % for \ul
%\usepackage[normalem]{ulem} % for \uline

% "formatcom*=<code>" appends code, while "formatcom=<code>" overwrites
\setminted{formatcom*={\let\underline=\underLine}}

\begin{document}
\begin{minted}[autogobble, breaklines, breakanywhere]{http}
GET /search?query=this\%20is\%20a\%20very\%20long\%20search\%20string\%20with\%20lots\%20of\%20special\%20characters\%20like\%20percent\%20signs\%20\%20and\%20ampersands\%20&&&&&\%20and\%20more\%20special\%20characters\%20%%%%%\%20&&&&&\%20plus\%20some\%20more\%20text\%20to\%20make\%20this\%20even\%20longer\%20and\%20more\%20complex\%20%%%%%\%20&&&&&\%20because\%20we\%20need\%20it\%20to\%20be\%20very\%20long\%20for\%20this\%20example\%20%%%%%\%20&&&&&\%20now\%20let's\%20add\%20more\%20random\%20characters\%20%%%%%\%20&&&&&\%20to\%20make\%20sure\%20it's\%20really\%20long\%20and\%20has\%20enough\%20special\%20characters\%20%%%%%\%20&&&&&\%20keep\%20going\%20%%%%%\%20&&&&&\%20almost\%20there\%20%%%%%\%20&&&&&\%20just\%20a\%20bit\%20more\%20%%%%%\%20&&&&&\%20and\%20we\%20are\%20done\%20%%%%%\%20&&&&&\%20finally\%20%%%%%\%20&&&&&\%20 HTTP/1.0
Host: example.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Upgrade-Insecure-Requests: 1
\end{minted}
\end{document}

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants