Wikipedia:Manual of Style/Glossaries/DD bug test cases
Test cases and explanation of the definition list definition (<dd>) bug.
Overview
Due to MediaWiki's very brittle handling of HTML list structures generally (in particular their inability to handle multiple paragraphs except under a very specific circumstance, outlined below), the ;
and :
wikimarkup features cannot be used to produce any but simplistic and easily broken definition lists, unlike real HTML. Some of the interrelated bug reports include: 1584 (unresolved as of September 2014[update]), 5178 (unresolved as of September 2014[update]),6200, etc.
The main problem is detailed below, but there are also other problems with the wikimarkup version of definition lists. Bug reports include: 6776, 11894, and many others.
It is unlikely that all these problems will be fixed any time within the next several years, especially as they are seen as "features" by some, especially the termination of a list item by a line break. (See detailed comments in the bug reports for more information.)
Examination of the main problem
In ;
and :
markup, if a single definition uses multiple paragraphs, it is necessary to specify the paragraphs explicitly with a <p>
or the full <p>...</p>
paragraph markup. We cannot rationally just create a second definition line for a second paragraph, as this indicates two separate definitions, not a multi-paragraph definition, and doing this causes all sorts of problems.
Due to bugs in (or alleged features of) the MediaWiki software (see above), the paragraphs must not be separated by a newline either inside or outside of the paragraph, in wikimarkup-based list items such as definitions:
;term 1
:<p>Part of definition of term 1.</p><p>More of definition of term 1.</p>
and it is highly unlikely that any regularly edited text would retain such precious formatting for long before someone broke it. The same holds true of the use (again without linebreaks) of <br /><br />
, as suggested (along with <p>...</p>
) at Help:List, which leads to accessibility problems anyway: text visually broken with simply <br />
line breaks this way will not be treated as separate paragraphs by screen readers.
To be clear, this example does not work:
;term 1
:<p>
Part of the definition of term 1.
</p><p>
More of definition of term 1.
</p>
and neither does this one:
;term 1
:<p>Part of definition of term 1.</p>
<p>More of definition of term 1.</p>
nor anything like them (see test cases below).
For the same reason, if a :
-initiated definition requires an indented segment, one has to use use <blockquote>...</blockquote>
around it to get valid code as a the result, and must butt those tags against any preceding or following paragraph tags in the same definition. Help:List's suggestion to use :
as an indentor produces invalid markup. While this is not an enormous concern with a quick-and-dirty wikimarkup lists, it would be a major problem for structured glossaries.
|
|
The rendered output of this looks correct to the sighted human reader, but in reality, the MediWiki parser has made the block quotation into an entire new definition list (glossary)! Wikimarkup definition list structures cannot be mixed with structured markup.
The brittle list handling bug/feature is quite general, and also affects ordered (#
) and (*
) unordered lists.
From the perspective of non-technical editors, simple tricks can be used to make the code more readable for some editors. One such kluge is to put linebreaks between definitions, as already illustrated, giving the false appearance of a well-spaced list, when in reality MediaWiki creates a whole slew of pointless micro-lists, ruining the semantic value of bothering to use definition list markup in the first place. Another is to code a multi-paragraph definition as multiple definitions, but write the prose as if it were a single definition in two paragraphs, as already illustrated. And as already noted this just blatantly falsifies the code, resulting in pretty-looking but technically awful output.
Such hacks will lead to confusing Wikipedia code (that other editors are likely to correct anyway), redundant MediaWiki output, and blatantly invalid XHTML, among other problems, resulting in accessibility and usability issues.
To repeat: It just doesn't work, due to MediaWiki bugs/features, but there is an easy solution as show below.
NB: Replacing :
with a real <dd>...</dd>
structure has no effect if ;
is used, or vice-versa with <dt>...</dt>
and :
. The entire structure must be entirely [X]HTML in order to function properly. Which brings us to...
Workaround
The workaround, as illustrated below, is to abandon ;
and :
entirely for any case in which one intends to produce rich definition lists, including glossaries, and instead use pure XHTML markup: <dl>/<dt>/<dd>
. And there is no reason to use HTML manually to produce a glossary when the easy-to-use structured glossary templates will do this for you, and do it consistently with other glossary articles. For non-structured glossaries, use bullet lists or use subheadings and plain-text entries, as recommended at WP:Manual of Style (glossaries).
Test cases
|
This is more of the definition of term 1. Failure: Definitions not indented. |
|
This is more of the definition of term 2. Failure: Only one definition indented. |
|
Failure: Definitions not indented. |
|
Failure: Definitions not indented. |
|
Failure: Definitions not indented. |
|
Failure: Definitions not indented. |
|
Failure: Definition not indented. |
|
Failure: Definition not indented. |
|
Poor: Indentation is typical WP style for this markup, but undesirable for proper use of the tags to create a glossary. |
|
Failure: Definitions not indented. |
|
Poor: Indentation gone, but requiring |
|
Success: Perfect, and supports |
|
This is more of the definition of term 13. Failure: Only one definitions indented. |
|
Failure: Lack of auto-markup of paragraphs. This used to work perfectly, because MediaWiki would auto-generate paragraph markup for plain text entered on isolated lines, even inside a |
|
Successlure: Perfect, even with a two-fold coding error (missing |
Developer views
In the process of working on the now-closed MediWiki bug report 1584:
"Real HTML <li>[...]</li> tags are very rarely used, and then only by HTML-savvy editors who want to apply a class or style attribute, or by editors who cut-and-paste some existing HTML code. Since block or inline content is allowed in list items, this would be the way to allow correct and more complex formatting of the contents of list items, but at the cost of complex and unusual markup in the edit field, incompatible with wikitext lists."