• Resolved redcore

    (@redcore)


    Posting a code blog has always seemed to be somewhat of a difficult thing to do (many blogs don’t support syntax highlighting, for one). I like WP and I have SyntaxHighlighter Plus installed and thought everything was going pretty well on my first blog post. Unfortunately, upon the first draft save all of the code formatting was converted by WP. Normally this is fine, but not for code snippets.

    Before saving the draft: https://shinytype.com/images/code-good.jpg
    After saving the draft: https://shinytype.com/images/code-bad.jpg
    (note that I do not use the visual editor)

    Am I missing something?

    Here’s how that blog of code looks like in the HTML editor:
    [PHP]<?php
    $server = ""; // aka "localhost" or "69.249.73.42"
    $username = ""; // aka "ChuckNorris"
    $password = ""; // aka "Eatsnails4_breakfast"
    $database = ""; // where you want your new table to go

    mysql_connect($server, $username, $password) or die(mysql_error());
    mysql_select_db($database) or die(mysql_error());
    ?>[/PHP]

    I’d be totally bummed if I have to build a blog by hand to make this work, so I hope it’s just something I’m not quite attune to quite yet. Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator James Huff

    (@macmanx)

    Try this instead (from the HTML editor):

    <code><?php
    $server	 = "";	// aka "localhost" or "69.249.73.42"
    $username	= "";	// aka "ChuckNorris"
    $password	= "";	// aka "Eatsnails4_breakfast"
    $database	= "";	// where you want your new table to go
    
    mysql_connect($server, $username, $password) or die(mysql_error());
    mysql_select_db($database) or die(mysql_error());
    ?></code>
    Thread Starter redcore

    (@redcore)

    It cuts off the opening PHP tag, ends up looking like this:

    $server	 = "";	// aka "localhost" or "69.249.73.42"
    $username	= "";	// aka "ChuckNorris"
    $password	= "";	// aka "Eatsnails4_breakfast"
    $database	= "";	// where you want your new table to go
    mysql_connect($server, $username, $password) or die(mysql_error());
    mysql_select_db($database) or die(mysql_error());
    ?>

    Also, syntax highlighting doesn’t work with code blocks.

    Thread Starter redcore

    (@redcore)

    Switched to SyntaxHighlighter Evolved and the problem is solved

    https://www.ads-software.com/extend/plugins/syntaxhighlighter/installation/

    Thanks for your help, macmanx ??

    Moderator James Huff

    (@macmanx)

    You’re welcome!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WP Converting Code Formatting’ is closed to new replies.