-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Clean up "html" pseudo-mode hacks #2965
Comments
Not part of Sprint 21 |
reviewed, @gruehle, @peterflynn I wonder if this is worth a x point improvement story? |
Made it a medium priority, pending further review |
Actually the "xml" mode would already register a "text/html" mode:
But it's already taken by "htmlmixed":
So there's a conflict here. |
Regarding using "html" as the MIME mode, either this was overlooked or MIME modes don't need a slash, but the "gfm" mode does this:
This might indicate we could just use "html" as a MIME mode, requiring fewer changes indeed. However, we'd still need to map the mode "html" for the language "HTML" to itself, as we now do with "xml". The latter currently doesn't even have an effect, that's just a preparation for when we remove the hack in |
Regarding a) - how are we leaving anything exposed there? Nobody tells HTMLUtils to do something with "xml", it just does this internally, right? |
We have a number of hacks to deal with the fact that the tokens "htmlmixed" mode generates for HTML content actually say their mode is "xml". (We care about the mode of individual tokens so as to distinguish JS, CSS, etc. that might be embedded in the HTML).
_setLanguageForMode("html", html)
at bottom)html._setLanguageForMode("xml", html)
at bottom -- the only usage of this mechanism).There are several ways we could fix this & remove those hacks:
a) Make HTMLUtils and other code handle seeing "xml" tokens. Dennis pointed out that much of the functionality there should be callable on any XML content anyway (e.g. getTagAttributes(), getTagInfo()). Cons: tokens remain seemingly confusing; would never be able to distinguish any sort of non-HTML XML embedded inside HTML; we're basically leaving an implementation detail of htmlmixed mode exposed; may break extensions.
b) Change htmlmixed to pull in XML mode by a mimetype alias, which is increasingly becoming the "official" way to reference modes with non-default configurations. So instead of
CodeMirror.getMode(config, {name: "xml", htmlMode: true})
it would doCodeMirror.getMode(config, "text/html")
). But we'd either have to change all our code that looks for a mode name "html" to look for "text/html" instead, or use "html" as the mime name even though it's not in mimetype format. Cons: requires CodeMirror changes; may involve nonstandard usage of CM's mimetype facility.For original discussion, see these threads:
The text was updated successfully, but these errors were encountered: