Topic on Help talk:Extension:Linter

missing-end-tag : span tag around several lines ?

5
NicoV (talkcontribs)

Hi, how do we fix reports of missing end tag for span where the closing span tag is actually here but around several lines.

Main problem is with templates. For example, on frwiki, Linter reports this error for Baud (Morbihan) due to a call to template refnec which puts its first parameter inside a span tag : in this case, the first parameter is a multi lines text.

Similare situation happens for many errors reported.

Jdforrester (WMF) (talkcontribs)

If it's multi-line text (or any form of block content) then you should use a <div>, not a <span>. Block content inside a <span> is invalid HTML.

SSastry (WMF) (talkcontribs)

What James said there. But, yes, this gets trickier where templates and parameters are involved. This will get easier to handle once we start work in earnest with balanced templates. At that time, template authors can provide guidance to editors about contexts in which it can be used which then informs what kind of parameters are valid. Somewhat like a limited set of types (that are pertinent to the HTML context).

But, for the immediate term, don't have a good answer for you -- either let the error be (since the HTML does get "fixed up"), or change the page, or change the template based on how it is being used on pages. It is a low-priority issue for some of these reasons -- because, the wikitext and HTML5 parsers handle them correctly (i.e. as in respecting author's intent) in most (definitely not all) cases.

197.218.81.104 (talkcontribs)

The problem is actually caused by the spaces in that particular usage, this seems to be tricky and can only be fixed on a case by case basis, for example this small snippet:

{{refnec|Le nom [[breton]] de la commune est '''''Baod''''' (prononcé [bɔwt]).

''Baod'' serait le nom du fondateur de l'entité primitive. Cette possibilité se trouve étayée par le toponyme de quelques écarts comme ''Lenvaod'' (Lenvaud) ou ''Ker al Baod'' (Keralbaud).
}}

Becomes this:

<div class="mw-parser-output">
    <p>
        <span class="need_ref" style="cursor:help;" title="Ce passage nécessite une référence.">Le nom 
      <a href="/wiki/Breton" title="Breton">breton</a> de la commune est <i><b>Baod</b></i> (prononcé [bɔwt]).
    </p>
    <p>
        <i>Baod</i> serait le nom du fondateur de l'entité primitive. Cette possibilité se trouve étayée par le toponyme de quelques écarts comme <i>Lenvaod</i> (Lenvaud) ou <i>Ker al Baod</i> (Keralbaud).
        </span>
        <sup class="need_ref_tag" style="padding-left:2px;"><a href="/wiki/Aide:R%C3%A9f%C3%A9rence_n%C3%A9cessaire" title="Aide:Référence nécessaire">[réf.&#160;nécessaire]</a></sup>
    </p>
</div>

See Special:expandtemplates.

This is because an empty line break in wikitext is changed to "<p></p>", and that isn't allowed to be nested inside a span. The same would apply to any block type tag nested inside "phrasing content".

There are many ways to fix this, but this largely depends on what type of output one wants. Either change the template to emit a div or a paragraph, or make sure the template (through lua or something else) changes all empty newlines , e.g. "\n" to "<br>".

Most cases where this happens are caused by tags being misnested and eventually "missing end tags" as a result. In such cases the templates need to be cleaned up to avoid incorrectly nested html.

Using "Show raw HTML" in Special:Expandtemplates is a good way to find these.

Adding this to the linter itself (https://phabricator.wikimedia.org/T163149) should probably help future cases.

Whatamidoing (WMF) (talkcontribs)

I believe that the Listing templates at the Wikivoyages are having this problem, too. Most listings have only one line, but some have multi-paragraph descriptions.

Reply to "missing-end-tag : span tag around several lines ?"