http://qs1969.pair.com?node_id=307683

Quick CSS tip for those who tend to write their longer perlmonks posts in a text editor rather than in a textarea field.

Add the following to the top of your HTML while editing:

<style type="text/css"> code { display: block; white-space: pre; color: red; } p > code { display: inline; } </style>

In a vaguely CSS compliant browser it will cause code blocks to be displayed as pre-formatted blocks, unless they're inside a paragraph tag, where they're displayed inline. I also colour them red, but that's just for taste.

This allows me to happily sit in my editor and see a better approximation of what will appear online in the preview window.

(and don't forget to remove the style tags before you post online)

Replies are listed 'Best First'.
Re: CSS tip for offline perlmonks writing
by EdwardG (Vicar) on Nov 18, 2003 at 07:38 UTC

    ++nice tip

    Anyone using vim under windows might also find it helpful to map a key to preview their post in a browser, like this:
    "open current file in browser map <F11> :update<CR>:silent !start D:\MOZILL~1\MOZILL~1.EXE "file://% +:p"<CR>

    Update: Added quotes around filename

Re: CSS tip for offline perlmonks writing
by Anonymous Monk on Nov 18, 2003 at 05:23 UTC

    Nice tip adrianh, thanks. I do have to ask though: Does anyone really type in the textarea fields anything but the most trivial bits of text? I can't imagine doing so myself.

      Does anyone really type in the textarea fields anything but the most trivial bits of text?

      I do.

      Most of my less-trivial code snippets posted here are written using my code editor, tested, and then pasted into the text box.

      But 100% of the actual text and markup tags of all of my 300 or so posts to this site were typed directly into the textarea field. Why not?


      Dave


      "If I had my life to live over again, I'd be a plumber." -- Albert Einstein

        A textarea is far too limiting of an editing environment for my tastes and I am quite surprised that others don't find it so. When I'm writing and editing text I want to do it in the best editing environment I have, not some crude, barely functional text widget in a browser. Everything I post here is written in a real editor and pasted into the textarea. I can't think of a single reason not to use a real editor.

      Most of my posts are written directly in the textarea. This is mostly because I'm highly lazy, and often falsely lazy. It's also because cut-and-paste in X tends to mess me up for some reason. It's also because I become more perfectionistic about my formatting when I'm using an HTML editor, to the point where I never end up posting. (See, for example, this half-done tutorial on context, which I normaly would have just posted where I started writing it, and not decided that it should be recast as a tutorial... so now it's sitting, waiting for me to have another burst of wanting to talk about such things. (BTW, the contents of my pad tends to change quite a bit, so if you're reading this significantly after it's posted, that link is unlikely to go anywhere useful.)


      Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).