gnosygnu / xowa

xowa offline wiki application
Other
379 stars 40 forks source link

onlyinclude flag incorrectly triggered #825

Closed desb42 closed 3 years ago

desb42 commented 3 years ago

I started with en.wikipedia.org/wiki/Help:Displaying_a_formula#Chemistry

desb42 commented 3 years ago

Oops

And noticed a difference between mediawiki and xowa chem

At least a bullet point is missing

Further investigation leads to the wikitext:

{{xtag|chem|p}}

(among many xtag calls)

Calling this wikitext on its own gives a blank (completely empty) response

Under debug it turns out that this template does not 'execute' any code

This turns out to be caused by 400_xowa\src\gplx\xowa\parsers\tmpls\Xot_defn_tmpl.java function Extract_onlyinclude being called when it should not

This in turn is happening because of code in 400_xowa\src\gplx\xowa\parsers\Xop_parser.java function Parse_text_to_defn The line

boolean only_include_chk = Bry_find_.Find_fwd(src, Xop_xnde_tag_.Bry__onlyinclude, 0, src.length) != Bry_find_.Not_found;

is the issue

Template:Xtag has the word onlyinclude in it not the tag <onlyinclude> but the above code currently is checking for the word hence the issue

Modifying 400_xowa\src\gplx\xowa\parsers\xndes\Xop_xndetag.java Line

public static final    byte[] Bry__onlyinclude = Bry_.new_a7("onlyinclude");

to

public static final    byte[] Bry__onlyinclude = Bry_.new_a7("<onlyinclude");

seems to fix it

gnosygnu commented 3 years ago

Wow! That must have taken a long time to debug!

Thanks for all the work! Fixed with the commit above