version info: codefilter.module,v 1.10.2.2 2005/04/23 02:40:04
Because the text in comments are being outputed with HTML tags around it my web pages with the PHP code blocks were not validating as XHTML Transitional. The codefilter div tags were being returned surrounded by p tags, which the W3C validator doesn't like.
I was able to workaround this by changing the div tags on lines 47 and 82 of the codefilter.module (PHP related outputs) to span tags and then modifying the CSS to turn the span into block elements. Here's what the changed lines look like now:
47: return '<span class="codeblock">'. highlight_string("<?php\n$text\n?>", 1) .'</span>';
82: if ($multiline) $text = '<span class="codeblock">'. $text .'</span>';
Then I changed the div to span and added display:block; in the CSS:
span.codeblock {
display: block;
padding: 15px;
border: 1px solid #CCC;
background-color: #EEE;
}
The page validated after this and I haven't noticed any other adverse affects.
Hope this helps.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | line_break.patch | 1.15 KB | Island Usurper |
Comments
Comment #1
deekayen commented-1, span breaks my code blocks in firefox, but I did verify the sequence
<p><div class...does not validate.Comment #2
Stuart Greenfield commentedI found this too, with codefilter.module,v 1.10.2.5 2006/03/28 02:42:55. To work around I added these two lines after line 111
So it strips the offending
and
before returning the string. Not very elegant but code then passes validation.
Comment #3
Stuart Greenfield commentedThat didn't look quite right!
Comment #4
deekayen commentedThat still doesn't look right. Could you put it in a txt file and attach it?
Comment #5
johnalbinThe code has changed since this issue was last updated. Does this problem still exist?
Comment #6
wim leersI can confirm that the problem still exists. Example: http://wimleers.com/blog/textmate-command-look-functions-api.drupal.org.
Comment #7
wim leersComment #8
wim leersOk this is not a bug.
In your input format, you have to move the code filter *before* the line break converter, if you're using it. People who don't use the line break converter in their input format(s), should not experience this issue.
Comment #9
johnalbinI’ve added this to the INSTALL.txt doc. Thanks for finding the fix!
Comment #10
johnalbinFYI, I just added an issue about the input filtering order on d.o.
http://drupal.org/node/198179
Comment #11
wim leersWow, I wasn't aware this problem existed here on Drupal.org as well! :D Nice catch :)
Comment #12
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #13
johnalbinI’ve been playing around with input ordering until my eyes bug out. Any ordering dependency that we can get rid of is a good thing.
If codefilter wraps its code blocks in its own
<p>tags during the 'prepare' stage of input filtering, than Line Break Converter won't wrap one around it. Then we can strip the<p>off during 'process'.Comment #14
Island Usurper commentedI had a hard time getting that to work until I remembered the line breaks just inside the
<p>tags.I can confirm that enabling Code filter on a format automatically puts it at weight 10, so this should help keep people's content up to standards.
Comment #15
avpadernoIf the module surrounds the code with
<div>tags, then you cannot put<p>tags around that.Comment #16
Island Usurper commentedTrue, but like John suggested, it's taking out the
<p>tags in the process step with the preg_replace().Comment #17
cameron tod commentedClosing as part of issue queue cleanup. Feel free to reopen.