emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#48078: closed (Verbatim environments with key-value arguments)


From: GNU bug Tracking System
Subject: bug#48078: closed (Verbatim environments with key-value arguments)
Date: Wed, 28 Apr 2021 19:44:02 +0000

Your message dated Wed, 28 Apr 2021 20:41:16 +0200
with message-id <87r1iu42lf.fsf@gnu.org>
and subject line Re: bug#48078: Verbatim environments with key-value arguments
has caused the debbugs.gnu.org bug report #48078,
regarding Verbatim environments with key-value arguments
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
48078: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=48078
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: Verbatim environments with key-value arguments Date: Wed, 28 Apr 2021 11:11:07 +0200
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:

\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:
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@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

--- End Message ---
--- Begin Message --- Subject: Re: bug#48078: Verbatim environments with key-value arguments Date: Wed, 28 Apr 2021 20:41:16 +0200 User-agent: mu4e 1.5.12; emacs 28.0.50
Dario Gjorgjevski <dario.gjorgjevski@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


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]