I want to use Drupal with a limited range of HTML tags. Even though I include both the opening and closing paragraph tags in the list of allowed tags I find that when I add a story Drupal converts the closing para tag to two line break tags. Which file or files do I need to edit to stop this conversion taking place?

Thanks

K H Brown

Comments

al’s picture

You shouldn't include the closing tag in the list of allowed tags.
Just add <p> to it.

Anonymous’s picture

Thanks for the suggestion. I removed the closing p from the list of allowed tags, keeping the opening p in there, but it's still replacing the closing one with two br tags.

K H Brown

Anonymous’s picture

After changing function node_filter_line($text) in modules/node.module I've got it to do what I want, though I do find it odd that you can apparently put p into the list of allowed tags but then have it stripped out anyway regardless.

Just a minor criticism of an otherwise great piece of software. And hey, thanks to being open source I can at least change it to suit!

K H Brown

Anonymous’s picture

After changing the function check_output in includes/common.inc and the function box themes/marvin/marvin.theme I've now got the pages being output with pairs of para tags as I wanted.

Still trying to work out how to get the story to go into the database with the para tags intact, rather than with just newlines.

Thanks

K H Brown

al’s picture

Drupal shouldn't mess with <p> tags. It certainly doesn't on my box. Are you using 4.2rc? Or 4.1?

If I submit a node:
<p>This is a paragraph</p><p>And this is another one</p>

That markup remains intact in the final node.
Are you running any other filters other than the HTML tags one?
What have you had to change exactly to get it to work?

Anonymous’s picture

I'm running 4.1 and not running any filters other than the HTML one, as far as I know.

To stop the tags being stripped I commented out some lines in modules/node.module:

// $text = eregi_replace("<br>", "\n", $text); // this one is now <br>
// $text = eregi_replace("<br />", "\n", $text);
// $text = eregi_replace("<p>", "\n", $text);
// $text = eregi_replace("<p />", "\n", $text);
// $text = eregi_replace("</p>", "\n", $text); // remove orphaned tags

Lines 374 or thereabouts.

I also made some changes in includes/common.inc

function check_output($text, $nl2br = 0) {
// return ($text) ? ($nl2br ? str_replace("\r", "", str_replace("\n", "<br />", stripslashes($text))) : stripslashes$
// KHB: changed this
$text = preg_replace("/[\r\n]+/", "\n</p>\n<p>\n", $text);
return $text;
}

around line 425

I still need to do some more on it, perhaps doing something so that if someone uses p tags in their input it's assumed they know what they're doing and nothing is stripped, but if they don't use p tags and put in newlines, then they get replaced.

Thanks

K H Brown