]> git.lyx.org Git - features.git/commit
lyxpreview_tools.py: fix a regular expression
authorScott Kostyshak <skostysh@lyx.org>
Sat, 15 Feb 2020 18:27:45 +0000 (13:27 -0500)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:52 +0000 (15:48 +0200)
commit8af13d8cfb441684cb9f091093707e4add9a641d
treee4652e57d080ebdfa8b63add29d089e1dc9914d7
parentbab8d6710331d8dd4908992f1fd720f118cc926b
lyxpreview_tools.py: fix a regular expression

Three backslashes are needed before a LaTeX command, not one. Before
this commit, the code gave the following error with Python >= 3.6:

  re.error: bad escape \g at position 29

This error was introduced with Python 3.6, as documented [1] by the
following line of documentation:

  Changed in version 3.6: Unknown escapes in pattern consisting of
  '\' and an ASCII letter now are errors.

Although previous Python versions did not give an error, the regular
expression was not working as intended: for example, the "\\n" in
"\\newcommandx" would be interpreted as a new line.

[1] https://docs.python.org/3.6/library/re.html#re.sub
lib/scripts/lyxpreview_tools.py