mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-05 17:09:56 +00:00
do not suppress too many extra braces in math parser
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH-1_2_X@4645 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
1cb11db386
commit
4e88da7076
@ -21,6 +21,8 @@ public:
|
||||
MathInset * clone() const;
|
||||
///
|
||||
MathBraceInset * asBraceInset() { return this; }
|
||||
/// identifies things that add {...} when written
|
||||
bool extraBraces() const { return true; }
|
||||
///
|
||||
void draw(Painter &, int x, int y) const;
|
||||
///
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "math_scriptinset.h"
|
||||
#include "math_mathmlstream.h"
|
||||
#include "debug.h"
|
||||
#include "math_parser.h"
|
||||
|
||||
|
||||
using std::ostream;
|
||||
@ -235,3 +236,20 @@ void MathInset::mathmlize(MathMLStream & os) const
|
||||
NormalStream ns(os.os());
|
||||
normalize(ns);
|
||||
}
|
||||
|
||||
|
||||
string asString(MathArray const & ar)
|
||||
{
|
||||
std::ostringstream os;
|
||||
WriteStream ws(os);
|
||||
ws << ar;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
MathArray asArray(string const & str)
|
||||
{
|
||||
MathArray ar;
|
||||
mathed_parse_cell(ar, str);
|
||||
return ar;
|
||||
}
|
||||
|
@ -220,8 +220,8 @@ public:
|
||||
virtual MathTextCodes code() const { return LM_TC_MIN; }
|
||||
/// identifies things that can get \limits or \nolimits
|
||||
virtual bool takesLimits() const { return false; }
|
||||
/// identifies complicated things that need braces if used as arg
|
||||
virtual bool needsBraces() const { return true; }
|
||||
/// identifies things that add {...} when written
|
||||
virtual bool extraBraces() const { return false; }
|
||||
|
||||
///
|
||||
virtual void edit(BufferView *, int, int, unsigned int) {}
|
||||
@ -256,4 +256,7 @@ public:
|
||||
|
||||
std::ostream & operator<<(std::ostream &, MathInset const &);
|
||||
|
||||
string asString(MathArray const & ar);
|
||||
MathArray asArray(string const & str);
|
||||
|
||||
#endif
|
||||
|
@ -932,10 +932,6 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
|
||||
{
|
||||
parse_into1(array, flags, code);
|
||||
// remove 'unnecessary' braces:
|
||||
if (array.size() == 1 && array.back()->asBraceInset()) {
|
||||
lyxerr << "extra braces removed\n";
|
||||
array = array.back()->asBraceInset()->cell(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1012,15 +1008,9 @@ void Parser::parse_into1(MathArray & array, unsigned flags, MathTextCodes code)
|
||||
else if (t.cat() == catBegin) {
|
||||
MathArray ar;
|
||||
parse_into(ar, FLAG_BRACE_LAST);
|
||||
#ifndef WITH_WARNINGS
|
||||
#warning this might be wrong in general!
|
||||
#endif
|
||||
// ignore braces around simple items
|
||||
if ((ar.size() == 1 && !ar.front()->needsBraces()
|
||||
|| (ar.size() == 2 && !ar.front()->needsBraces()
|
||||
&& ar.back()->asScriptInset()))
|
||||
|| (ar.size() == 0 && array.size() == 0))
|
||||
{
|
||||
// do not create a BraceInset if they were written by LyX
|
||||
// this helps to keep the annoyance of "a choose b" to a minimum
|
||||
if (ar.size() == 1 && ar.front()->extraBraces()) {
|
||||
array.push_back(ar);
|
||||
} else {
|
||||
array.push_back(MathAtom(new MathBraceInset));
|
||||
@ -1177,7 +1167,9 @@ void Parser::parse_into1(MathArray & array, unsigned flags, MathTextCodes code)
|
||||
*/
|
||||
|
||||
else if (t.cs() == "label") {
|
||||
curr_label_ = getArg('{', '}');
|
||||
MathArray ar;
|
||||
parse_into(ar, FLAG_ITEM, code);
|
||||
curr_label_ = asString(ar);
|
||||
}
|
||||
|
||||
else if (t.cs() == "choose" || t.cs() == "over" || t.cs() == "atop") {
|
||||
|
@ -21,6 +21,8 @@ public:
|
||||
explicit MathSizeInset(latexkeys const * l);
|
||||
///
|
||||
MathInset * clone() const;
|
||||
/// identifies things that add {...} when written
|
||||
bool extraBraces() const { return true; }
|
||||
///
|
||||
void metrics(MathMetricsInfo const & st) const;
|
||||
///
|
||||
|
@ -20,6 +20,9 @@ What's new
|
||||
|
||||
** Updates
|
||||
|
||||
- it is now possible to build LyX with xforms 1.0rc4 (and probably 1.0
|
||||
when this gets released)
|
||||
|
||||
- new option `keep aspect ratio' in graphics dialog
|
||||
|
||||
- update finnish, danish, french and russian localizations
|
||||
@ -101,6 +104,8 @@ What's new
|
||||
- when a document is registered though version control, make sure it
|
||||
has been saved
|
||||
|
||||
- fix bug where the math parser would drop some pairs of braces
|
||||
|
||||
- only use the amsmath package when it is needed
|
||||
|
||||
- fix the spacing around fraction insets in math editor
|
||||
@ -124,9 +129,6 @@ What's new
|
||||
- make latex import script (reLyX) honor the LYX_DIR_12x envirnment
|
||||
variable, like the rest of LyX
|
||||
|
||||
- rework the configuration script wrt xforms 1.0. This version is now
|
||||
supported.
|
||||
|
||||
- honor --with-extra-XXX when searching for AikSaurus library
|
||||
|
||||
- fix search for pspell library
|
||||
|
Loading…
Reference in New Issue
Block a user