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>").

CommentFileSizeAuthor
#6 heading_xhtml_compliant.patch577 bytestinou

Comments

tinou’s picture

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

naudefj’s picture

Title: W3C validation - H3 or PRE tags in paragraphs » W3C validation - H3 tags in paragraphs

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!

naudefj’s picture

Title: W3C validation » W3C validation - H3 or PRE tags in paragraphs
Priority: Normal » Minor
Status: Active » Postponed

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

tinou’s picture

Title: W3C validation - H3 tags in paragraphs » W3C validation - H3 or PRE tags in paragraphs

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.

naudefj’s picture

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.

tinou’s picture

Assigned: Unassigned » tinou
Status: Postponed » Needs review
StatusFileSize
new577 bytes

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.

naudefj’s picture

Status: 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".

naudefj’s picture

Status: Postponed » Closed (fixed)