mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-07 09:46:54 +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;
|
MathInset * clone() const;
|
||||||
///
|
///
|
||||||
MathBraceInset * asBraceInset() { return this; }
|
MathBraceInset * asBraceInset() { return this; }
|
||||||
|
/// identifies things that add {...} when written
|
||||||
|
bool extraBraces() const { return true; }
|
||||||
///
|
///
|
||||||
void draw(Painter &, int x, int y) const;
|
void draw(Painter &, int x, int y) const;
|
||||||
///
|
///
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "math_scriptinset.h"
|
#include "math_scriptinset.h"
|
||||||
#include "math_mathmlstream.h"
|
#include "math_mathmlstream.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
#include "math_parser.h"
|
||||||
|
|
||||||
|
|
||||||
using std::ostream;
|
using std::ostream;
|
||||||
@ -235,3 +236,20 @@ void MathInset::mathmlize(MathMLStream & os) const
|
|||||||
NormalStream ns(os.os());
|
NormalStream ns(os.os());
|
||||||
normalize(ns);
|
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; }
|
virtual MathTextCodes code() const { return LM_TC_MIN; }
|
||||||
/// identifies things that can get \limits or \nolimits
|
/// identifies things that can get \limits or \nolimits
|
||||||
virtual bool takesLimits() const { return false; }
|
virtual bool takesLimits() const { return false; }
|
||||||
/// identifies complicated things that need braces if used as arg
|
/// identifies things that add {...} when written
|
||||||
virtual bool needsBraces() const { return true; }
|
virtual bool extraBraces() const { return false; }
|
||||||
|
|
||||||
///
|
///
|
||||||
virtual void edit(BufferView *, int, int, unsigned int) {}
|
virtual void edit(BufferView *, int, int, unsigned int) {}
|
||||||
@ -256,4 +256,7 @@ public:
|
|||||||
|
|
||||||
std::ostream & operator<<(std::ostream &, MathInset const &);
|
std::ostream & operator<<(std::ostream &, MathInset const &);
|
||||||
|
|
||||||
|
string asString(MathArray const & ar);
|
||||||
|
MathArray asArray(string const & str);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -932,10 +932,6 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
|
|||||||
{
|
{
|
||||||
parse_into1(array, flags, code);
|
parse_into1(array, flags, code);
|
||||||
// remove 'unnecessary' braces:
|
// 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) {
|
else if (t.cat() == catBegin) {
|
||||||
MathArray ar;
|
MathArray ar;
|
||||||
parse_into(ar, FLAG_BRACE_LAST);
|
parse_into(ar, FLAG_BRACE_LAST);
|
||||||
#ifndef WITH_WARNINGS
|
// do not create a BraceInset if they were written by LyX
|
||||||
#warning this might be wrong in general!
|
// this helps to keep the annoyance of "a choose b" to a minimum
|
||||||
#endif
|
if (ar.size() == 1 && ar.front()->extraBraces()) {
|
||||||
// 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))
|
|
||||||
{
|
|
||||||
array.push_back(ar);
|
array.push_back(ar);
|
||||||
} else {
|
} else {
|
||||||
array.push_back(MathAtom(new MathBraceInset));
|
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") {
|
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") {
|
else if (t.cs() == "choose" || t.cs() == "over" || t.cs() == "atop") {
|
||||||
|
@ -21,6 +21,8 @@ public:
|
|||||||
explicit MathSizeInset(latexkeys const * l);
|
explicit MathSizeInset(latexkeys const * l);
|
||||||
///
|
///
|
||||||
MathInset * clone() const;
|
MathInset * clone() const;
|
||||||
|
/// identifies things that add {...} when written
|
||||||
|
bool extraBraces() const { return true; }
|
||||||
///
|
///
|
||||||
void metrics(MathMetricsInfo const & st) const;
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
///
|
///
|
||||||
|
@ -20,6 +20,9 @@ What's new
|
|||||||
|
|
||||||
** Updates
|
** 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
|
- new option `keep aspect ratio' in graphics dialog
|
||||||
|
|
||||||
- update finnish, danish, french and russian localizations
|
- 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
|
- when a document is registered though version control, make sure it
|
||||||
has been saved
|
has been saved
|
||||||
|
|
||||||
|
- fix bug where the math parser would drop some pairs of braces
|
||||||
|
|
||||||
- only use the amsmath package when it is needed
|
- only use the amsmath package when it is needed
|
||||||
|
|
||||||
- fix the spacing around fraction insets in math editor
|
- 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
|
- make latex import script (reLyX) honor the LYX_DIR_12x envirnment
|
||||||
variable, like the rest of LyX
|
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
|
- honor --with-extra-XXX when searching for AikSaurus library
|
||||||
|
|
||||||
- fix search for pspell library
|
- fix search for pspell library
|
||||||
|
Loading…
Reference in New Issue
Block a user