[LyX/master] \cprotect some content in captions

Scott Kostyshak skostysh at lyx.org
Sun Sep 20 00:14:49 UTC 2020


On Sun, Apr 21, 2019 at 04:38:20PM +0200, Juergen Spitzmueller wrote:
> commit c9432ccbbc2ec0029d9ac59ed8da126f4a02a910
> Author: Juergen Spitzmueller <spitz at lyx.org>
> Date:   Sun Apr 21 16:44:29 2019 +0200
> 
>     \cprotect some content in captions
>     
>     Fixes: #6243
> ---
>  src/Paragraph.cpp        |   29 ++++++++++++++++++++++++++---
>  src/insets/InsetText.cpp |   11 ++++++-----
>  src/insets/InsetText.h   |    2 +-
>  3 files changed, 33 insertions(+), 9 deletions(-)

Starting with this commit, the attached document loads the cprotect
package but cprotect command is never used. See comment below the code.

> 
> diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
> index a41fe67..59cfa64 100644
> --- a/src/Paragraph.cpp
> +++ b/src/Paragraph.cpp
> @@ -1647,6 +1647,8 @@ void Paragraph::validate(LaTeXFeatures & features) const
>  	d->validate(features);
>  	bool fragile = features.runparams().moving_arg;
>  	fragile |= layout().needprotect;
> +	if (inInset().getLayout().isNeedProtect())
> +		fragile = true;
>  	if (needsCProtection(fragile))
>  		features.require("cprotect");
>  }
> @@ -3435,10 +3437,31 @@ bool Paragraph::needsCProtection(bool const fragile) const
>  	}
>  
>  	// 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(maintext, fragile))
> +	pos_type size = pos_type(d->text_.size());
> +	for (pos_type i = 0; i < size; ++i) {
> +		if (!isInset(i))
> +			continue;
> +		Inset const * ins = getInset(i);
> +		if (ins->needsCProtection(maintext, fragile))
> +			return true;
> +		if (ins->getLayout().latextype() == InsetLayout::ENVIRONMENT)
> +			// Environments need cprotection regardless the content
> +			return true;

This is the "return true" that seems to happen with the document.

Scott
-------------- next part --------------
A non-text attachment was scrubbed...
Name: unnecessary-cprotect.23.lyx
Type: application/x-lyx
Size: 1894 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20200919/bed471db/attachment.lyx>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20200919/bed471db/attachment.asc>


More information about the lyx-devel mailing list