• wpautop recognizes shortcode syntax and will attempt not to wrap p or br tags around shortcodes that stand alone on a line by themselves.
    http://codex.wordpress.org/Shortcode_API#Output

    Actually, if a shortcode begins a paragraph, it doesn’t get a p tag.

    This annoys me greatly. I get extra p tags when they’re inappropriate, and no p tags when they’re necessary.

    In the case of the former, I solve it with preg_replace.

    Here is an example of the latter:

    [highlight]For more information, please contact Justin Case at 800-555-0505.[/highlight]

    [highlight] wraps the content in a span tag. When this begins a paragraph, it does not get wrapped in a p tag.

    As far as I can tell, there is no way for a shortcode to know that it starts a paragraph so I can have it add its own p tag.

    At present, not having p tags is a cosmetic problem only. My ugly solution? span + p {margin-top: .5em;}

    The desired behavior would be to apply wpautop as normal when the shortcode produces inline elements, and not to apply tags when the shortcode produces block-level elements.

    I’m not sure I have the chops to try my hand at rewriting the processor. To someone who knows about such things: Does this sound like a good idea, or is there some reason we wouldn’t want to correct…err…modify the current behavior?

    After writing the above, I found this issue: http://core.trac.wordpress.org/ticket/12061. OMG this is so necessary. It would be trivial and quite desireable for shortcode authors to specify, yes, run autop on my shortcode or no, don’t you dare touch it, i’ll do it myself! 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wpautop shortcode handling – inline vs block elements’ is closed to new replies.