Page MenuHomePhabricator

Extension attribute key-value pairs should be strings, not tokens
Open, MediumPublic

Description

Parsoid currently tokenizes extension keys and values into arbitrary tokens like everything else. However, these should be treated like strings, not as wikitext. Extensions get to interpret those strings however they want. If wikitext, they would request the extension API to expand that wikitext for them (ex: gallery captions).

So, for example <ref name="{{1x|foo}}">....</ref> would not be a ref with name="foo" attribute. It would be a ref with a name="{{1x|foo}}" attribute (you can try it on a wiki). Templates aren't expanded.

This can actually lead to further simplifications of Parsoid's extension API since extensions will now get string-typed keys and values for extension arguments and no longer have to mess with KV objects.

For starters, this tokens-to-string conversion can happen in the ExtensionHandler class (along with suppressing their processing in AttributeExpander). But, as the next step, we could split the xml-tag grammar rules to handle extension attributes as plain strings.