GNU bug report logs - #48078
Verbatim environments with key-value arguments

Previous Next

Package: auctex;

Reported by: Dario Gjorgjevski <dario.gjorgjevski <at> gmail.com>

Date: Wed, 28 Apr 2021 09:12:01 UTC

Severity: normal

Done: Tassilo Horn <tsdh <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Dario Gjorgjevski <dario.gjorgjevski <at> gmail.com>
Subject: bug#48078: closed (Re: bug#48078: Verbatim environments with
 key-value arguments)
Date: Wed, 28 Apr 2021 19:44:03 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#48078: Verbatim environments with key-value arguments

which was filed against the auctex package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 48078 <at> debbugs.gnu.org.

-- 
48078: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=48078
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Tassilo Horn <tsdh <at> gnu.org>
To: Dario Gjorgjevski <dario.gjorgjevski <at> gmail.com>
Cc: bug-auctex <at> gnu.org, 48078-done <at> debbugs.gnu.org
Subject: Re: bug#48078: Verbatim environments with key-value arguments
Date: Wed, 28 Apr 2021 20:41:16 +0200
Dario Gjorgjevski <dario.gjorgjevski <at> gmail.com> writes:

Hi Dario,

> \begin{tcblisting}{%
> listing only,%
> title={Example shell session},
> minted language=shell-session,%
> minted options={},%
> }
> $ echo 'Hello, World!'
> Hello, World!
> \end{tcblisting}
>
> Feel free to add "tcblisting" to `LaTeX-verbtaim-environments' and
> check out the example above: You will see that everything after
> title={Example shell session} is fontified as verbatim.
>
> I would be happy to try and improve the regex so that it handles
> key-value arguments,

To handle all situations correctly is impossible.  You can't properly
match nested constructs like balanced parens/braces using regular
expressions.  For that, you'd need an actual parser.

But you can at least allow a fixed number of balanced braces, and I've
just done that in order to allow one level of nested {...} in mandatory
arguments.  (We already allowed for one level of nested brackets in an
optional argument.)

I'll make a new ELPA release.

Thanks for the report and Bye,
Tassilo

[Message part 3 (message/rfc822, inline)]
From: Dario Gjorgjevski <dario.gjorgjevski <at> gmail.com>
To: bug-auctex <at> gnu.org
Subject: Verbatim environments with key-value arguments
Date: Wed, 28 Apr 2021 11:11:07 +0200
[Message part 4 (text/plain, inline)]
Hi,

I am writing styles for the minted and listings libraries of tcolorbox,
which introduce the tcblisting verbatim environment.  Here is a small
example showing things:

[tcblisting.tex (text/x-tex, inline)]
\documentclass[preview,svgnames,x11names]{standalone}

\RequirePackage[newfloat]{minted}
\RequirePackage{tcolorbox}
\tcbuselibrary{most,minted}

\begin{document}
\begin{tcblisting}{%
listing only,%
title={Example shell session},
minted language=shell-session,%
minted options={},%
}
$ echo 'Hello, World!'
Hello, World!
\end{tcblisting}
\end{document}

% Local Variables:
% mode: latex
% TeX-command-extra-options: "-shell-escape"
% TeX-master: t
% End:
[Message part 6 (text/plain, inline)]
As you can see, tcblisting takes key-value arguments.  This breaks the
"mandatory arguments to verbatim environments" part of
`font-latex-syntactic-keywords', which is defined as:

    ;; After the optional argument, there may also be
    ;; another mandatory argument(s) (e.g. with VerbatimOut or
    ;; the minted envs or defined with `lstnewenvironment').
    "\\(?:{[^}]*}\\)*"

Since the key-value arguments _can_ contain braces (e.g., title={Example
shell session}), the regex does not match properly and messes up the
fontification.

Feel free to add "tcblisting" to `LaTeX-verbtaim-environments' and check
out the example above: You will see that everything after title={Example
shell session} is fontified as verbatim.

I would be happy to try and improve the regex so that it handles
key-value arguments, but I first wanted to ask if this is indeed and the
best approach.

Best regards,

-- 
Dario Gjorgjevski <dario.gjorgjevski <at> gmail.com>
Key fingerprint = F7C3 734D 2381 DAEB 4C6D  9CF7 744A 4F0B 4F1C 9371
$ gpg --keyserver   hkps://hkps.pool.sks-keyservers.net \
      --search-keys 744A4F0B4F1C9371

This bug report was last modified 4 years and 17 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.