[LyX/master] fix get_quoted_value

José Matos jaomatos at gmail.com
Thu Aug 15 08:35:47 UTC 2024


On Thu, 2024-08-15 at 06:06 +0000, Juergen Spitzmueller wrote:
> -    return val.strip('"')
> +    # remove only outer pair of quotes,
> +    # hence do not use strip('"')
> +    if val[:1] == '"':
> +        val = val[1:]
> +    if val[-1:] == '"':
> +        val = val[:-1]
> +    
> +    return val

This will only fail for cases where there are multiple opening and
closing quotes.
Is that our case?


BTW I usually prefer code that is more expressive:

if val.startswith('"'):
    val =  val[1:]
if val.endswith('"'):
    val =  val[:-1]


On a tangent note, since the C++20 standard strings have the
starts_with and ends_with methods. :-)

-- 
José Abílio


More information about the lyx-devel mailing list