gpoore / minted

minted is a LaTeX package that provides syntax highlighting using the Pygments library. Highlighted source code can be customized using fancyvrb.
1.73k stars 125 forks source link

breakautoindent option doesn't work with some languages #359

Closed j-tai closed 1 year ago

j-tai commented 1 year ago

The breakautoindent option doesn't work when the language is c, cpp, json, yaml, and possibly others. It works fine for other languages such as text, java, kotlin, javascript, typescript, python, perl, html, and latex.

Reproduce:

\documentclass{article}
\usepackage{minted}

\setminted{breaklines, breakautoindent}

\begin{document}
\begin{minted}{c}
char* first = "afjeowij f eowa ijfe awo i fejwoai f jeo wiafj eo wijfo";
    char* second = "afjeowij f eowa ijfe awo i fejwoai f jeo wiafj eo wijfo";
        char* third = "afjeowij f eowa ijfe awo i fejwoai f jeo wiafj eo wijfo";
\end{minted}
\end{document}

Although I set breakautoindent in the preamble's \setminted, the feature does not have any effect.

image

I expected it to look like this (ignore the different colors):

image

minted version: 2.7 from master branch Log file: minted-breakautoindent.log

gpoore commented 1 year ago

Are you using the latest version of fvextra? It is used internally for line breaking, and the last release improved these sorts of situations. Your example works for me with the latest minted and fvextra.

j-tai commented 1 year ago

Looks like that's it. Thanks!

muzimuzhi commented 1 year ago

minted could add a soft requirement on the minimum release date of fvextra (\RequirePackage{fvextra}[2022-11-30]), so users using outdated fvextra relative to minted will receive a warning. Using \IfPackageAtLeast{<pkg>}{<date>}{<true code>}{<false code>} could even issue an error.