2015-04-30 19:35 GMT+02:00 Jürgen Spitzmüller:
> Further testing revealed that this is a change that needs careful testing.
> I have learned that readParToken also uses getDocString() in order to read
> normal paragraph lines, and thus obviously must not be trimmed.
>
After some more pondering, I propose to go with the most careful approach
and only trim at request (only the "requires" tags for now). It does not
strike me sensible to do the trimming when we have no indication it is
needed.
See attached patch.
OK?
Jürgen
diff --git a/src/Layout.cpp b/src/Layout.cpp
index 1e89433..400e6bb 100644
--- a/src/Layout.cpp
+++ b/src/Layout.cpp
@@ -565,7 +565,7 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass
const & tclass)
case LT_REQUIRES: {
lex.eatLine();
vector<string> const req =
- getVectorFromString(lex.getString());
+ getVectorFromString(lex.getString(true));
requires_.insert(req.begin(), req.end());
break;
}
diff --git a/src/Lexer.cpp b/src/Lexer.cpp
index c4b738f..fa9ffc7 100644
--- a/src/Lexer.cpp
+++ b/src/Lexer.cpp
@@ -695,23 +695,23 @@ double Lexer::getFloat() const
}
-string const Lexer::getString() const
+string const Lexer::getString(bool trim) const
{
lastReadOk_ = pimpl_->status == LEX_DATA || pimpl_->status == LEX_TOKEN;
if (lastReadOk_)
- return pimpl_->getString();
+ return trim ? support::trim(pimpl_->getString(), "\t ") :
pimpl_->getString();
return string();
}
-docstring const Lexer::getDocString() const
+docstring const Lexer::getDocString(bool trim) const
{
lastReadOk_ = pimpl_->status == LEX_DATA || pimpl_->status == LEX_TOKEN;
if (lastReadOk_)
- return pimpl_->getDocString();
+ return trim ? support::trim(pimpl_->getDocString(), "\t ") :
pimpl_->getDocString();
return docstring();
}
diff --git a/src/Lexer.h b/src/Lexer.h
index dc56a4a..5e87ebc 100644
--- a/src/Lexer.h
+++ b/src/Lexer.h
@@ -137,9 +137,9 @@ public:
///
double getFloat() const;
///
- std::string const getString() const;
+ std::string const getString(bool trim = false) const;
///
- docstring const getDocString() const;
+ docstring const getDocString(bool trim = false) const;
/** Get a long string, ended by the tag `endtag'.
This string can span several lines. The first line
serves as a template for how many spaces the lines
diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp
index eed1b6b..ca706f2 100644
--- a/src/insets/InsetLayout.cpp
+++ b/src/insets/InsetLayout.cpp
@@ -441,7 +441,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const &
tclass)
case IL_REQUIRES: {
lex.eatLine();
vector<string> const req
- = getVectorFromString(lex.getString());
+ = getVectorFromString(lex.getString(true));
requires_.insert(req.begin(), req.end());
break;
}