Page MenuHomePhabricator

Add parser test for multiline <pre> or <syntaxhighlight> elements inside a dd element created by ":"
Closed, ResolvedPublic

Assigned To
Authored By
He7d3r
Jul 23 2014, 7:24 PM
Referenced Files
F35530999: image.png
Sep 23 2022, 4:59 PM
F35530997: image.png
Sep 23 2022, 4:59 PM
F35530988: image.png
Sep 23 2022, 4:58 PM
F35530987: image.png
Sep 23 2022, 4:58 PM
F35530985: image.png
Sep 23 2022, 4:58 PM
F35530982: image.png
Sep 23 2022, 4:58 PM
Tokens
"Like" token, awarded by ToBeFree.

Description

Please, add some parser tests to ensure that Parsoid interprets the wiki markup

;A
:B<syntaxhighlight lang="CSS">
.test {
    color: red;
}
</syntaxhighlight>

as having 'an element <dd> which contains "B" and the highlighted code', instead of what the current parser does:
https://www.mediawiki.org/w/index.php?title=Project:Sandbox&oldid=1075316&action=edit&preview=yes

Here is a comparison of the wiki markup and HTML markup with the current parser:
https://www.mediawiki.org/w/index.php?title=Project:Sandbox&oldid=1075311

And here is the same kind of problem with <pre> tags instead of <syntaxhighlight>:
https://www.mediawiki.org/w/index.php?title=Project:Sandbox&oldid=1075317&action=edit&preview=yes
The current parser converts the code

;A
:B<pre>first line
second line</pre>

to

<dl>
<dt>A</dt>
<dd>B
<pre>first line
</pre></dd>
</dl>
<p>second line</p>

but it should be converted to

<dl>
<dt>A</dt>
<dd>B
<pre>first line
second line
</pre></dd>
</dl>

as Parsoid does:
http://parsoid-lb.eqiad.wikimedia.org/mediawikiwiki/Project:Sandbox?oldid=1075317

Details

Reference
bz68466

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 3:27 AM
bzimport added a project: Parsoid.
bzimport set Reference to bz68466.

The second test can be added right away -- there are a number of dl/dd list tests in a section. Your test can be added there. Would you like to submit a patch to parserTests.txt in the parsoid repo? If not, one of us will pick it up in the coming days.

He7d3r set Security to None.
Arlolra subscribed.

This is because <syntaxhighlight> gets unstripped before doBlockLevels(),
https://github.com/wikimedia/mediawiki/blob/08510de602c239a60d0918bdbf666250d8ac5846/includes/parser/Parser.php#L1651-L1653

There was an attempt to hide the content in a nowiki stripmarker in T104067 since that gets unstripped later in the function, after those passes, but was abandoned.

We probably want to say this will be resolved when Parsoid is the default parser.

matmarex claimed this task.
matmarex subscribed.

I think the issue with <syntaxhighlight> tags was actually fixed by the changes for T104067.

Both of the examples given in this task look correct, and they look the same in old parser and in Parsoid:

This behavior is covered by a parser test added along with those changes, which is still found today here: https://gerrit.wikimedia.org/g/mediawiki/extensions/SyntaxHighlight_GeSHi/+/0cb5db91b8052b90281744d65491b9e163117048/tests/parser/parserTests.txt#107

!! test
Multiline <source/> in lists
!! options
parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
!! wikitext
*<source>a
b</source>
*foo <source>a
b</source>
!! html
<ul><li><div class="mw-highlight mw-content-ltr" dir="ltr"><pre>a
b</pre></div></li></ul>
<ul><li>foo <div class="mw-highlight mw-content-ltr" dir="ltr"><pre>a
b</pre></div></li></ul>
!! end