Page MenuHomePhabricator

P-wrap DOM pass should not expand range of paragraphs to include rendering-transparent link tags from templates
Open, MediumPublic

Description

In some cases, Parsoid's p-wrap DOM pass expands the scope of a template to include a preceding paragraph. The following Parsoid command-line session demonstrates the problem.

[subbu@earth:~/work/wmf/parsoid] echo -e "foo\n\n{{1x|[[Category:Boo]]<div>x</div>}}" | php bin/parse.php --dump dom:pre-pwrap,dom:post-pwrap
----- DOM: pre-pwrap -----
<body data-parsoid='{"tmp":{}}'>foo

<meta typeof="mw:Transclusion" about="#mwt1" data-parsoid='{"tsr":[5,40],"src":"{{1x|[[Category:Boo]]&lt;div>x&lt;/div>}}","tmp":{"tplarginfo":"{\"dict\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"[[Category:Boo]]&lt;div>x&lt;/div>\"}}},\"paramInfos\":[{\"k\":\"1\",\"srcOffsets\":[10,10,10,38]}]}","tagId":2}}'/><link rel="mw:PageProp/Category" href="./Category:Boo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Boo"},"sa":{"href":"Category:Boo"},"tmp":{"inTransclusion":true,"tagId":3}}'/><div data-parsoid='{"stx":"html","tmp":{"inTransclusion":true,"tagId":4}}'>x</div><meta typeof="mw:Transclusion/End" about="#mwt1" data-parsoid='{"tsr":[null,40],"tmp":{"inTransclusion":true,"tagId":5}}'/>
</body>

--------------------------

----- DOM: post-pwrap -----
<body data-parsoid='{"tmp":{}}'><p data-parsoid='{"tmp":{}}'>foo

<meta typeof="mw:Transclusion" about="#mwt1" data-parsoid='{"tsr":[5,40],"src":"{{1x|[[Category:Boo]]&lt;div>x&lt;/div>}}","tmp":{"tplarginfo":"{\"dict\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"[[Category:Boo]]&lt;div>x&lt;/div>\"}}},\"paramInfos\":[{\"k\":\"1\",\"srcOffsets\":[10,10,10,38]}]}","tagId":2}}'/><link rel="mw:PageProp/Category" href="./Category:Boo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Boo"},"sa":{"href":"Category:Boo"},"tmp":{"inTransclusion":true,"tagId":3}}'/></p><div data-parsoid='{"stx":"html","tmp":{"inTransclusion":true,"tagId":4}}'>x</div><meta typeof="mw:Transclusion/End" about="#mwt1" data-parsoid='{"tsr":[null,40],"tmp":{"inTransclusion":true,"tagId":5}}'/>
</body>

---------------------------

<p about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"dsr":[0,40,0,0],"firstWikitextNode":"P","pi":[[{"k":"1"}]]}' data-mw='{"parts":["foo\n\n",{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"[[Category:Boo]]&lt;div>x&lt;/div>"}},"i":0}}]}'>foo

<link rel="mw:PageProp/Category" href="./Category:Boo"/></p><div about="#mwt1" data-parsoid='{"stx":"html"}'>x</div>

It is not clear why the p-wrap token pass did not already create a p-wrapper for foo there.


Original Bug Report:

The bug can be seen in the attached screenshot. In short, if the maintenance template starts with a category, selecting the template also selects the preceding paragraph. Selecting in the paragraph also selects the template just like it would be part of the template.

The issue can be reproduces with this article version and this template version.

The issue was solves with this change.

Wikipedia.jpg (1×1 px, 253 KB)

Event Timeline

ssastry renamed this task from Category in front of maintenance template makes VE select more than it should to P-wrap DOM pass expands range of paragraphs to include rendering-transparent link tags from templates.Nov 9 2020, 7:38 PM
ssastry renamed this task from P-wrap DOM pass expands range of paragraphs to include rendering-transparent link tags from templates to P-wrap DOM pass should not expand range of paragraphs to include rendering-transparent link tags from templates.
ssastry triaged this task as Medium priority.
ssastry updated the task description. (Show Details)
ssastry moved this task from Needs Triage to Feature requests on the Parsoid board.