Open desb42 opened 5 years ago
Thanks for the write-up. Most of the logic for white-space trimming is here (trim start is below, but trim end is very similar): https://github.com/gnosygnu/xowa/blob/master/400_xowa/src/gplx/xowa/parsers/tmpls/Arg_bldr.java#L152-L154 . The code is as follows
case Xop_arg_wkr_.Typ_prm : trim = arg_idx == 0; break;
case Xop_arg_wkr_.Typ_tmpl: trim = key_exists || arg_idx == 0; break;
case Xop_arg_wkr_.Typ_lnki: trim = cur_itm_is_key || !key_exists; break; // NOTE (this comment was wrong): trim if " a=b"; skip if "a= b" or " a"
First, about the different types
Typ_prm
is for triple-braces. For example: {{{ k1 }}}
Typ_tmpl
is for double-braces. For example: {{test|1=a|2=b}}
Typ_lnki
is for double-brackets. For example: [[File:A.png|page=123]]
So, that said, the logic is as follows
{{{1| a }}}
[[File:A.png| page=123]]
Now, that said, this logic was derived by testing various inputs. I didn't check MediaWiki code at the time, and I suspect the rules above are wrong or have changed.
This may explain the divergence above. Let me look at this some more as well
this was triggered by looking at en.wikipedia.org/wiki/Template:Dubious There is a line of wikitext
Note the indicated space character In xowa this is:
In mediawiki
Note the space between the end of
dubious
and the pipe character|
I always thought that whitespace was trimmed from the beggining and end of 'pipe' arguments On other experiments that I will not go into here, it seems that there is a difference between positional arguments and keyed arguments. A difference is that mediawiki 'trims' the keyed arguments in a different way to the positional ones
Further experiments show some other differences This wikitext
Produces in xowa
In mediawiki
Note the failures