In a setup where codefilter processes before linebreak filter, if linebreak filter finds multiple newlines, it inserts a <p> tag (nested inside the <code> tags), causing a discontinuation in style (because <p> tag might have it's own styling).
For example
#include <stdio.h>
<!--if this line is blank, linebreak will add a <p> here-->
int main(void)
{
printf("Hello world!");
return 0;
}
We don't want linebreak to insert anything inside the <code> tags. And we don't want to put linebreak before codefilter because of the invalid XHTML problem.
I'm suggesting a fix. Patch attached (see comment in patch).
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | screen-shot-spacing-problem.png | 18.77 KB | geerlingguy |
| newline_edit.patch | 614 bytes | webkid |
Comments
Comment #1
geerlingguy commentedI'm having the same problem on a bunch of my sites; when I have code, then a blank line, then more code, a pair of
<p> </p>tags is inserted where the blank line was because of the 'Convert line breaks into HTML (i.e. <br> and <p>)' filter.I tried simply applying the patch to the Drupal 7 version, and also changing the code in
codefilter_process_php(), but that didn't work for me. It seems that the newlines are being changed elsewhere.Here's a sample of code (as it looks on Drupal.org), with a screenshot of how it looks with the current D7 release attached:
(Go figure, everything looks normal on drupal.org...).
Comment #2
geerlingguy commentedForgot to attach screenshot with spacing issues...
Comment #3
geerlingguy commentedWell, after a bit more experimentation (after seeing that Drupal.org's filter order is different than mine), I found that if I put the Code Filter filter last, after both the HTML cleanup and the Convert linebreaks filters, everything looks correct. Maybe we can mark this issue fixed?
This could definitely use more documentation (the current project page documentation link goes to a CVS file viewer, which doesn't work anymore). Opened #1488276: Update project page Documentation link for that...
Comment #4
cameron tod commentedThis is covered in the handbook page as mentioned in #3, but feel free to clarify any documentation over there or reopen this if you think that the present docs are inadequate.