Removing the forced <p> tags in MovableType posts?

John Gruber gruber at fedora.net
Wed Mar 24 19:17:23 EST 2004


jec44 at drexel.edu wrote on 03/24/04 at 2:09p:

> Basically, whenever you tell MT to use automatic formatting of any
> sort (including Markdown, unfortunately), MT will place <p> tags
> around every paragraph of text in your entry.
[...]
> I asked around for help and was pointed to the html_text_transform
> procedure in Util.pm -- within that proc are a few lines that read:
> 
>        if ($p !~ m/^<(?:table|ol|ul|pre|select|form|blockquote|div|q)/) {
>            $p =~ s!\r?\n!<br />\n!g;
>            $p = "<p>$p</p>";
>        }

You've been getting bad advice, but that's OK. Anyone who goes to
Drexel is OK in my book.

The code you've quoted above is `MT::Util::html_text_transform()`,
which is in fact MT's implementation of its "Convert Line Breaks"
filter. If you look in MT.pm, you'll see where it's set up as a
filter:

    sub init {
        my $mt = shift;
        my %param = @_;
    
        MT->add_text_filter(__default__ => {
            label => 'Convert Line Breaks',
            on_format => sub { MT::Util::html_text_transform($_[0]) },
        });

This code will only run if you select "Convert Line Breaks" for a
post. Conversely, it will never run for a post that uses Markdown.
Markdown places its own `<p>` tags.


> This is a bad thing for me, as I don't like the preceeding and
> concluding carriage returns that this leaves in my bog entries.

What are you talking about here? Blank lines in your resulting HTML
source code? Or something in the rendered appearance of your weblog
in a browser?

If it's something about the way the source code is formatted, can
you give an example of what you don't like, and what you'd like to
see Markdown do instead?

You're not suggesting that you want "paragraphs" which don't have
`<p>` tags, are you?


> I've tried numerous things things with this block of code and it
> seems to have no effect.  Even if I comment the whole thing out, the
> <p>'s are still printed around each paragraph.

My humble advice is that you probably shouldn't be commenting out
chunks of code with the MT application.

-J.G.


More information about the Markdown-discuss mailing list