Invalid HTML produced for glossary overview.

harking - April 24, 2008 - 18:25
Project:Glossary
Version:6.x-1.6
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

When viewing the default glossary/ page, invalid html is generated in the form of a

<dl>
    <a id="lettera"></a>
    <a id="term1"></a>
    <dt>Term Title</dt>
    <dd>Term description...</dd>
</dl>

According to the html spec, a tags can't go inside of dl elements. I suggest that the dl is moved into the letter sections and is replaces outside with a div with the same ids/classes. we can then leave one anchor tag in place (letter) and move the term anchor tag into the dt.

Something simiar to:

<div id="glossary-list">
    <a id="lettera"></a>
    <dl>
        <dt><a id="term1"></a>Term Title</dt>
        <dd>Term description...</dd>
    </dl>
</div>

#1

harking - April 24, 2008 - 22:31

I've attached a patch which performs the structure changes to make the document valid.

Needs testing as I'm not familiar with all of the glossary options/combinations. Works well on our setup.

AttachmentSize
glossary.module.dl-validation.patch 5.22 KB

#2

harking - April 24, 2008 - 22:42

Doh!

I forgot about the single glossary term pages, added dl wrappers for those too.

AttachmentSize
glossary.module.dl-validation.patch 5.31 KB

#3

NancyDru - April 25, 2008 - 11:00
Status:active» needs review

When you submit a patch, please set the status to "patch (code needs review)" and assign the issue to yourself.

According to the html spec, a tags can't go inside of dl elements.

Did you actually try a validation? Does it validate after this change? It would seem that there is not much difference with this patch and that validation would still have a problem.

#4

harking - April 25, 2008 - 16:16

Did you actually try a validation? Does it validate after this change?

Yes, I tested validation after the patch and it passed. Pages tested include the overview and the individual term. I also varied the different display options for the overview and it still validated.

Each change this patch made helps in validation. List of changes:

  • Convert outlying dl into div element for validation.
  • Create dl inside of new div element for validation.
  • Perform check_plain() on term title. HTML entities can appear here.
  • Move "term" anchor tag to inside of dt. This is where the term anchor should go since the dt is where the term title is.
  • Modify how edit/search links are created. Removes ul element since spec does not allow ul inside of dt

#5

NancyDru - April 25, 2008 - 18:17

Thanks.

#6

Andreas Wolf - April 26, 2008 - 22:46

I ran into the same validation issue and tried this patch.

1) I can confirm that the view of Glossary Terms validates as XHTML 1.0 strict.

2) The glossary overview is broken for me, but this is another bug unrelated to this patch, as I found out. I'm going to submit a patch right after this.
After resolving my overview issue, the overview validates as XHTML 1.0 strict, too.

I don't set the status of this issue to reviewed, because of my problems with the overview.

#7

NancyDru - April 28, 2008 - 14:04

Some follow up questions for you guys:
1. Term synonyms are treated as though they are the terms themselves, so should we change the "synonyms: abc, def..." to additional <dt> tags?
2. Should we consider something similar with related terms and move them into additional <dd> tags?

Also, some confusion on your mention of "ul" within "dl":
According to the W3C recommendations:

Definition lists vary only slightly from other types of lists in that list items consist of two parts: a term and a description. The term is given by the DT element and is restricted to inline content. The description is given with a DD element that contains block-level content.

"Block-level content" may be a nested list. Indeed the examples on the above page show an unordered list within a definition list.

#8

NancyDru - April 28, 2008 - 14:25

Perform check_plain() on term title. HTML entities can appear here.

Is this necessary? That was in there before and I changed it so that HTML could be used and so that HTML entities would display correctly.

#9

NancyDru - April 28, 2008 - 16:45

I applied the patch, but it is not producing the <dl> or </dl> elements on the overview.

Also, you are clearly not using Taxonomy Image or the "Show detailed descriptions on the Glossary page" option. They introduce even more validation problems.

#10

NancyDru - April 28, 2008 - 18:38

It's always nice to fight a core issue while you're trying to fix one of your own. http://drupal.org/node/252277

#11

NancyDru - April 28, 2008 - 23:42
Assigned to:Anonymous» NancyDru

I have just committed the fix to -dev on both branches. Please test and let me know how it goes. Also there are some questions above.

#12

NancyDru - April 28, 2008 - 23:43
Status:needs review» reviewed & tested by the community

#13

harking - April 28, 2008 - 23:57

Perform check_plain() on term title. HTML entities can appear here.

Is this necessary? That was in there before and I changed it so that HTML could be used and so that HTML entities would display correctly.

I think it is necessary. The way I tested it was to place an & in my term name. When the term was rendered to the glossary and I validated it, the validation complained that the & was not converted to an HTML entity. I added the check_plain() and it took care of it.

There might be a different function that should have been used?

#14

NancyDru - April 29, 2008 - 00:18

The problem is that check_plain will make HTML entities display as text. For example, &eacute; will display exactly that way rather than as é. There is another issue already open about this.

#15

NancyDru - May 5, 2008 - 16:37
Status:reviewed & tested by the community» fixed

My output validates even without check_plain. Typing just an ampersand is not good practice.

#16

Anonymous (not verified) - May 19, 2008 - 16:44
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

#17

askibinski - April 14, 2009 - 08:36
Version:5.x-2.2» 6.x-1.6
Assigned to:NancyDru» Anonymous
Status:closed» active

I found this issue for the 5.x version but the Drupal 6 version also generates errors, so I reopened it for 6.

Most of them are:

document type does not allow element "dt" here; assuming missing "dl" start-tag
and
end tag for "dd" omitted, but OMITTAG NO was specified

You can view a W3C validation example here. (1 letter overview with 6 errors)

 
 

Drupal is a registered trademark of Dries Buytaert.