WordPress.org

Ready to get started?Download WordPress

Forums

Formatting when only a shortcode on the line (7 posts)

  1. WoD
    Member
    Posted 4 years ago #

    I ran into a strange problem (or bug).
    Say you type a post, with a couple of linebreaks in it. WP will automaticly convert them to paragraps by putting <p> and </p> on it.

    Let's take the following text for example:

    "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

    Ut enim ad minim veniam.

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."

    The line "Ut enim ad minim veniam." would have a beginning and ending P tag in HTML code.

    If whe put a shortcode on th same line, it would also be in the P tags.
    But, if you replace the complete line with a shortcode, it will not get the P tags:

    "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

    [some_shortcode]

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."

    This is breaking up formatting.
    When you put only one single character (a space for example) as the first character in the lin, formatting will be OK.
    However I can't allways put a extra character in fornt of tehe shortcode.

    Is this a bug, am I missing some clue or what?

  2. s_ha_dum
    Member
    Posted 4 years ago #

    So, do you want WP to wrap the shortcode in paragraph tags? I can imagine a number of circumstances in which that could be problematic. It seem like things are working the way they should. Your shortcode needs to do whatever formatting it needs.

  3. WoD
    Member
    Posted 4 years ago #

    No, that's not what I mean.
    Perhaps I didn;t explain it well. I found the following topic wich is explaining the same problem in much lesser words ;)

    http://wordpress.org/support/topic/193625

  4. s_ha_dum
    Member
    Posted 4 years ago #

    It still sounds like you want WP to wrap shortcodes in paragraph tags, or at least do so when the shortcode appears by itself on a line. After all, its the paragraph tags that keep the post from 'collapsing'. Again, that might work for some shortcodes but it would make a mess of others. And again, the shortcode needs to do its own formatting.

  5. WoD
    Member
    Posted 4 years ago #

    No, that is not what I mean.
    When I replace the shortcode with a single word, the tags are placed (because I did a enter in the visual editor).
    If I just place one empty space before the shortcode, it also works as wanted in the visual editor.

    So yes: I want to wrap it in paragraph tags, but I 'place' them in the editor - just like I would with normale tekst.
    The shortcode function just wouldn't know if it needs to put the tags around it, but the WP core should know that.
    There should be now difference between shortcode text or normal text.

  6. s_ha_dum
    Member
    Posted 4 years ago #

    But there is a big difference between shortcodes and 'normal' text. Shortcodes get replaced by all kinds of things. It is a mistake to treat them like 'just any other text'.

    Let's say that WP adds paragraph tags around shortcodes when the shortcode appears on a line all by itself. If your shortcode inserts the word 'dog' there is no problem. What if the shortcode replaces the word 'cat' with a picture of a cat? Maybe you want your image inside paragraph tags, maybe you don't. What if the shortcode inserts a table? Then you get this, which is invalid:

    <p>
    	<table>
    		<tr>
    			<td>hi</td>
    		</tr>
    	</table>
    </p>

    Try it yourself.

  7. ccasselman
    Member
    Posted 3 years ago #

    This is haunting me as well. Was there ever a solution / work around?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags