{
// Nested cprotect content needs \cprotect
// on each level
- if (hasCProtectContent(fragile))
+ if (producesOutput() && hasCProtectContent(fragile))
return true;
// Environments generally need cprotection in fragile context
if (!maintext && getLayout().latextype() != InsetLayout::COMMAND)
return true;
+ // If the inset does not produce output (e.g. Note or Branch),
+ // we can ignore the contained paragraphs
+ if (!producesOutput())
+ return false;
+
// Commands need cprotection if they contain specific chars
int const nchars_escape = 9;
static char_type const chars_escape[nchars_escape] = {