WordPress.org

Ready to get started?Download WordPress

Forums

Dangling Paragraph Tag in Comments Fixed (5 posts)

  1. Ghidra99
    Member
    Posted 7 years ago #

    I've figured out where the bug is that creates the hanging </p> tag in the comments.

    If you go to line 65 of the functions-formatting.php, located at "wp-includes/functions-formatting.php" you'll see a line that reads:

    $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end

    This creates:

    <p>Hello, my name is Hal.</p>
    <p>You've found my blog.
    </p>

    The third \n (newline) is what is creating the problem. If you take it out, your final </p> tag will appear inline with your final sentence. It should read:

    $pee = preg_replace('/\n?(.+?)(?:\n\s*|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end

    The text will now appear as:

    <p>Hello, my name is Hal.</p>
    <p>You've found my blog.</p>

    For added styling, you can aline the final <p> with the rest of your markup by adding three (or however many you need) tabs (\t) after the final newline (\n) in line 65. It should look like this:

    $pee = preg_replace('/\n?(.+?)(?:\n\s*|\z)/s', "<p>$1</p>\n\t\t\t", $pee); // make paragraphs, including one at the end

  2. spencerp
    Member
    Posted 7 years ago #

    Thanks for sharing this! ;) Not sure if this has been "fixed" for the upcoming 2.0.5 release.. but, you can take a look here.

    If it hasn't been, you can search over there:
    http://trac.wordpress.org/search

    And find a related ticket.. login there, and add your suggestion with a link to this forum thread in your comment there..

    Or, join the wp-hackers or wp-testers email list, and submit an email through one of those mentioning it.. ;) =)

    spencerp

  3. Ghidra99
    Member
    Posted 7 years ago #

    There wasn't a ticket created for this problem, so I went ahead and created one.

    It's a rather minor problem so it shouldn't be too difficult to fix.

    Glad I could help! :D

  4. spencerp
    Member
    Posted 7 years ago #

    Awesome, thanks for doing this. ;)

    spencerp

  5. scrapeyard
    Member
    Posted 7 years ago #

    Thanks for the effort. I am myself trying to figure out something very similar to the one you mentioned.

    I am using WP-Polls. At one point WordPress is adding <p> and </p> which makes no sense.

    For example, the code

    <div class="AnserBox"><span id="pds-answer6">
    <ul class="wp-polls-ul">
    
    <li>
    <input class="PollRadio" type="radio" id="poll-answer-14" name="poll_6" value="14" /><label for="poll-answer-14">This question is not long enough</label></li>
    <li>
    <input class="PollRadio" type="radio" id="poll-answer-15" name="poll_6" value="15" /><label for="poll-answer-15">My be the answers are !</label></li>
    </ul>
    </span></div>
    
    <div class="PollBottom" >
    <div class="pds-vote">
    <div class="pds-votebutton-outer">
    <input type="submit" value="" name="vote" class="pds-votebutton" onclick="poll_vote(6); return false;" onkeypress="poll_result(6); return false;" /><a href="#ViewPollResults" title="View Results Of This Poll">View Results</a></div>

    Note the starting < p > tag and end < /p >

    <div class="AnserBox"><span id="pds-answer6">
    <ul class="wp-polls-ul">
    
    <li>
    <input class="PollRadio" type="radio" id="poll-answer-14" name="poll_6" value="14" /><label for="poll-answer-14">This question is not long enough</label></li>
    <li>
    <input class="PollRadio" type="radio" id="poll-answer-15" name="poll_6" value="15" /><label for="poll-answer-15">My be the answers are !</label></li>
    </ul>
    </span></div>
    
    <div class="PollBottom" >
    <div class="pds-vote">
    <div class="pds-votebutton-outer">
    <input type="submit" value="" name="vote" class="pds-votebutton" onclick="poll_vote(6); return false;" onkeypress="poll_result(6); return false;" /><a href="#ViewPollResults" title="View Results Of This Poll">View Results</a></div>

    [sig moderated]

Topic Closed

This topic has been closed to new replies.

About this Topic