• I have been searching everywhere for a solution to why every time I post code containing \n or \t at the start of a line, it gets removed. It is not possible to post correct python code e.g. Could anyone tell how I get this fixed?..

    – I have read http://codex.wordpress.org/Writing_Code_in_Your_Posts, looked at all the links and tried the plugins suggested.. It just broke my blog’s look and still removed \n and \t…..

Viewing 2 replies - 1 through 2 (of 2 total)
  • first, go to your theme’s .css file and create classes/attributes for various things you’d like to display.

    then, (i don’t know why you’re using \n or \t) try using ,
    , and &nbsp
    to position/format things as you’d like.

    also, if you take a look at the “extend” link above, i belive there are a number of plugins available for syntax highlighing/formatting, etc.

    Thread Starter jakobj

    (@jakobj)

    Okay.. Imagine you wanted to write the output of the php below into a post:
    < ?php
    echo “<pre> \nfirst line of code.. \n\tsecond linie which is indented.. \nthird linie not indented..\n</pre>”;
    ? >

    After you press any save button, WP saves the contents of the input felt as:
    < ?php
    echo “<pre>< br />first line of code..< br />second linie which is indented..< br />third linie not indented..< br /></pre>”;
    ? >

    And if you can read php, you see that the second linie is no longer indented.
    My problem isn’t CSS-related, I have tried using plugins and they do not help, when the problem is inside WP’s “saving” functions. I suspekt it is a filter I need to disable…. But I don’t which or how..

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Keeping whitespace for e.g. pre-tags’ is closed to new replies.