mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +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.
|
||||
% $...$, $$...$$, \(...\) and \[...\] are hardcoded in tex2lyx.
|
||||
% The arguments are currently ignored.
|
||||
% The arguments are currently ignored (apart from displaymath).
|
||||
\begin{mathenvironments}
|
||||
equation
|
||||
equation*
|
||||
eqnarray
|
||||
eqnarray*
|
||||
align
|
||||
align*
|
||||
gather
|
||||
gather*
|
||||
multline
|
||||
multline*
|
||||
math
|
||||
displaymath
|
||||
flalign
|
||||
flalign
|
||||
equation{displaymath}
|
||||
equation*{displaymath}
|
||||
eqnarray{displaymath}
|
||||
eqnarray*{displaymath}
|
||||
align{displaymath}
|
||||
align*{displaymath}
|
||||
gather{displaymath}
|
||||
gather*{displaymath}
|
||||
multline{displaymath}
|
||||
multline*{displaymath}
|
||||
math{}
|
||||
displaymath{displaymath}
|
||||
flalign{displaymath}
|
||||
flalign{displaymath}
|
||||
% These require extra args
|
||||
alignat
|
||||
alignat*
|
||||
xalignat
|
||||
xalignat*
|
||||
xxalignat
|
||||
alignat{}{displaymath}
|
||||
alignat*{displaymath}
|
||||
xalignat{}{displaymath}
|
||||
xalignat*{}{displaymath}
|
||||
xxalignat{}{displaymath}
|
||||
% These are not known by LyX but work nevertheless:
|
||||
empheq
|
||||
empheq[]{}{displaymath}
|
||||
\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)
|
||||
{
|
||||
while (p.good()) {
|
||||
|
@ -357,6 +357,8 @@ void read_command(Parser & p, string command, CommandMap & commands)
|
||||
arguments.push_back(required);
|
||||
else if (arg == "item")
|
||||
arguments.push_back(item);
|
||||
else if (arg == "displaymath")
|
||||
arguments.push_back(displaymath);
|
||||
else
|
||||
arguments.push_back(verbatim);
|
||||
} else {
|
||||
|
@ -84,6 +84,7 @@ std::string join(std::vector<std::string> const & input,
|
||||
char const * delim);
|
||||
|
||||
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 *);
|
||||
|
||||
/*!
|
||||
@ -117,7 +118,8 @@ enum ArgumentType {
|
||||
required,
|
||||
verbatim,
|
||||
item,
|
||||
optional
|
||||
optional,
|
||||
displaymath,
|
||||
};
|
||||
|
||||
class FullCommand {
|
||||
|
@ -689,6 +689,7 @@ void parse_arguments(string const & command,
|
||||
else
|
||||
ert += p.verbatim_item();
|
||||
break;
|
||||
case displaymath:
|
||||
case verbatim:
|
||||
// This argument may contain special characters
|
||||
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);
|
||||
os << "\\end{" << name << "}";
|
||||
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") {
|
||||
@ -1900,7 +1907,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
||||
context.check_layout(os);
|
||||
begin_inset(os, "Formula ");
|
||||
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
|
||||
os << "\\[";
|
||||
parse_math(p, os, FLAG_SIMPLE, MATH_MODE);
|
||||
@ -1914,6 +1922,12 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
||||
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)
|
||||
@ -2160,6 +2174,10 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
||||
parse_math(p, os, FLAG_EQUATION, MATH_MODE);
|
||||
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")
|
||||
|
Loading…
Reference in New Issue
Block a user