WordPress.org

Forums

[resolved] <code>-tag not functioning properly? (4 posts)

  1. chartinael
    Member
    Posted 5 years ago #

    Hi guys,

    I have a draft post where I store all the wp body edits I had to make in order for wordpress to do what I need it to do.

    I enter location and code to be changed.

    The code I put between the code-tag but somehow it does get parsed.

    so i.e. I end up with

    Line xyz
    <code>
    $pee = preg_replace('/<p>\s*?(' . get_shortcode_regex() . ')\s*< \/p>/s', '$1', $pee); // don't auto-p wrap shortcodes that stand alone
    </p></code>

    where the </p> was added by wordpress' tag closing feature. And thus it displays on preview an nicely added paragraph so I know that the code inside the code-tags does get parsed.

    or at another place it closes a <code>-tag even though there are no open code-tags at all.

    Anyhow, is this a bug? is there anywhere I can look and adjust code to make it work?

  2. esmi
    Forum Moderator
    Posted 5 years ago #

    The <code></code> tags are just markup. They don't escape your code or stop it being parsed. You need to encode all opening < and closing > tags to stop it being parsed.

    Additionally the <code></code> are inline markup elements which means that they should be enclosed in a block-level element such as <p></p>, <div></div> or <pre></pre>. So WP is acting correctly in this instance. Personally, I enclose blocks of pre-encoded scripting for display inside <pre><code></code></pre> tags and WP doesn't interfere at all.

  3. chartinael
    Member
    Posted 5 years ago #

    so how does this code tag here in the forum function? Cause it does what I thought the code button in the wp editor ought to be doing?

  4. chartinael
    Member
    Posted 5 years ago #

    http://www.thunderguy.com/semicolon/wordpress/code-markup-wordpress-plugin/

    This plugin does the job and assigns the <code>-tag with the appropriate functionality.

Topic Closed

This topic has been closed to new replies.

About this Topic