Jump to content

Specs/HTML/2.8.0/Extensions/Indicator

From mediawiki.org

Parsoid started supporting <indicator> tags after 2.8.0 HTML version was bumped.

Preliminaries

[edit]

Since indicators are meant to be hoisted from their place of definition to wherever a skin wants to display it, Parsoid represents indicators as a meta tag with a typeof value indicating that the meta tag represents an indicator (Caveat: except when the markup has errors - see examples below).

The data-mw attribute has the standard representation as with extensions in general. The data-mw.name property has the tag name and data-mw.attrs has key-value representations of all attributes present on the tag. In addition, data-mw.body has two properties, extsrc and html. The extsrc property has the content of the extension's content (in this case, the indicator's wikitext source). In addition, for clients that care about the output of the indicator, the generated output (HTML) can be found in the data-mw.body.html property.

Within core and extensions, this output continues to available through ParserOutput where skins and other code expect to find indicator content.

Editing

[edit]

Editing clients are expected to update the data-mw.body.html property which Parsoid will convert back to wikitext to represent the edits.

Examples

[edit]

Some examples:

Wikitext HTML
<indicator name='x'>[[Foo]] ''bar''</indicator>
<meta typeof="mw:Extension/indicator" about="#mwt2" data-mw='{"name":"indicator","attrs":{"name":"x"},"body":{"extsrc":"[[Foo]] &apos;&apos;bar&apos;&apos;"},"html":"&lt;a rel=\"mw:WikiLink\" href=\"./Foo\" title=\"Foo\" data-parsoid=&apos;{\"stx\":\"simple\",\"a\":{\"href\":\"./Foo\"},\"sa\":{\"href\":\"Foo\"},\"dsr\":[20,27,2,2]}&apos;>Foo&lt;/a> &lt;i data-parsoid=&apos;{\"dsr\":[28,35,2,2]}&apos;>bar&lt;/i>"}'/>
<indicator>[[Foo]] ''bar''</indicator>
<p data-parsoid='{"dsr":[0,38,0,0]}'><span typeof="mw:Extension/indicator mw:Error" about="#mwt2" data-parsoid='{"dsr":[0,38,11,12]}' data-mw='{"name":"indicator","attrs":{},"body":{"extsrc":"[[Foo]] &apos;&apos;bar&apos;&apos;"},"errors":[{"key":"invalid-indicator-name"}]}' data-mw-i18n='{"/":{"lang":"x-user","key":"invalid-indicator-name","params":[]}}'>invalid-indicator-name</span></p>

As the second example shows, errors in markup are represented with spans that have a mw:Error typeof value (along with the mw:Extension/indicator value to indicate the type of extension tag). Like all other errors, more information is available in the data-mw.errors property. Note that canonical Parsoid HTML (served by the APIs) will not have the errors localized.

Additional notes

[edit]

While data-mw.body.extsrc is available, this property may be removed since the data-mw.body.html has the fully rendered output and is potentially more useful (and for clients that do need the wikitext form, they can get it via html->wikitext transformations). This change might come in the future.