Patches for Python scripts
José Abílio Matos
jamatos at lyx.org
Fri Jan 29 12:26:57 UTC 2021
On Friday, January 29, 2021 11:48:40 AM WET Kornel Benko wrote:
> Right, the last one should be escaped.
> Given the line
> # \DeclareLaTeXClass[revtex,revtex.sty]{REVTeX (Obsolete Version)}
> and the original regex
>
> '\\s*#\\s*\\\\DeclareLaTeXClass\\s*(\[([^,]*)(,.*)*\])*\\s*{(.*)}\\s*$' the
> result in found(1) would be "revtex"
> and found(2) would be the rest inside the escaped brackets, e.g.
> "revtex.sty"
>
> Not escaping the last ']' probably not intended.
> (I would escape also '{' and '}' if that were a perl regex)
Now that you mention it the code should use raw strings in order to avoid
doubling the backslashes, e.g. in order to match \DeclareLaTeXclass the code
has "\\\\DeclareLaTeXclass" because the backslash needs to be escaped twice
the first time for the regular expression and then each needs to be escaped
again for python.
Using raw strings the results would be r"\\DeclareLaTeXclass" more in line
with what we usually write. :-)
This is a detour that come from the code analysis and it does not come from
Thibault's changes.
--
José Abílio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20210129/a9f5b95a/attachment.html>
More information about the lyx-devel
mailing list