How to Keep Whitespace Formatting Using PHP/Html

How do I keep whitespace formatting using PHP/HTML?

use the <pre> tag (pre formatted), that will use a mono spaced font (for your art) and keep all the white space

<pre>
text goes here and here
and here and here Some out here
▄ ▄█▄ █▄ ▄
▄█▀█▓ ▄▓▀▀█▀ ▀▀▀█▓▀▀ ▀▀ ▄█▀█▓▀▀▀▀▀▓▄▀██▀▀
██ ██ ▀██▄▄ ▄█ ▀ ░▒ ░▒ ██ ██ ▄█▄ █▀ ██
█▓▄▀██ ▄ ▀█▌▓█ ▒▓ ▒▓ █▓▄▀██ ▓█ ▀▄ █▓
█▒ █▓ ██▄▓▀ ▀█▄▄█▄▓█ ▓█ █▒ █▓ ▒█ ▓█▄ ▒
▀▒ ▀ ▀ █▀ ▀▒ ▀ █▀ ░

</pre>

You might have to convert any <'s to < 's

Convert text formatted with whitespace to html

What you're looking for is a Markdown to HTML converter. Magmi doesn't have a plugin that can do this, however you could easily write one yourself.

  1. Create a Magmi plugin folder and file.
  2. Include a Markdown to HTML PHP library, such as this: https://github.com/michelf/php-markdown
  3. Use the processItemBeforeId() function to update the descriptions on the fly in the plugin, like this:

    public function processItemBeforeId(&$item,$params=null)
    {
    //Use the Markdown class library to convert the description.
    $updated_description = Markdown::defaultTransform($item['description']);

    //Update the description of the item before it gets imported.
    $item['description'] = $updated_description;
    }
  4. Enable your custom Magmi plugin, and it should start converting the descriptions on the fly when you import.

White-space formatting concerns in HTML

Wrap in a <pre> tag then apply some css: How do I wrap text in a pre tag?

pre {
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}

Demo with your sample html: http://jsfiddle.net/B98jc/



Related Topics



Leave a reply



Submit