Page MenuHomePhabricator

CodeMirror 6 MediaWiki stream parser produces excess markup
Open, LowPublicBUG REPORT

Description

Background

In working on T348019: Port MediaWiki mode to CodeMirror 6 stream-parser, I have hit a wall with one particular issue where identical adjacent tokens unnecessarily have separate <span> tags. This does not visually produce any issue, but the excess markup could pose a performance problem.

I tried reproducing the issue with CodeMirror 6's "Try" feature, but in doing so I believe I have concluded this is not an issue with CM6 but with my code.

Steps to replicate the issue (include links if applicable):

  • Check out r972438
  • Start a new page with CM6 enabled (i.e. ?cm6enable=1)
  • Add only the content https://wikimedia.org

What happens?:

The markup is as follows:

<div class="cm-line">
  <span class="cm-mw-free-extlink-protocol">https://</span>
  <span class="cm-mw-free-extlink">wikimedia.</span>
  <span class="cm-mw-free-extlink">org</span>
</div>

What should have happened instead?:

The markup should be:

<div class="cm-line">
  <span class="cm-mw-free-extlink-protocol">https://</span>
  <span class="cm-mw-free-extlink">wikimedia.org</span>
</div>

Software version

CodeMirror with r972438 checked out

Other information (browser name/version, screenshots, etc.):

The above is just one example. This happens in many cases, such as table headings:

{| class="wikitable"

produces:

<div class="cm-line">
  <span class="cm-mw-table-bracket">{|</span>
  <span class="cm-mw-table-definition">class</span>
  <span class="cm-mw-table-definition">="wikitable"</span>
</div>

There should be just one span for .cm-mw-table-definition.

Event Timeline

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

It is not a fair comparison. If we try to faithfully reproduce the eatFreeExternalLink on the CodeMirror 6 website (demo), a similar issue occurs.

I think it's still an issue with our code. Or at least, other legacy stream parsers don't seem to have this issue.

Overall though, after seeing how fast CodeMirror 6 is even with the extra markup, I'm thinking it may not be a *must* for the CM6 upgrade project. But I definitely want to investigate more before giving up.

Not a blocker for rolling out CM6, but this should be revisited at some point.

It never hurts to ask the maintainers, right?! https://discuss.codemirror.net/t/streamparser-can-produce-excess-markup/8770

This is now fixed upstream. I'll look into this at a later time, since it will require a bump to the language package which may require other packages to be bumped (see also T358804#10065810).