W3C validation - H3 or PRE tags in paragraphs

tinou - January 5, 2008 - 15:49
Project:Bbcode
Version:5.x-1.x-dev
Component:Markup
Category:bug report
Priority:minor
Assigned:tinou
Status:postponed
Description

Some BBCode markup generates HTML that doesn't pass the W3C validator. I've only realized it for [h3] at the moment.

The post is a blog entry on a fresh Drupal-5.5 with only BBCode as an additional module, and is displayed with the default theme. The only BBCode markup used consists of [url], [img], and [h3]. All errors reported by the Validator are of the form:

Line XX, Column YY: document type does not allow element "h3" here; missing one of "object", "ins", "del", "map", "button" start-tag.

<p><a name="MyH3Heading"><h3>MyH3Heading</h3></a><br />

The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.
One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").

#1

tinou - January 5, 2008 - 15:51

Sorry, I forgot to mention that the [h3] markup is not nested in any other markup in the post content.

#2

naudefj - January 13, 2008 - 05:13
Title:W3C validation» W3C validation - H3 tags in paragraphs
Priority:normal» minor
Status:active» postponed

This happens because you've set "Smart paragraph and line breaks:" to "Line and paragraph breaks". This mode is known to produce non-compliant HTML. Use one of the following two workarounds:

1) Disable "BBCode Line Break converter" in the settings page and use another module for it.
2) Set "BBCode Line Break converter" to "Line breaks only".

A patch will obviously also be welcome!

#3

naudefj - January 13, 2008 - 04:03
Title:W3C validation - H3 tags in paragraphs» W3C validation - H3 or PRE tags in paragraphs

The same problem occurs with [CODE] tags - same workarounds apply.

For example: the following BBCode renders a in a

:

The code
[code]
code line 1
code line 2
[/code]
is an example...

For details, see http://drupal.org/node/107373

#4

tinou - January 27, 2008 - 13:55

I don't think this is really the point here. I've tried your workarounds, but it didn't change anything.

What the validator is complaining about is the <h3> tags being inside the <a> tags. I tried to copy the output of Drupal into the validator and changed a couple of <h3> so they stand outside the <a> tags, and the errors disappeared.

#5

naudefj - January 27, 2008 - 14:33

Well, the fact is that this is a known problem. As I personally do not care, I will unfortunately not fix it. However, as always, patches are more than welcome.

#6

tinou - January 27, 2008 - 15:29
Assigned to:Anonymous» tinou
Status:postponed» patch (code needs review)

Ok, here's my first patch. It's only about XHTML-compliant headings, not about making the whole BBCode XHTML compliant. Its' only been tested on one article so far. Please test and post results.

AttachmentSize
heading_xhtml_compliant.patch577 bytes

#7

naudefj - January 27, 2008 - 16:51
Status:patch (code needs review)» postponed

Patch applied - see http://drupal.org/cvs?commit=97785

More patches are required, so I will set the status back to "postponed".

 
 

Drupal is a registered trademark of Dries Buytaert.