]> git.lyx.org Git - features.git/commit
Fix display and output of math macros with optional arguments
authorEnrico Forestieri <forenr@lyx.org>
Thu, 1 Dec 2016 17:02:47 +0000 (18:02 +0100)
committerEnrico Forestieri <forenr@lyx.org>
Thu, 1 Dec 2016 17:02:47 +0000 (18:02 +0100)
commite8f480e7c22ae29804ff0c386c54e86c9b72d3ce
treefd719e52907d536995a0ba69161a3c5045b29105
parenta0ebae829ccfc75ddfa7c6c568bf5aac0e4787b4
Fix display and output of math macros with optional arguments

This is a long standing issue, present since the new math macros
inception in version 1.6. It manifests as a display issue when a
macro with optional arguments appears in the optional argument of
another macro. In this case the display is messed up and it is
difficult, if not impossible, changing the arguments as they do not
appear on screen as related to a specific macro instance. It also
manifests as latex errors when compiling, even if the latex output
is formally correct, due to limitations of the xargs package used
to output the macros. Most probably, both aspects have the same
root cause, as simply enclosing in braces the macro and its
parameters solves both issues. However, when reloading a document,
lyx strips the outer braces enclosing a macro argument, thus
frustrating this possible workaround.

This commit solves the display issue by correctly accounting for
macros with optional arguments nested in the argument of another
macro, and circumvents the xargs package limitations causing errors
by enclosing in braces the macros with optional arguments appearing
in the argument of an outer macro when they are output. This means
that when loading an old document with such macros and saving it
again, the macro representation is updated and will have these
additional braces. However, as such braces are stripped by lyx on
loading, there is no risk that they accumulate.

See also this thread:
http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg197828.html
src/mathed/MathData.cpp
src/mathed/MathMacro.cpp
src/mathed/MathStream.cpp
src/mathed/MathStream.h