bool Paragraph::needsCProtection() const
{
- // first check the layout of the paragraph
- if (layout().needcprotect) {
+ // first check the layout of the paragraph, but only in insets
+ InsetText const * textinset = inInset().asInsetText();
+ bool const maintext = textinset
+ ? textinset->text().isMainText()
+ : false;
+
+ if (!maintext && layout().needcprotect) {
// Environments need cprotection regardless the content
if (layout().latextype == LATEX_ENVIRONMENT)
return true;
// now check whether we have insets that need cprotection
pos_type size = d->text_.size();
for (pos_type i = 0; i < size; ++i)
- if (isInset(i) && getInset(i)->needsCProtection())
+ if (isInset(i) && getInset(i)->needsCProtection(maintext))
return true;
return false;