Page MenuHomePhabricator

CodeMirror stops processing at a TemplateStyles tag with parameters on the page
Closed, ResolvedPublic

Assigned To
Authored By
Izno
Sep 23 2020, 9:30 PM
Referenced Files
F34607043: image.png
Aug 19 2021, 6:54 PM
F34607039: image.png
Aug 19 2021, 6:54 PM
F34607036: image.png
Aug 19 2021, 6:54 PM
F34607046: image.png
Aug 19 2021, 6:54 PM

Description

I didn't see another tag, but when CodeMirror (I think it's CodeMirror that provides highlighting in the 2010/2017 wikitext editors?) hits a TemplateStyles tag it gives up and stops processing the rest of the page when there are also parameters on the page (but some of the page highlighting is fine in some cases; see TQI template).

https://en.wikipedia.org/w/index.php?title=User:Izno/Sandbox&oldid=980018629
https://en.wikipedia.org/w/index.php?title=Template:Talk_quote_inline&oldid=859108285

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Based on the cite extension model for highlighting, I think the correct place to make a fix is in TemplateStyles?

Tgr subscribed.

I doubt so. CodeMirror should be able to handle extension tags. Maybe it doesn't correctly parse self-closing tags?

I doubt so. CodeMirror should be able to handle extension tags. Maybe it doesn't correctly parse self-closing tags?

It's not that it can't, it's that it's not responsible for the definition of the extension tags, I don't think (it could be that it doesn't handle self-closing extension tags; it has no issue with <br/> of course). /resources/mode/mediawiki/mediawiki.js doesn't have poem or ref defined... and in fact I have no idea where those are defined.

@Izno can you link to a page that, when editing, shows this issue?

Izno renamed this task from CodeMirror stops processing at a TemplateStyles tag to CodeMirror stops processing at a TemplateStyles tag with parameters on the page.Sep 24 2020, 4:02 AM
Izno updated the task description. (Show Details)

@Izno can you link to a page that, when editing, shows this issue?

Added a page.

Extension tags are basically just XML syntax, and their names are available via MediaWiki configuration. CodeMirror shouldn't require custom setup to recognize them, only to highlight their contents in some specific way (but TemplateStyles tags have no content).

I narrowed this down: This occurs when there is a slash / in the src attribute of the templatestyles tag and doesn't seem to otherwise.

I narrowed this down: This occurs when there is a slash / in the src attribute of the templatestyles tag and doesn't seem to otherwise.

A combination of that and not having a space between the attribute and the closing />. And it only happens with <templatestyles>, not e.g. <cite src="Module:Citation/CS1/styles.css"/>. Weird - there's nothing TemplateStyles-specific in CodeMirror, or CodeMirror-specific in TemplateStyles.

Izno closed this task as Resolved.EditedAug 19 2021, 6:54 PM
Izno claimed this task.

I can't reproduce this anymore in the same way that I think I could in the original report (should have got a screenshot /sigh).

image.png (151×1 px, 10 KB)

image.png (242×1 px, 26 KB)

There does still seem to be an issue: certain HTML tags won't display as expected. In the two links from the description. I think it may just be that <q> is not recognized by the syntax highlighter? <p> and <div> both highlight, though suboptimally:

image.png (194×1 px, 11 KB)

image.png (268×1 px, 26 KB)