diff --git a/src/insets/InsetIndex.cpp b/src/insets/InsetIndex.cpp index f9ab2b1156..384e88cb10 100644 --- a/src/insets/InsetIndex.cpp +++ b/src/insets/InsetIndex.cpp @@ -152,15 +152,19 @@ int InsetIndex::latex(odocstream & os, subst(spart2, from_ascii("\\"), docstring()); os << ppart; os << '@'; + i += count_char(ppart, '\n'); } docstring const tpart = *it; os << tpart; + i += count_char(tpart, '\n'); if (it2 < levels_plain.end()) ++it2; } // write the bit that followed "|" - if (!cmd.empty()) + if (!cmd.empty()) { os << "|" << cmd; + i += count_char(cmd, '\n'); + } os << '}'; return i; } diff --git a/src/support/lstrings.cpp b/src/support/lstrings.cpp index 7039fe127f..87fac22a08 100644 --- a/src/support/lstrings.cpp +++ b/src/support/lstrings.cpp @@ -666,6 +666,7 @@ basic_string const subst_char(basic_string const & a, return tmp; } + /// Substitute all \a oldchar with \a newchar docstring const subst_char(docstring const & a, docstring::value_type oldchar, docstring::value_type newchar) @@ -697,6 +698,7 @@ String const subst_string(String const & a, return lstr; } + docstring const subst_string(docstring const & a, docstring const & oldstr, docstring const & newstr) { @@ -742,6 +744,19 @@ docstring const subst(docstring const & a, } +/// Count all occurences of char \a chr inside \a str +int count_char(docstring const & str, docstring::value_type chr) +{ + int count = 0; + docstring::const_iterator lit = str.begin(); + docstring::const_iterator end = str.end(); + for (; lit != end; ++lit) + if ((*lit) == chr) + count++; + return count; +} + + docstring const trim(docstring const & a, char const * p) { LASSERT(p, /**/); diff --git a/src/support/lstrings.h b/src/support/lstrings.h index 5acd0d247d..85ea79b8df 100644 --- a/src/support/lstrings.h +++ b/src/support/lstrings.h @@ -173,6 +173,9 @@ std::string const subst(std::string const & a, docstring const subst(docstring const & a, docstring const & oldstr, docstring const & newstr); +/// Count all occurences of char \a chr inside \a str +int count_char(docstring const & str, docstring::value_type chr); + /** Trims characters off the end and beginning of a string. \code trim("ccabccc", "c") == "ab".