Page MenuHomePhabricator

SyntaxHighlight in list item produces unbalanced HTML
Closed, ResolvedPublic

Description

The highlighting of source code on https://www.mediawiki.org/w/index.php?title=Extension:QuestyCaptcha&oldid=1650379 seems to be broken. Also, it works fine when in 'Edit' mode (using VE).

Event Timeline

polybuildr raised the priority of this task from to Needs Triage.
polybuildr updated the task description. (Show Details)
polybuildr subscribed.
polybuildr set Security to None.
polybuildr added a subscriber: Emufarmers.

I was able to fix it by making this edit. Looks like it doesn't work properly if there is no linebreak before the source tag.

Glaisher renamed this task from Source highlighting issue on mw:Extension:QuestyCaptcha to Source highlighting doesn't work properly if there is no space before <source> tag.Jun 27 2015, 5:24 PM
Glaisher added a project: Regression.
Glaisher added subscribers: Krinkle, ori, matmarex.

I don't think this happened when GeSHi was used (I might be wrong).

I would blame the list syntax, not the newlines. This is probably some new exciting Tidy behavior we're running into. Perhaps we render some whitespace differently, or perhaps the wrapper tags are different, or perhaps something else…

This works correctly:

foo <source>a
b</source>

These don't:

* <source>a
b</source>

* foo<source>a
b</source>

* foo <source>a
b</source>

pasted_file (481×464 px, 8 KB)

matmarex renamed this task from Source highlighting doesn't work properly if there is no space before <source> tag to Source highlighting doesn't work properly if the <source> tag being in a wikitext list.Jun 27 2015, 7:06 PM
matmarex renamed this task from Source highlighting doesn't work properly if the <source> tag being in a wikitext list to Source highlighting doesn't work properly if the <source> tag begins in a wikitext list.
Edokter renamed this task from Source highlighting doesn't work properly if the <source> tag begins in a wikitext list to Source highlighting doesn't work properly if the <source> tag does not start on a new line.Jun 28 2015, 8:12 AM

It has alwasy broken inside a list item wihtout the enclose=div option (which was a hack in itself). We should make it a good habit of no longer using it inside a wikilist item. Other then that, wether it is Tidy or the parser getting confused (I'd have to test using ExpandTemplates), the extension should always treat it as a new block context.

We should make it a good habit of no longer using it inside a wikilist item.

I would prefer T70466: Add parser test for multiline <pre> or <syntaxhighlight> elements inside a dd element created by ":", to suport better the usage of these elements inside of lists.

I would prefer T70466: Add parser test for multiline <pre> or <syntaxhighlight> elements inside a dd element created by ":", to suport better the usage of these elements inside of lists.

The problem is that wiki list items are single line entities; a linebreak terminates them. They cannot contain multi-line elements of any kind wihtout changing the fundamentals of the parser.

matmarex renamed this task from Source highlighting doesn't work properly if the <source> tag does not start on a new line to Source highlighting doesn't work properly if the <source> tag begins in a wikitext list.Jun 29 2015, 6:54 PM
matmarex added a subscriber: Nemo_bis.

Example:

https://wikitech.wikimedia.org/w/index.php?title=How_to_deploy_code&oldid=167361#The_Resource_Loader_.28RL.29_and_l10n

After the ResourceLoader section, the "Security patches" section has a notably larger font. This is because the body container's DIV element ended up being closed and as such the flow is no longer valid.

Wikitext:

The Resource Loader (RL) and l10n

In the case of a locaization update that affects JavaScript and is loaded via the [[mw:ResourceLoader|ResourceLoader]] the live string may remain unchanged after running scap; troubleshooting steps follow:

  1. Check <code>/MediaWiki:<string-key></code> on the wiki in question to see if the string has been updated, e.g. to check the <code>popups-send-feedback</code> string (from the [[mw:Extension:Popups|Popups extension]]) on enwiki visit <code>https://en.wikipedia.org/wiki/MediaWiki:Popups-send-feedback</code>
  2. If that string '''has''' been updated, check the <code>msg_resource</code> table in the database of the appropriate wiki for the apprpriate language <syntaxhighlight lang="sql">select * from msg_resource where mr_resource='<resource>' and mr_lang='<lang>'\G</syntaxhighlight>
  3. It may be necessary to truncate the <code>msg_resource</code> database table if the string in <code>msg_resource</code> is out of date, but the wiki '''does''' see the new string (checked in step 1) <syntaxhighlight lang="sql">truncate msg_resource;</syntaxhighlight>
<h2>..The Resource Loader (RL) and l10n..</h2>
<p>In the case of a localization update ..</p>
<ol><li> Check ..</li>
<li> If that string .. language <div class="mw-highlight"><pre><span class="k">select</span> ..<span class="k">G</span></li></ol>
</pre></div>
<ol><li> It may ..step 1 <div class="mw-highlight"><pre><span class="k">truncate</span> <span class="n">msg_resource</span><span class="p">;</span></li></ol>
</pre></div>
<h2>..Security patches..</h2>

It seems the list item, and even the list itself, are closed before mw-highlight.

Krinkle renamed this task from Source highlighting doesn't work properly if the <source> tag begins in a wikitext list to SourceHighlight in list item produces unbalanced HTML.Jun 29 2015, 6:59 PM
Krinkle triaged this task as High priority.
Krinkle moved this task from Backlog to Accepted on the SyntaxHighlight board.

Change 221740 had a related patch set uploaded (by Bartosz Dziewoński):
Use 'nowiki' strip marker for <syntaxhighlight/> output

https://gerrit.wikimedia.org/r/221740

Change 221740 abandoned by Bartosz Dziewoński:
Use 'nowiki' strip marker for <syntaxhighlight/> output

Reason:
This is a very clever idea but probably not something we want to maintain. T104067 should be fixable using a variant of this solution described by Brad on the changeset. I'll implement it and submit as a new patch.

https://gerrit.wikimedia.org/r/221740

Change 221980 had a related patch set uploaded (by Bartosz Dziewoński):
Refactor final output formatting

https://gerrit.wikimedia.org/r/221980

Change 221980 merged by jenkins-bot:
Refactor final output formatting

https://gerrit.wikimedia.org/r/221980

matmarex renamed this task from SourceHighlight in list item produces unbalanced HTML to SyntaxHighlight in list item produces unbalanced HTML.Jul 6 2015, 4:43 PM
matmarex claimed this task.
matmarex removed a project: Patch-For-Review.