Filter module Line Break convertor adds
tag around an
element.
This can be fixed by modifying the filter.module file. The function to be modified is
_filter_autop, and the fix is to add
iframe to the
$block regular expression so that the filter regards iframes as block-level elements, which is their primary use.
Original code snippet:
function _filter_autop($text) {
// All block level tags
$block = '(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|p|h[1-6]|hr)';
Patched code snippet:
function _filter_autop($text) {
// All block level tags
$block = '(?:iframe|table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|p|h[1-6]|hr)';
A sophisticated fix would be to include configuration settings for the filter module to change behavior for the elements used as either inline / block-level elements, like listed in
http://htmlhelp.com/reference/html40/block.html -page list on the bottom of the page.
Comments
Comment #1
mongeron commentedThe first few lines should read:
Filter module Line Break convertor adds "p" tag around an "iframe" element.
Comment #2
sunComment #3
dfletcher commentedAccording to the unit tests, iframe should not be a block element but rather one of the elements that is ignored entirely, a few lines below the $block = line pointed out by mongeron.
I think the "sophisticated fix" mentioned in OP should be a separate feature request, and this bug should be closed with the simpler solution in the patch.
Comment #4
sunExceeds 80 chars.
Let's remove the outer, irrelevant markup and only test the actual IFRAME tag and its direct siblings.
A second, positive assertion to verify that we're not adding paragraphs to the inner HTML of the IFRAME would be good to add.
Powered by Dreditor.
Comment #5
dfletcher commentedComments fixed. Some lines below my change were also > 80, so I reformatted the whole paragraph.
Test simplified:
Sun: There already a positive assertion test, line 819 of filter.test. It accidentally does not get triggered because of http://drupal.org/node/1054632 , which I discovered while working on that bug.
Comment #6
damien tournoud commentedThis is now handled in #1063178: Line break filter will ignore everything following a <pre>xxx</pre>.