}
+docstring const Paragraph::printableString(bool label) const
+{
+ odocstringstream os;
+ if (label && !params().labelString().empty())
+ os << params().labelString() << ' ';
+ pos_type end = size();
+ for (pos_type i = 0; i < end; ++i) {
+ char_type const c = d->text_[i];
+ if (isPrintable(c))
+ os.put(c);
+ }
+ return os.str();
+}
+
+
docstring Paragraph::asString(bool label) const
{
return asString(0, size(), label);
bool isMultiLingual(BufferParams const &) const;
/// Convert the paragraph to a string.
+ /// This method doesn't go inside insets, only printable characters in this
+ /// paragraph are used.
/// Used for building the table of contents
+ docstring const printableString(bool label) const;
+
+ /// Convert the paragraph to a string.
docstring asString(bool label) const;
///
docstring asString(pos_type beg, pos_type end, bool label) const;
*static_cast<InsetOptArg&>(inset).paragraphs().begin();
if (!par.labelString().empty())
tocstring = par.labelString() + ' ';
- tocstring += inset_par.asString(false);
+ tocstring += inset_par.printableString(false);
break;
}
}
int const toclevel = par.layout().toclevel;
if (toclevel != Layout::NOT_IN_TOC && toclevel >= min_toclevel
&& tocstring.empty())
- tocstring = par.asString(true);
+ tocstring = par.printableString(true);
const_cast<TocItem &>(*toc_item).str_ = tocstring;
}
*static_cast<InsetOptArg&>(inset).paragraphs().begin();
if (!pit->labelString().empty())
tocstring = pit->labelString() + ' ';
- tocstring += par.asString(false);
+ tocstring += par.printableString(false);
break;
}
default:
pit.pos() = 0;
// insert this into the table of contents
if (tocstring.empty())
- tocstring = pit->asString(true);
+ tocstring = pit->printableString(true);
toc.push_back(TocItem(pit, toclevel - min_toclevel,
tocstring));
}
pit.push_back(CursorSlice(*this));
Toc & toc = buffer().tocBackend().toc(type_);
- docstring const str = full_label_ + ". " + text_.getPar(0).asString(false);
+ docstring const str = full_label_ + ". " + text_.getPar(0).printableString(false);
toc.push_back(TocItem(pit, 0, str));
}