Forums

[resolved] WP Converting Code Formatting (5 posts)

  1. redcore
    Member
    Posted 2 years ago #

    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: http://shinytype.com/images/code-good.jpg
    After saving the draft: http://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!

  2. James
    Happiness Engineer
    Posted 2 years ago #

    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>
  3. redcore
    Member
    Posted 2 years ago #

    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.

  4. redcore
    Member
    Posted 2 years ago #

    Switched to SyntaxHighlighter Evolved and the problem is solved

    http://wordpress.org/extend/plugins/syntaxhighlighter/installation/

    Thanks for your help, macmanx :)

  5. James
    Happiness Engineer
    Posted 2 years ago #

    You're welcome!

Topic Closed

This topic has been closed to new replies.

About this Topic