Page MenuHomePhabricator

Old syntax tvar breaks templates
Open, MediumPublicBUG REPORT

Description

When an old syntax tvar (<tvar|var>) is used in a template, it breaks the template because the | is seen as a new argument separator.

As an example:

$ echo '{{1x|<tvar|1d>test</> test}}' | php bin/parse.php --wt2html --scrubWikitext
<p data-parsoid='{"dsr":[0,28,0,0]}'><span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]],"dsr":[0,28,null,null]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;tvar|1d>test&lt;/> test"}},"i":0}}]}'>&lt;tvar</span></p>

We'd expect the "test" content to be visible akin to this:

$ echo '{{1x|<tvar>test</tvar> test}}' | php bin/parse.php --wt2html 
<p data-parsoid='{"dsr":[0,29,0,0]}'><span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]],"dsr":[0,29,null,null]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;tvar>test&lt;/tvar> test"}},"i":0}}]}'>test test</span></p>

Event Timeline

I am borderline inclined to decline this ... one more reason to see if we can get old syntax migrated over with bots, etc. cc @Nikerabbit

Arlolra triaged this task as Medium priority.Wed, Nov 24, 5:33 PM
Arlolra moved this task from Needs Triage to Known Differences on the Parsoid board.
Arlolra added a subscriber: Arlolra.

When an old syntax tvar (<tvar|var>) is used in a template, it breaks the template because the | is seen as a new argument separator.

Noting because I was confused, there's nothing wrong with the tokenization here,

0-[peg]        | ---->   [{"type":"SelfclosingTagTk","name":"template","attribs":[{"k":"1x","v":"","srcOffsets":[2,4,4,4]},{"k":"","v":[{"type":"SelfclosingTagTk","name":"meta","attribs":[{"k":"typeof","v":"mw:Annotation/tvar"},{"k":"data-mw","v":"{\"attrs\":{\"name\":\"1d\"}}"}],"dataAttribs":{"tmp":null,"tsr":[5,14]}},"test",{"type":"SelfclosingTagTk","name":"meta","attribs":[{"k":"typeof","v":"mw:Annotation/tvar/End"}],"dataAttribs":{"tmp":null,"tsr":[18,21]}}," test"],"srcOffsets":[5,5,5,26]}],"dataAttribs":{"tmp":{"tagId":null,"bits":0,"leadWS":"","trailWS":""},"tsr":[0,28],"src":"{{1x|<tvar|1d>test</> test}}"}}]

The difference is in template expansion on the MediaWiki end but probably better solved in T295834