On Saturday, 13 May 2017 19.39.55 WEST Uwe Stöhr wrote:
> commit 0dd3311dd42996f9aede7d8c58b27937ebb48b54
> Author: Uwe Stöhr <uwesto...@lyx.org>
> Date:   Sat May 13 20:39:45 2017 +0200
> 
>     rename buffer parameter math_number_before to math_numbering_side
> 
>     this is a fileformat change
> 
>     also try to fix an UI issue that JMarc gets
> 
> +def convert_mathnumberingname(document):
> +    " rename the \\math_number_before tag to \\math_numbering_side "
> +    document.warning("Malformed LyX document: Missing '\\end_inset' of
> Float inset.")

As Guillaume suggested I think that this warning is incorrect. The function 
does not check for insets since it works on the header and also this call is 
unconditional...

> +    regexp = re.compile(r'(\\math_number_before 1)')
> +    i = find_re(document.header, regexp, 0)
> +    if i != -1:
> +        document.header[i] = "\\math_numbering_side left"
> +    regexp = re.compile(r'(\\math_number_before 0)')
> +    i = find_re(document.header, regexp, 0)
> +    if i != -1:
> +        document.header[i] = "\\math_numbering_side default"
> +    # check if the document uses the class option "reqno"
> +    k = find_token(document.header, "\\math_numbering_side", 0)

This part of the code is OK:

> +    regexp = re.compile(r'^.*reqno.*')
> +    i = find_re(document.header, regexp, 0)
> +    if i != -1:
> +        document.header[k] = "\\math_numbering_side right"
> +        # delete the found option
> +        document.header[i] = document.header[i].replace(",reqno", "")
> +        document.header[i] = document.header[i].replace(", reqno", "")
> +        document.header[i] = document.header[i].replace("reqno,", "")
> +        j = find_re(document.header, regexp, 0)
> +        if i == j:
> +            # then we have reqno as the only option
> +            del document.header[i]
> +
> +

My objection are on this part of the code. Basically we search for a reference 
to reqno in the lyx header, that in this case means the latex preamble or the 
class options to equate the reqno reference to using the reqno option.

It is very easy to produce a false positive by placing in the latex preamble 
of the document:

% it would be interesting to use reqno for all or some of the equations

Just the mention of reqno is interpreted as transforming the document to use 
the equation number on the right.

IMHO we should left this option to the user as we do in all the other cases. 
In this case that would mean removing the last part of the function.

Regards,
-- 
José Abílio

Reply via email to