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>

Comments

harking’s picture

StatusFileSize
new5.22 KB

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.

harking’s picture

StatusFileSize
new5.31 KB

Doh!

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

nancydru’s picture

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.

harking’s picture

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
nancydru’s picture

Thanks.

Andreas Wolf’s picture

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.

nancydru’s picture

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.

nancydru’s picture

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.

nancydru’s picture

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.

nancydru’s picture

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

nancydru’s picture

Assigned: Unassigned » 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.

nancydru’s picture

Status: Needs review » Reviewed & tested by the community
harking’s picture

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?

nancydru’s picture

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.

nancydru’s picture

Status: Reviewed & tested by the community » Fixed

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

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

askibinski’s picture

Version: 5.x-2.2 » 6.x-1.6
Assigned: nancydru » Unassigned
Status: Closed (fixed) » 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

AaronCollier’s picture

I use 6.1.6 and I think the problem is that the patch above wasn't applied to 6 - the a elements are what are causing many of your errors.

Here's an example of what I get:

<dl>

<a id="lettera"></a>

<div class="glossary-letter">a</div>

<dt class="depth0"><a id="term34"></a>Ex<a href="..." class="glossary-search-term" title="search for content using this term">search for term</a></dt>

<dd class="depth0"><p>Example</p>

The a and div elements before the dt element don't work. I also don't see a closing dd tag, which creates more problems.

I'd suggest removing the empty a elements anyway, and just using ids for the dts.

If I knew much about creating patches, I'd do so now.

phiscock’s picture

I am also having this problem with version 6.x1.6 which is stopping my page from validating. I have analysed the code to help clarify the problem, but as a Drupal newbie I am not up to writing a patch yet.

The following code is generated on the glossary page:

<div class="glossary-list"><dl>
<a id="letterd"></a><dt class="depth0"><a id="term29"></a>Drupal <a href="/admin/content/taxonomy/edit/term/29?destination=glossary%2F2" class="glossary-edit-term" title="edit this term and definition">edit term</a><a href="/search/node/%22Drupal%22" class="glossary-search-term" title="search for content using this term">search for term</a></dt><dd class="depth0"> <a class="glossary-term" href="/glossary/2#term29">Drupal</a> is a content management system <span class="glossary-related">See also: <a href="/glossary/2#term28" class="active">Content Management System</a></span><div class="glossary-detailed-link"><a href="/taxonomy/term/29">Detailed definition of Drupal</a></div>
</dl></dl></div>

As far as I can see there are three small errors:

  • The a tag at the beginning of each entry needs to be removed or moved inside the dt tag
  • A dd tag needs to be added to the end of each entry
  • There is an extra closing dl tag at the end of the block that needs to be removed

There is an extra problem if you enable the Separate Letters option as it adds in an extra div e.g. <div class="glossary-letter">d</div> before the dt element which is also not allowed.

A solution would be greatly appreciated as due to the constraints on my current project if the module is not producing valid xhtml markup then I will not be able to use it, which would be a pain and a great pity when all the other aspects seem to be working fine.

BarisW’s picture

Check out http://drupal.org/project/lexicon which comes with valid HTML and more sweetness!

jessebeach’s picture

StatusFileSize
new947 bytes

@harking re:#2

I'm attaching a small patch to address the missing closing tag for the <dd> element. I didn't see that in your patch. Otherwise it looked good.

daniel wentsch’s picture

@jessebeach thanks, your patch reduced my validation errors from more than 40 to 19 on version 6.x-1.6.

The first patches (#1 and #2) can't be applied for 6.x-1.6, is there any chance those changes can be found in the dev versions?

nancydru’s picture

Issue summary: View changes
Status: Active » Closed (outdated)