Help:Extension:Linter/misnested-tag

From MediaWiki.org
Jump to navigation Jump to search

Other languages:
English • ‎dansk • ‎polski • ‎日本語

The misnested tag warning is triggered when some tag or wikitext markup is closed outside of its parent and those tags or marks are overlapped. This linter category has been added to assist editors in fixing wikitext and templates that have instances of misnested tags. Linter will flag a warning for all the examples below. We are treating this as a warning currently.

Example 1:

<b> foo <i> bar </b> baz </i>

Example 2:

''' foo '' bar ''' baz ''

Example 3:

* a
* b <small> c
* d </small>
* e

Example 4:

<small> foo
* a
* b
bar </small>

Example 5:

''<span>foo''</span>

In Examples 1 and 2, the <i> tag (either in HTML or wikitext form) should be properly nested inside the<b> tag. While the parsers fix this up right now, the output may not always be what the editors intended.

In Example 3, the <small> tag should be closed and reopened on lines 2 and 3.

In Example 4, HTML5 semantics require the <small> tag (and other formatting tags like <span>, <strike>, <em>, <i> (''foo''), etc.) to be wrapped around individual elements. But, a <div> tag can be wrapped around lists. But, this is a such a common usage on wikitext pages that we should probably treat this as special wikitext semantics and not expect editors to fix them up. We are flagging this here in case editors are wondering why it is showing up. We'll try to remove this output from Linter as we tweak it further.

In Example 5, much like previous examples, the output is invalid because that wikitext would expanded to <i><span>foo</i></span>. The <i> pair should be either inside or outside the span, e.g. <span>''foo''</span>.

Tools[edit]

The following tools can help fix misnested tags:

See also[edit]