WYGIWYS, please
« previous post | next post »
Our new content-management software, WordPress 2.5, has generally been a pleasure to install, administer and use. But I have a complaint. The solution is probably covered somewhere on the helpful WordPress forums, but the problem is annoying enough to document here.
The problem is that there's no way — that I've found — to get the WordPress posting interface to stop being "helpful" in unhelpful ways.
Let me illustrate. Suppose that I want to post some computer code (like here), where it's important to put newlines and spaces in specific and exact places. No problem, .html has <pre> … </pre> tags that should do just the right thing, and WordPress has an HTML mode. So I put the interface in HTML mode, and enter something like this:
Now I switch back to VISUAL mode, and this is what I see:
Oops — where did those blank lines come from? I switch back to HTML mode, and I'm puzzled to see this:
OK, the <p>…</p> markers have been replaced by newlines — but newlines will be interpreted as paragraph breaks, as annoying as that sometimes is, so whatever… Except that the helpful interpretation of newline as paragraph breaks is what's generating the extra blank lines in the <pre>…</pre> environment.
But mainly, what happened to my leading spaces?
Looking back at the VISUAL mode, things are still the same:
However, when I preview the post, the extra blank lines are gone (I guess because the CSS is doing the right thing with that aspect of the <pre>…</pre> environment). But of course, the leading spaces haven't come back:
We could go through the whole sad story of what happens when I try to use the special HTML space entities ' ' (they get deleted too — if you don't see ampersand n b s p semicolon back there between the single quotes, it's because WordPress has swallowed it from my post again) — but let's leave that for later.
I think that Melvyn Quince will join me in wishing that WordPress would offer an optional WYGIWYS ("what you get is what you specify") environment. Maybe even a WYGIWYFS environment.
[If you think you know a good solution — my favorite would be a way to tell wpautop() to "leave this stuff alone, please", or failing that, a way to turn it off for a whole post — please let me know. I do know about this, but it's not quite what I want.]
[A bit of search suggests that the wp-syntax plugin would be a solution for displaying code — though it wouldn't have solved my problem without some additional hacking, since Mathematica is not one of the supported languages. But anyhow, why should I have to rely on a parser and transducer that adds colors and stuff, when all I want to do is to display some material that's already properly formatted?
Does anyone post poetry with leading spaces in WordPress? If so, how do they do it?]
[Some discussion on the poetry problems is here.]
[Bertilo Wennergren points out that in WP 2.5 it's possible to turn the graphic editor off, so that conversions back and forth between VISUAL and HTML mode won't mangle your posts. (There are still some transformations, applying I guess when you save, such as inserting extra br tags at newlines.) I didn't notice this option before, because the Profile screen is not offered to the site administrator in the usual way to the site admin — but whatever your status, you can get to the Profile page via "Users" -> "Your Profile". Then if you uncheck "Use the visual editor when writing", you only see the "HTML" editor mode. This mode still thinks that it knows better than I do about <p>…</p> tags, but maybe it will let me have leading spaces in the <pre>…</pre> environment?
Let's try:
Line one, flush left.
Line two, one leading space.
Line three, two leading spaces.
Hooray, it works! Thanks, Bertilo! ]