mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Fix bug #7668 (cosmetic whitespace issues)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40184 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2a216184c4
commit
8d707723b7
@ -703,30 +703,30 @@ thebibliography{}
|
|||||||
|
|
||||||
% Environments that start math mode.
|
% Environments that start math mode.
|
||||||
% $...$, $$...$$, \(...\) and \[...\] are hardcoded in tex2lyx.
|
% $...$, $$...$$, \(...\) and \[...\] are hardcoded in tex2lyx.
|
||||||
% The arguments are currently ignored.
|
% The arguments are currently ignored (apart from displaymath).
|
||||||
\begin{mathenvironments}
|
\begin{mathenvironments}
|
||||||
equation
|
equation{displaymath}
|
||||||
equation*
|
equation*{displaymath}
|
||||||
eqnarray
|
eqnarray{displaymath}
|
||||||
eqnarray*
|
eqnarray*{displaymath}
|
||||||
align
|
align{displaymath}
|
||||||
align*
|
align*{displaymath}
|
||||||
gather
|
gather{displaymath}
|
||||||
gather*
|
gather*{displaymath}
|
||||||
multline
|
multline{displaymath}
|
||||||
multline*
|
multline*{displaymath}
|
||||||
math
|
math{}
|
||||||
displaymath
|
displaymath{displaymath}
|
||||||
flalign
|
flalign{displaymath}
|
||||||
flalign
|
flalign{displaymath}
|
||||||
% These require extra args
|
% These require extra args
|
||||||
alignat
|
alignat{}{displaymath}
|
||||||
alignat*
|
alignat*{displaymath}
|
||||||
xalignat
|
xalignat{}{displaymath}
|
||||||
xalignat*
|
xalignat*{}{displaymath}
|
||||||
xxalignat
|
xxalignat{}{displaymath}
|
||||||
% These are not known by LyX but work nevertheless:
|
% These are not known by LyX but work nevertheless:
|
||||||
empheq
|
empheq[]{}{displaymath}
|
||||||
\end{mathenvironments}
|
\end{mathenvironments}
|
||||||
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
@ -27,6 +27,16 @@ bool is_math_env(string const & name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool is_display_math_env(string const & name)
|
||||||
|
{
|
||||||
|
CommandMap::const_iterator it = known_math_environments.find(name);
|
||||||
|
if (it != known_math_environments.end())
|
||||||
|
if (!it->second.empty())
|
||||||
|
return it->second.back() == displaymath;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void parse_math(Parser & p, ostream & os, unsigned flags, const mode_type mode)
|
void parse_math(Parser & p, ostream & os, unsigned flags, const mode_type mode)
|
||||||
{
|
{
|
||||||
while (p.good()) {
|
while (p.good()) {
|
||||||
|
@ -357,6 +357,8 @@ void read_command(Parser & p, string command, CommandMap & commands)
|
|||||||
arguments.push_back(required);
|
arguments.push_back(required);
|
||||||
else if (arg == "item")
|
else if (arg == "item")
|
||||||
arguments.push_back(item);
|
arguments.push_back(item);
|
||||||
|
else if (arg == "displaymath")
|
||||||
|
arguments.push_back(displaymath);
|
||||||
else
|
else
|
||||||
arguments.push_back(verbatim);
|
arguments.push_back(verbatim);
|
||||||
} else {
|
} else {
|
||||||
|
@ -84,6 +84,7 @@ std::string join(std::vector<std::string> const & input,
|
|||||||
char const * delim);
|
char const * delim);
|
||||||
|
|
||||||
bool is_math_env(std::string const & name);
|
bool is_math_env(std::string const & name);
|
||||||
|
bool is_display_math_env(std::string const & name);
|
||||||
char const * const * is_known(std::string const &, char const * const *);
|
char const * const * is_known(std::string const &, char const * const *);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -117,7 +118,8 @@ enum ArgumentType {
|
|||||||
required,
|
required,
|
||||||
verbatim,
|
verbatim,
|
||||||
item,
|
item,
|
||||||
optional
|
optional,
|
||||||
|
displaymath,
|
||||||
};
|
};
|
||||||
|
|
||||||
class FullCommand {
|
class FullCommand {
|
||||||
|
@ -689,6 +689,7 @@ void parse_arguments(string const & command,
|
|||||||
else
|
else
|
||||||
ert += p.verbatim_item();
|
ert += p.verbatim_item();
|
||||||
break;
|
break;
|
||||||
|
case displaymath:
|
||||||
case verbatim:
|
case verbatim:
|
||||||
// This argument may contain special characters
|
// This argument may contain special characters
|
||||||
ert += '{' + p.verbatim_item() + '}';
|
ert += '{' + p.verbatim_item() + '}';
|
||||||
@ -1157,6 +1158,12 @@ void parse_environment(Parser & p, ostream & os, bool outer,
|
|||||||
parse_math(p, os, FLAG_END, MATH_MODE);
|
parse_math(p, os, FLAG_END, MATH_MODE);
|
||||||
os << "\\end{" << name << "}";
|
os << "\\end{" << name << "}";
|
||||||
end_inset(os);
|
end_inset(os);
|
||||||
|
if (is_display_math_env(name)) {
|
||||||
|
// Prevent the conversion of a line break to a space
|
||||||
|
// (bug 7668). This does not change the output, but
|
||||||
|
// looks ugly in LyX.
|
||||||
|
eat_whitespace(p, os, parent_context, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (unstarred_name == "tabular" || name == "longtable") {
|
else if (unstarred_name == "tabular" || name == "longtable") {
|
||||||
@ -1900,7 +1907,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
|||||||
context.check_layout(os);
|
context.check_layout(os);
|
||||||
begin_inset(os, "Formula ");
|
begin_inset(os, "Formula ");
|
||||||
Token const & n = p.get_token();
|
Token const & n = p.get_token();
|
||||||
if (n.cat() == catMath && outer) {
|
bool const display(n.cat() == catMath && outer);
|
||||||
|
if (display) {
|
||||||
// TeX's $$...$$ syntax for displayed math
|
// TeX's $$...$$ syntax for displayed math
|
||||||
os << "\\[";
|
os << "\\[";
|
||||||
parse_math(p, os, FLAG_SIMPLE, MATH_MODE);
|
parse_math(p, os, FLAG_SIMPLE, MATH_MODE);
|
||||||
@ -1914,6 +1922,12 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
|||||||
os << '$';
|
os << '$';
|
||||||
}
|
}
|
||||||
end_inset(os);
|
end_inset(os);
|
||||||
|
if (display) {
|
||||||
|
// Prevent the conversion of a line break to a
|
||||||
|
// space (bug 7668). This does not change the
|
||||||
|
// output, but looks ugly in LyX.
|
||||||
|
eat_whitespace(p, os, context, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (t.cat() == catSuper || t.cat() == catSub)
|
else if (t.cat() == catSuper || t.cat() == catSub)
|
||||||
@ -2160,6 +2174,10 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
|||||||
parse_math(p, os, FLAG_EQUATION, MATH_MODE);
|
parse_math(p, os, FLAG_EQUATION, MATH_MODE);
|
||||||
os << "\\]";
|
os << "\\]";
|
||||||
end_inset(os);
|
end_inset(os);
|
||||||
|
// Prevent the conversion of a line break to a space
|
||||||
|
// (bug 7668). This does not change the output, but
|
||||||
|
// looks ugly in LyX.
|
||||||
|
eat_whitespace(p, os, context, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (t.cs() == "begin")
|
else if (t.cs() == "begin")
|
||||||
|
Loading…
Reference in New Issue
Block a user