minted icon indicating copy to clipboard operation
minted copied to clipboard

Option to remove blank lines from the input

Open olberger opened this issue 7 years ago • 2 comments

It could be convenient to have an option to remove empty/blank lines from the input. At the moment, only removing their numbering is possible.

Thanks in advance.

olberger avatar Jan 19 '17 12:01 olberger

That could be useful. Unfortunately, it would require a rewrite of some of the fancyvrb internals, so it probably isn't something I can get to in the near future.

gpoore avatar Jan 19 '17 14:01 gpoore

For future reference, the following will remove all empty lines globally. Now this needs to be adapted into an option that can be turned on/off. Also, there may need to be some modifications to take into account lines that consist entirely of whitespace.

\makeatletter
\AtBeginEnvironment{minted}{%
  \def\FV@@PreProcessLine{%
    \expandafter\ifstrempty\expandafter{\FV@Line}{}{%
      \FV@StepLineNo
      \FV@Gobble
      \expandafter\FV@ProcessLine\expandafter{\FV@Line}}}%
}
\makeatother

gpoore avatar Jul 26 '17 16:07 gpoore