• I am a developer who wants to share javascript code snippets he has written by using WordPress posts.

    I find that WordPress 2.3 makes this impossible to do

    I need to be able to post example code I have written in an unformatted manner, with spaces and HTML code syntax left in place.

    In the real world you do this by placing your previously formatted code inside the PRE and /PRE tags. The HTML render engine in your browser does no formatting to the items inside the tags. Simply displaying them as it would plain text.

    In the Post editor there is a “CODE” tab you can click on to to enable a “CODE” editor which lets you insert HTML tags. It’s here that you can insert the PRE tag.

    BUT

    The second you save the code it returns you to the GUI editor which then collapses all your spaces. This makes indentation in your code impossible to achieve. Every single line inside a loop, an if statment, etc.. all start in column one.

    You can post once, then never edit it again, but that would be the only option you have.

    P.S.

    I’ve tried to use the SyntaxHighlighter pluggin instead of the PRE tag to display my code – but it currently has a bug in it which I am waiting to hear back about

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Turn off the GUI editor entirely, see if that works better for you. Go to Users->Your Profile and disable the visual editor.

    If you refer to this post of yours:
    https://www.ads-software.com/support/topic/140233?replies=1
    that’s not really a bug. It’s the plugin’s stylesheet and your stylesheet combined.

    Thread Starter slaughters

    (@slaughters)

    “Turn off the GUI editor entirely..”

    Thanks – thought I did. Now at least I can post code inside PRE tags with out scrambling it.

    “..that’s not really a bug. It’s the plugin’s stylesheet and your stylesheet combined.”

    The style sheet used by the SyntaxHighlighter does not calculate widths properly when there is a float:right element in the same container.

    How is that not a bug?

    – Whatever – I just fixed it for you. Here is what you need to do. Remove the “width:99%” from the dp-highlighter class definition inside the SyntaxHighlighter.css file.

    This works for IE7 and Firefox. For IE6 it works to the extent that the float:right element stays on top and is not hidden by the dp-highlighter class item

    *** In other News ***

    What’s going on with the GUI editor? Why does modify the code inside the PRE tag?

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    What’s going on with the GUI editor? Why does modify the code inside the PRE tag?

    TinyMCE is not perfect. It’s not implemented perfectly in WordPress either. The short of it is that if you want to do anything more complex than text with images and links, you should probably disable it.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WordPress – Impossible to post Code Snippets?’ is closed to new replies.