Hi Keita,

Ikumi Keita <[email protected]> writes:

>> How about this:

First of all, my last patch wasn't correct, please try this one if you
want to test:

--8<---------------cut here---------------start------------->8---
diff --git a/font-latex.el b/font-latex.el
index b78cf58a..0d32eab1 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -1095,7 +1095,10 @@ have changed."
                   ;; Some macros take an optional argument.  This is
                   ;; the same line as above for environments.
                   "\\(?:\\[[^][]*\\(?:\\[[^][]*\\][^][]*\\)*\\]\\)?"
-                  "\\({\\).*?[^\\]\\(?:\\\\\\\\\\)*\\(}\\)")
+                  "\\({\\)"
+                  "\\(?:[^}{]*\\(?:{[^}{]*}[^}{]*\\)*\\)"
+                  "[^\\]\\(?:\\\\\\\\\\)*"
+                  "\\(}\\)")
          (1 "|") (2 "|")))))
   (when font-latex-syntactic-keywords-extra
     (nconc font-latex-syntactic-keywords font-latex-syntactic-keywords-extra))
--8<---------------cut here---------------end--------------->8---

> Hmm. That would fail if some verbatim macro has an intentional unpaired
> "{" in its argument like \foobar{aaa"{"bbb} .
> But maybe it's a corner case that we don't have to worry about. I'm not
> sure.

This is indeed a corner case: Packages like fvextra.sty which allow
things like \Verb{content} explicitly require balanced braces;
\Verb{co{ntent} raises an error during compilation whereas
\Verb|co{ntent| works.  Another issue with my suggestion above is this:


\documentclass{article}
\usepackage{fvextra}

\begin{document}

\Verb{w{o}r{k}s}
\Verb{b{r}eak{s}}

\end{document}

due to "[^\\]\\(?:\\\\\\\\\\)*" in the regexp.

Best, Arash

Reply via email to