Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Updated: Comment #N
Problem/Motivation
blanks lines are part of our coding standards. examples are having those blank lines (newlines) stripped out.
Examples:
https://drupal.org/node/1353118
https://drupal.org/node/2122241
Proposed resolution
Fix filters?
Remaining tasks
Remaining tasks
- Test patch in #14 on Drupal.org development site
- Make sure your public SSH key is uploaded to your Drupal.org user account (Instructions) and then ask for your public key to be manually added to the devwww server.
- Ping drumm, basic or tvn in #drupal-infrastructure IRC channel to get your key added faster
- SSH to dev server, go to https://sprint6-drupal.redesign.devdrupal.org/ development site. Change password for your user account via drush. See instructions how to work on dev sites
- Apply patch from #14 to the Code Filter module on the dev site. Clear cache.
- Test if the problem still exists on the dev site (e.g. at https://sprint6-drupal.redesign.devdrupal.org or https://sprint6-drupal.redesign.devdrupal.org/node/2122241)
- Report results of your testing in this issue.
User interface changes
No.
API changes
No.
Comment | File | Size | Author |
---|---|---|---|
#22 | codefilter.code-blanks.22.patch | 3.01 KB | sun |
#21 | codefilter.code-blanks.patch | 2.91 KB | sun |
#14 | interdiff.txt | 3.83 KB | marvil07 |
#14 | 0001-Issue-2134969-Keep-new-lines-on-php-blocks.patch | 4.31 KB | marvil07 |
#11 | Screenshot 2014-04-25 09.58.17.png | 28.46 KB | kalman.hosszu |
Comments
Comment #1
tvn CreditAttribution: tvn commentedComment #2
mgiffordI noticed this too.
Was rather annoying to me.
Comment #3
jhodgdonIsn't this probably a Core bug with the text filter, rather than a Drupal.org-specific issue? Or maybe it's the order of text filters in the d.o "Filtered HTML" text format?
Comment #4
mgiffordI think we'd have found it if it before was a core bug. Mind you the order of the filters is quite likely...
Comment #5
danylevskyiCode Filter module removes leading and trailing line breaks. I think we should remove this functionality and let user decide to remove or leave line breaks.
Comment #6
tvn CreditAttribution: tvn commentedComment #7
tvn CreditAttribution: tvn commentedComment #8
jhodgdonRE #5 - the problem here is not the first/last newlines being stripped out. It is that blank lines in the middle of code blocks are stripped out.
Comment #9
danylevskyiYeah. We have a real problem. Code Filter removes blank lines in order to avoid clashes with line break filter which converts them to html tags...
Comment #10
dokumori CreditAttribution: dokumori commentedThe filter 'Convert line breaks into HTML' needs to come after 'Code filter' to fix this issue.
Comment #11
kalman.hosszu CreditAttribution: kalman.hosszu commented@dokumori I tested it with your solution but it didn't fix the problem. The blank line between other lines was removed. I tied it here: https://kalman-drupal.redesign.devdrupal.org/node/2234363/
Comment #12
marvil07 CreditAttribution: marvil07 commentedThe cleanest way I found to make this happen is to add extra markup.
After reading the drupal core filter which does the replacement of new lines(see
_filter_autop()
), which is causing the problem, I also see that it is skipping the pre tag contents.That makes sense, so if we wrap the return text with the pre tag, drupal core will not try to replace newlines inside.
That's actually what pre(formatted) tag means, so it sounds consistent.
In the drupal.org specific case:
Comment #14
marvil07 CreditAttribution: marvil07 commentedFixing text in the test to match new output, also includes a new line there so this behavior is tested too(maybe we need to add one more when core filter is also there).
Comment #15
tvn CreditAttribution: tvn commentedTag and testing instructions.
Comment #16
drummI think the same change should be made in
codefilter_process_code()
for blocks like in comment #2.Comment #17
Cameron Tod CreditAttribution: Cameron Tod commentedI think it is looking ok without an additional change in
codefilter_process_code()
:Comment #19
Cameron Tod CreditAttribution: Cameron Tod commentedSetting to fixed - let me know if there is more to do here.
Comment #20
markhalliwellComment #21
sunNot sure why #17 performed a manual test instead of adding an automated test...?
Comment #22
sunRe-rolled against HEAD.
Comment #23
sunThis follow-up patch just adds an automated test for the manual test performed in #17.
Comment #24
Cameron Tod CreditAttribution: Cameron Tod commentedThis actually got commited, with the wrong commit message. Thanks sun!
Comment #25
sunThe cumulative change needs to be forward-ported to D8.
Comment #26
tvn CreditAttribution: tvn commentedComment #27
tvn CreditAttribution: tvn commentedComment #28
YesCT CreditAttribution: YesCT commented