WordPress.org

Ready to get started?Download WordPress

Forums

Keeping whitespace for e.g. pre-tags (3 posts)

  1. jakobj
    Member
    Posted 8 years ago #

    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.....

  2. Christopher J. Hradil
    Member
    Posted 8 years ago #

    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.

  3. jakobj
    Member
    Posted 8 years ago #

    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..

Topic Closed

This topic has been closed to new replies.

About this Topic