[PATCH] lyxpreview_tools.py: fix a regular expression

Scott Kostyshak skostysh at lyx.org
Sun Feb 16 03:21:59 UTC 2020


On Sat, Feb 15, 2020 at 09:25:40PM +0100, Kornel Benko wrote:
> Am Sat, 15 Feb 2020 21:15:17 +0100
> schrieb Kornel Benko <kornel at lyx.org>:
> 
> > Am Sat, 15 Feb 2020 14:03:43 -0500
> > schrieb Scott Kostyshak <skostysh at lyx.org>:
> > 
> > > Attached is a patch for lyxpreview_tools.py, but I don't know Python
> > > well and I don't know how to test whether this code works as intended
> > > now or not. All I know is it gets rid of the error.
> > > 
> > > I originally saw that error on master when opening the User Guide with
> > > Preview enabled.
> > > 
> > > Can someone give the patch a check?
> > > 
> > > Best,
> > > 
> > > Scott  
> > 
> > Definitely better as the original. Works here as expected.
> > Still one element making problems:
> > 	Warning: Failed to produce 1 preview snippet(s)
> > Looking at the lyxpreviewkn4998.log here, looks like it is not related to your patch.
> > 
> > Preview: Snippet 85 338603 0 465893
> > [85]
> > ! Undefined control sequence.
> > l.628 x^{2}-2x-2\Rightarrow\question
> >                                     {x_{1}}\answer{x_{2}}=1\question{+\sqrt{...
> > The control sequence at the end of the top line
> > of your error message was never \def'ed. If you have
> > misspelled it (e.g., `\hobx'), type `I' and the correct
> > spelling (e.g., `I\hbox'). Otherwise just continue,
> > and I'll forget about whatever was undefined.
> > 
> > Other snippets are OK.
> > 
> > 	Kornel
> 
> OK, found the offending piece, attached

I see the same. I guess it's difficult to expect it to work there, since
it requires a \newcommand that is defined in a previous paragraph. I
thought I could be sneaky and fix it by wrapping the \newcommand TeX box
in a preview inset, but that didn't work. Even the following gives an
undefined error since I guess the scope of the \newcommand is local to
the preview environment (?):

  \begin{preview}
  \newcommand{\question}[1]{#1}
  \newcommand{\answer}[1]{}
  \end{preview}
  
  \begin{preview}
  
  \[
  x^{2}-2x-2\Rightarrow\question{x_{1}}\answer{x_{2}}=1\question{+\sqrt{3}}\answer{-\sqrt{3}}.
  \]
  
  \end{preview}

That would have been a hackish patch anyway.

Scott
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20200215/5e60675b/attachment-0001.asc>


More information about the lyx-devel mailing list