Preformatted text formatting May 25, 2008 10:00 PM   Subscribe

Can we fix the <pre>formatted text bug where the live preview looks perfect, but the actual post ends up double-spaced?

You can create a preformatted text block correctly by using <br> tags instead of line breaks, but that's extremely hard to do when you're pasting a big block of text in.

Broken example:
    one
    two
    three
Working example:
    one    two    three
posted by knave to Bugs at 10:00 PM (119 comments total) 1 user marked this as a favorite

By the way, those look the same in my rss reader.

I don't think ascii art is really appreciated, & there's pastebin for, say, code snippets.
posted by Pronoiac at 10:17 PM on May 25, 2008


... what? rtfa? sorry about that.
posted by Pronoiac at 10:22 PM on May 25, 2008


You're right, I could've used a pastebin. But I was suckered in by the live preview, in which everything looks fine. So, I guess, if we're not going to fix the issue, we should make live preview at least give you some idea that it's going to look different when it finally posts.

Also, I'm an avid ASCII art enthusiast, since the untimely demise of the img element.
posted by knave at 10:33 PM on May 25, 2008


Live Preview is more of a guide, it's not nearly as accurate as clicking the "Preview" button and seeing your post on the page. There's a FAQ entry about this: My HTML seemed to work in the live preview but don't come through correctly. Is this a bug or intentional? Live preview is good for checking bold, italic, and link HTML before you post, but it doesn't accurately show anything much beyond that.
posted by pb (staff) at 10:34 PM on May 25, 2008


pb, using "Preview" has its own set of issues. For example, in my post, I put &lt; and &rt; to write HTML tags without them being rendered as actual HTML. After Preview, they are changed into < and > respectively. So Preview is a mildly destructive operation. Also, even though Live Preview is considered a "guide", it doesn't mean it shouldn't be improved where possible.

I guess the realization here is that MetaFilter is not a friendly place to be posting code snippets, particularly of HTML. It would be nice to see some improvement in that regard, although I agree the issue isn't huge.
posted by knave at 10:44 PM on May 25, 2008


Idea: Maybe someone could implement the Preview button as an awesome AJAX thing, that goes off to the server, does the server-side processing, and then renders the result below the post. It wouldn't be real-time like the live preview, but it would be accurate and wouldn't be destructive to the HTML entity codes you may have typed in your comment box. Neat, huh?
posted by knave at 10:48 PM on May 25, 2008


Preview shouldn't destroy the HTML entities you've entered. If I type &lt; into the textarea, I see < on preview, as I should because that's how it will be rendered. I still have &lt; in the textarea for editing. I don't see anything degrading in the process. (Mac, Firefox.) If there are issues with Preview not showing the end result correctly, we'd like to get those fixed up.
posted by pb (staff) at 10:54 PM on May 25, 2008


Hm, looks like it works in comments now, that's cool. But try posting a new MetaTalk or MetaFilter thread, and you should see the issue.
posted by knave at 11:05 PM on May 25, 2008


                  ___.-~"~-._   __....__                .'    `    \ ~"~        ``-.               /` _      )  `\              `\              /`  a)    /     |               `\             :`        /      |                 \        <`-._|`  .-.  (      /   .            `;\\         `-. `--'_.'-.;\___/'   .      .       | \\      _     /:--`     |        /     /        .'o \\     ("\   /`/        |       '     '         /  O :`;     `\'\_/`/         .\     /`~`=-.:        /     ``       `._.'          /`\    |      `\      /(    O                     /  /\   |        `Y   /  \                        /  /  Y  |         |  /`\  \   O                   /  |   |  |         |  |  |  | OOO                  "---"  /___|        /___|  /__|OOOOOO                         '"""         '"""  '"""
Yeah, can we please fix this?
posted by Krrrlson at 11:06 PM on May 25, 2008 [6 favorites]


I'd love to see this fixed too. I also wouldn't mind getting some CSS love for
blockquote
elements, so that their margin/padding is reduced and I can sort of type them in regularly in the big old textarea. As it is there's lots of extraneous space before and after the text enclosed by blockquote tags.

(On preview: you can kind of avoid the double-spacing issue, I think, if you use
a code block
instead of a block the begins and ends
with the pre tag
by my personal opinion is that that's kind of a hack relying on
br
tags interpolated into the actual text).
posted by whir at 12:19 AM on May 26, 2008


Piggybacking: the css for blockquote has been suboptimal since, well, always, I think. Could we tighten up the trailing whitespace a bit?
posted by stavrosthewonderchicken at 12:55 AM on May 26, 2008


Well, entities are removed; if you embed the &nbsp; code, for instance, it will be turned into a normal space by preview. And, when I first previewed to see if I did the nbsp properly, it changed my &amp; code into a &, and then destroyed the nbsp on the next preview. This is really frustrating.

In general, I think Preview shouldn't destroy any text in the comment box AT ALL -- adding in close tags would be okay -- if nothing else, as a visual hint that you're an idiot -- but nothing in the post body should be changed in any way, other than that.
posted by Malor at 3:20 AM on May 26, 2008


Argh, and the wording/punctuation in that last paragraph was absolutely terrible... because I didn't want to use preview. Sorry. I'm not quite that illiterate. Almost, but not quite. :)
posted by Malor at 3:21 AM on May 26, 2008


Idea: Maybe someone could implement the Preview button as an awesome AJAX thing, that goes off to the server, does the server-side processing, and then renders the result below the post. It wouldn't be real-time like the live preview, but it would be accurate and wouldn't be destructive to the HTML entity codes you may have typed in your comment box. Neat, huh?

The problem with that is that "Preview" lets you see what has been posted on the thread since you started typing your message. If you are about to leave the same comment as four other people just did, "Preview" prevents this. Doing an AJAXified preview would eliminate this bit of functionality that does wonders for stopping redundant posts.

I do have to second the idea going around that if possible, Preview should not be processing, at least, HTML entities. This can, and often does, radically change the result away from what the user intended to write.
posted by graymouser at 4:50 AM on May 26, 2008


Oh, whir: for blockquote, you can just embed the code directly into the text,
without any carriage returns
whatsoever, and the overall spacing comes out pretty okay.
posted by Malor at 5:19 AM on May 26, 2008


What Malor said. I don't understand all the whining about blockquote; there is no problem unless you choose to add unnecessary br's.
posted by languagehat at 6:05 AM on May 26, 2008


Is it kind of dickish to characterize a polite request as "whining"? I think it is.
posted by Wolfdog at 6:28 AM on May 26, 2008 [1 favorite]


I'm not into ascii art. But I am into ascii charts. I've often wanted to answer an AskMe post via a flowchart or whatever, and I'm pretty used to making these with text characters. But I rarely bother, because the whole preview thing is so complicated.
posted by grumblebee at 7:11 AM on May 26, 2008


The problem with that is that "Preview" lets you see what has been posted on the thread since you started typing your message.

Yeah, I realized that after I suggested it. It probably isn't such a great idea, after all.
posted by knave at 7:13 AM on May 26, 2008

Is it kind of dickish to characterize a polite request as "whining"? I think it is.
Well languagehat is correct you'd have to be some kind of idiot to add unnecessary line breaks.
posted by theiconoclast31 at 8:44 AM on May 26, 2008 [2 favorites]


All of us are some kind of idiot at various points.
posted by Brandon Blatcher at 8:47 AM on May 26, 2008


Speak for yourself Blatcher. We morons take offense. (;
posted by netbros at 9:14 AM on May 26, 2008


a moron is a completely different thing compared to an idiot. trust me, i'm an expert.
posted by quonsar at 10:14 AM on May 26, 2008 [1 favorite]


As the Three Stooges would say, there are three kinds of fools, imbeciles, morons, and idiots. Taking the middle way, I'll claim the moron tag.
posted by dawson at 10:24 AM on May 26, 2008


So are experts a kind of moron or a kind of idiot?
posted by nebulawindphone at 10:28 AM on May 26, 2008


(And what's the deal with squares and rectangles? Oh, I'm so confused!)
posted by nebulawindphone at 10:32 AM on May 26, 2008


I came in here to mention that code tags don't double space things, but I see that's already been mentioned.

What I just noticed is that the code tags don't preserve whitespace like the pre tags do though.
text with spaces before it, in code tags
             more text with spaces before, in pre tags
And what's with the extra space around the pre tags? It's like blockquote all over again.
posted by philomathoholic at 10:54 AM on May 26, 2008


nebulawindphone: And what's the deal with squares and rectangles?

Squares are a subset of rectangles, they have more restrictions. Rectangles are polygons with four right angles, squares are rectangles with equal length edges.
posted by philomathoholic at 11:00 AM on May 26, 2008


Is it kind of dickish to characterize a polite request as "whining"? I think it is.

Eh, maybe a little. But after the 500th time that somebody comes around asking for a fix for something that doesn't need fixing, it gets a little old.
posted by languagehat at 1:13 PM on May 26, 2008


What Malor said. I don't understand all the whining about blockquote; there is no problem unless you choose to add unnecessary br's.

Eh, maybe a little. But after the 500th time that somebody comes around asking for a fix for something that doesn't need fixing, it gets a little old.

Fuck you, buddy. I didn't whine, I made a polite and related request. I have not a fucking clue what you're talking about with ' adding unecessary <br>'s'.

Blockquote is wrapped in a ridiculous amount of whitespace. It needs to be fixed. I'm truly sorry if it's getting a little old for you that people have requested a fix FIVE HUNDRED TIMES, but try not to be such a dick, ok?
posted by stavrosthewonderchicken at 2:06 PM on May 26, 2008 [1 favorite]


Huh, weird, I thought live preview had been killed. Apparently it just got turned off for me. How did that happen?
posted by !Jim at 2:17 PM on May 26, 2008


giant user names in tag clouds is broke. oh, and images.
posted by quonsar at 3:21 PM on May 26, 2008 [1 favorite]


It's annoyed the shit out of me on several occasions, but there doesn't seem to be much will to do anything about it. I'd argue that if it can't be fixed then at lease the preview should be broken to match the result.
posted by Artw at 3:22 PM on May 26, 2008


languagehat: But after the 500th time that somebody comes around asking for a fix for something that doesn't need fixing, it gets a little old.

That people have requested this 500 times is, as stavros implies, a pretty strong indicator that the issue does need fixing.

The problem isn't that users are entering unnecessary <br> tags (which are different from line breaks); it's that the system is adding unecessary <br> tags. A slightly more sophisticated comment parser would know not to translate line breaks into <br> tags immediately after an opening block element tag (such as <p> or <blockquote>) or immediately before a closing block element tag (such as </blockquote>), or would know how to strip out unneccary <br>s after the fact.

For example (prior to the line break to <br> translation):

    s/<(p|blockquote|div|ul|ol|li)>\s+/<$1>/ig;
    s/\s+<\/(p|blockquote|div|ul|ol|li)>/<\/$1>/ig;


You're asking both experienced and inexperienced users to learn (and commit to active memory) a kludge just for Metafilter. It's entirely normal (and in almost all other cases entirely harmless) to enter line breaks before and after block element tags. That you've learned and are tired of having to remind people about the abnormal requirements of this site doesn't mean nobody has the right to keep asking for them to be addressed.

(And the CSS for <pre> tags really is messed up. And &nbsp; entities do get converted in the textarea after you click "Preview.")
posted by macrone at 4:19 PM on May 26, 2008 [3 favorites]


You've got my vote. Yes, preview, both kinds, are completely broken for anyone who wants to post code. I can't believe the kind of wank that gets added to MeFi, when stuff like this is broken and has been for years.

We can have Twitter feeds, AJAX flagging, and the jobs page will tell me that a job in England is 12,347 miles away from where I live, but we can't reliably post a three-line perl script.
posted by AmbroseChapel at 4:58 PM on May 26, 2008 [5 favorites]


Fuck you, buddy. I didn't whine, I made a polite and related request. I have not a fucking clue what you're talking about with ' adding unecessary
's'.

Blockquote is wrapped in a ridiculous amount of whitespace. It needs to be fixed. I'm truly sorry if it's getting a little old for you that people have requested a fix FIVE HUNDRED TIMES, but try not to be such a dick, ok?


Jesus, buddy, calm down, willya? I didn't insult you, and I have no idea what you're so huffy about. Maybe when you have your coffee, you'll realize that if you just put the
blockquote
in the middle of your text, it looks fine, but if you
add unnecessary line breaks
around it, it acquires the extra space being complained about. And try not to be such a dick, ok?
posted by languagehat at 5:26 PM on May 26, 2008


i'm basically just worried that they'll change the CSS and correct the blockquote and all my posts without linebreaks will look squished and ugly and spaceless and oh why do i feel so alone
posted by theiconoclast31 at 5:32 PM on May 26, 2008


What's really dickish, languagehat, is your continuing to post this same stupid objection after having had the issue explained to you before.

And as for "just put the blockquote in the middle of your text", nobody fucking codes HTML like that. (Unless they're trying to get around MetaFilter's broken HTML-munging code, that is.)
posted by Crabby Appleton at 5:43 PM on May 26, 2008


                  ___.-~"~-._   __.....__
                .'    `    \ ~"~| FIXED |`-.
               /` _      )  `\  |  THAT |   `\
              /`  a)    /     | |   FOR |     `\
             :`        /      | |   YOU |       \
        <>
         `-. `--'_.'-.;\___/'   |||||||||      | \\
      _     /:--`     |        /     /        .'♥ \\
     ("\   /`/        |       '     '         /  ♥ :`;
     `\'\_/`/         .\     /`~`=-.:        /     ``
       `._.'          /`\    |      `\      /(    ❤
                     /  /\   |        `Y   /  \    
                    /  /  Y  |         |  /`\  \   ❤
                   /  |   |  |         |  |  |  | ❤❤❤
                  "---"  /___|        /___|  /__|❤❤❤❤❤
                         '"""         '"""  '"""
                                 
posted by Sys Rq at 5:44 PM on May 26, 2008 [3 favorites]


Awesome.
posted by Sys Rq at 5:44 PM on May 26, 2008


FWIW, I didn't preview that. Live preview looked a-ok.

Apparently the MeFi manglifier is automatically adding a br at every line break, even within pre tags. Considering that the pre tag is for pre-formatted text, uh, yeah, it probably shouldn't be doing that.
posted by Sys Rq at 6:11 PM on May 26, 2008


Right, Sys Rq. Every line break in every case is translated to <br> followed by a line break. So in PRE blocks that becomes two line breaks (the <br> produces one line break and the actual line break another).

Another fix would be just to strip out newline characters after every <br> tag once the other processing is complete. All it would take is some very simple regular expressions.
posted by macrone at 6:22 PM on May 26, 2008


The metafilter implementation of blockquote seems to meet W3C standards, according to this. Specifically, "The BLOCKQUOTE typically provides space above and below the quote." That's a strong piece of evidence in favor of languagehat et al. and against Team Wonderchicken, right? languagehat was kind of a dick about it, but he also seems to be right; examples matching those criteria are widely available on this site.
posted by Kwine at 6:33 PM on May 26, 2008


That's correct Kwine, but the problem is that a <br> tag is added above and below the blockquote for each line break, making twice the amount of whitespace than necessary.
posted by Frankieist at 6:38 PM on May 26, 2008


There is no "metafilter implementation of blockquote". <blockquote> is an HTML construct, it is rendered by the HTML renderer, which is part of your web browser. (It's important in computer software development to keep your levels of abstraction straight.)
posted by Crabby Appleton at 6:52 PM on May 26, 2008


Yes, Kwine, you're mistaken. That document is about how browsers should read HTML and isn't relevant to the discussion we're having.

It's also thirteen years old and concerns a long-dead version of HTML, you might like to note.
posted by AmbroseChapel at 6:59 PM on May 26, 2008


Jesus, buddy, calm down, willya? I didn't insult you, and I have no idea what you're so huffy about.

Oh, quit yer whining. ;-)
posted by stavrosthewonderchicken at 8:04 PM on May 26, 2008 [2 favorites]


aha, you're all right. A more HTML-friendly Preview is officially on The To-Do ListTM. Thanks for the heads up.
posted by pb (staff) at 8:31 PM on May 26, 2008


pb just made me happy, 'cause this thread was like a balloon about to burst. I feared flame outs. I wish I could ask how to 'un-ad' myself as a friend, it sucks and arghhh. A new thread?
posted by dawson at 8:45 PM on May 26, 2008


If we can fix up preview, sweet. And I've got nothing against looking at sane-ifying the interpolated breaks in pre and blockquote or the spacing around blockquote, but there is that sticky question of what to do about the existing nine years of comments and posts that were made (at least by the folks who knew to do so) with the current weird system in place. Having those suddenly go to poop because we update the stylesheet and the display parser is kind of a messy and depressing thought.
posted by cortex (staff) at 8:49 PM on May 26, 2008


dawson, maybe try hitting this link? I just found the URL of another remove contact link and substituted your user ID.
posted by whir at 8:50 PM on May 26, 2008


And yeah, I think maybe I'll tape a little sign on my computer with a picture of pb giving a conciliatory thumbs-up. And just stop for a second and take a deep breath and give him a little wave before I ban people.
posted by cortex (staff) at 8:50 PM on May 26, 2008


And about the legacy blockquote issue, the solution that springs to mind immediately is to have the renderer produce something like <blockquote class="pancakes"> and then change the CSS for that class only.
posted by whir at 8:53 PM on May 26, 2008


Damn you whir, beat me to it.
posted by !Jim at 8:54 PM on May 26, 2008


whir, either the link you provided is fornicated or I don't get the joke...
posted by dawson at 8:55 PM on May 26, 2008


Hmm, sorry, it was just a guess. I suppose you will need administrator hope then.
posted by whir at 9:00 PM on May 26, 2008


it's OK, I'll just keep it as a constant reminder of my rash rush to be cutting edge, or something. It's a below the radar hack anyway.
posted by dawson at 9:03 PM on May 26, 2008


Live Preview is more of a guide, it's not nearly as accurate as clicking the "Preview" button and seeing your post on the page.

As long as the Preview button is being pimped as a better, more accurate choice for previewing comments, would it be too much to ask that the Preview page be given up-to-date functionality? For stuff like favorites and flags and all the other gee-gaws the normal pages have?
posted by carsonb at 9:29 PM on May 26, 2008


carsonb, the Preview page is just a spot to quickly check your post and see if anything new is posted. I'm not sure we want to encourage using the Preview page for anything beyond that.
posted by pb (staff) at 9:54 PM on May 26, 2008


Yeah, the preview and line-break parsing is a little suboptimal at mefi and has been for years. The problems are complicated and break down like so:

- The original intention is that you can write normally without having to know any HTML at all. You type and hit return and type some more? We make that into two paragraphs for you automatically with some simple dumb checking for carriage returns, swapping in line break tags (just br tags, not proper wrapping of paragraph tags).

- I've seen some of the guts on things like the posting form of Movable Type and the regex necessary to properly wrap paragraphs when text is entered, but ignored in the middle of unordered lists and preformatted text and teletype and every other crazy bunch of tags is a nightmare. I didn't want to go too far down that path so I just chose to tack on a br when you hit the return key. We should probably strip them out within some HTML blocks like blockquote and lists and pre's.

- Posting code is obviously a nightmare because a comment parser has to tell the difference between when you're writing about code, when you want to write out code to share, and when you want code to actually be embeded and parsed to change the way the comment looks. It's no easy task and virtually no forums get this right (that's why pastebin exists). I don't think a chunk of perl code plopped into a comment here is ever going to be perfectly non-parsed and escaped, while still being able to everything else we do with comments.

- The live preview is a relatively recent addition from the last couple years that gives an approximation of what you're writing will look like but since it's live javascript parsing and not the server-side parsing we normally do, there's virtually no way to make them 100% identical, so we always suggest if you're smart enough to use HTML in your comments, the preview button will show you stuff as it will look when posted.


The bottom line is that the simple dumb way I watch for linebreaks works for 99% of stuff that gets posted to mefi, but among the members that know HTML well, it can get in the way of what you intended for display. It's not a simple thing to fix and why some escaping bugs have persisted for years. We'll take a crack at fixing the easiest parts that get in the way most often (like pre tags and blockquote tags) but I don't think we'll ever have a perfect forum for handling all three common cases: writing normal everyday english without knowing HTML, writing out some HTML within your comment that you want to change the look of your comment with exactly as you like, and lastly posting code and HTML to show others without parsing any of it or tripping any existing regexes to remove bad code and unclosed tags.
posted by mathowie (staff) at 10:10 PM on May 26, 2008


Any chance you could throw in an extra page along the lines of "hey, you appear to be using <pre> or <blockquote> and haven't clicked preview, is this what you wanted your post to look like?" (then a preview)?

It's rare that I use them, so it wouldn't be too annoying, and certainly less anyoying than forgetting every time.
posted by Artw at 10:22 PM on May 26, 2008


Hey, my comment was wildly stupid! I'll be shutting up and going away now :(
posted by Kwine at 10:25 PM on May 26, 2008


the Preview page is just a spot to quickly check your post and see if anything new is posted. I'm not sure we want to encourage using the Preview page for anything beyond that.

I don't want to seem peevish, but why not? It looks, feels, smells, and tastes exactly like a normal page, but doesn't function like one. If I'm gonna see if anything new is posted while checking my comment, why can't I 'respond' to it in all of the ways available normally? On preview, I'd flag Artw's comment as offensive but I. just. can't!
And as long as I have you gentlemen here, how about adding focus to initial fields on certain pages like login and compose MeMail?
posted by carsonb at 10:25 PM on May 26, 2008


Hey, I didn't even suggest swapping PRE and BLOCKQUOTE out for styled DIVs this time!
posted by Artw at 10:30 PM on May 26, 2008


Why does Metafilter hate white people space so much?

posted by blue_beetle at 10:30 PM on May 26, 2008


Whitespace people love!
posted by Artw at 10:39 PM on May 26, 2008


oh! blue beetle, oh!
posted by dawson at 11:36 PM on May 26, 2008


SHUT THE FUCK UP YOU FUCKING ALBANIANS
posted by scrump at 1:43 AM on May 27, 2008


I don't think a chunk of perl code plopped into a comment here is ever going to be perfectly non-parsed and escaped, while still being able to everything else we do with comments.

I don't think anyone's expecting instant perfection, just sort of some easy movement toward it. :) The destructive Preview really adds to the problem, and fixing it would be of great utility. I'm confused about the exact internal process, but it appears to take the user code, strip out and add a bunch of stuff, and only then post it... but it throws away the original text entirely in the process, giving the user a mangled version in their next Preview.

Obviously, you need to mangle it, but preserve the original user text, and put THAT in the next preview box. As an optional extra, it would be nice to have the sanity-check closing tags pasted onto the end, because that's a nice hint that, "hey, you're a dork and forgot something here".

Without knowing the internal flow, however, I imagine that could be a fairly substantial change. At the moment, you have two text bodies; the user's, and the mangled flavor. Adding in JUST closing tags would mean you'd need three: original, fully-mangled, and semi-mangled, and that's probably too much of a hassle. Just remembering the original user text and giving that back to them, unchanged, would be enough. (Semi-mangled would be a nice bonus, if you can swing it without too much effort or server load.)

MeFi may never be smart enough to get the three lines of perl code right on its own, but we generally are. As long as we're getting back exactly what we started with, we can tinker and fix problems fairly painlessly, iterating a few times until we get it right. Destructive Preview makes the iteration a lot harder.

I'd also like to see the Preview button and the Live Preview better synced in terms of their code, but they're such different features that I realize this may never happen.
posted by Malor at 2:50 AM on May 27, 2008


To shorten all those words into just a few: please, make it so that the Preview button gives us back exactly what we started with. That will cure many headaches, all by itself.
posted by Malor at 2:54 AM on May 27, 2008


...make it so that the Preview button gives us back exactly what we started with.

That's where the rub is, unfortunately. To get back exactly what you started with in the textarea, we have to massage what you gave us. For example, if you type "&lt;" into the textarea, if we give back exactly that in the textarea on the Preview page, the browser will render it as < in the textarea (not what you typed). So we now have three versions of the text: what you originally typed, what users will see on the page, and a massaged version of what you typed that renders properly in a textarea.

We'll definitely move toward perfection as best we can. But the layers of escaping for editing HTML within an HTML page make it a bit of a challenge.
posted by pb (staff) at 6:34 AM on May 27, 2008


What's really dickish, languagehat, is your continuing to post this same stupid objection after having had the issue explained to you before.

Oh, give me a fucking break. What, it's OK for you to repeat yourself endlessly but no one else can get a word in edgewise? It's not a stupid objection, it's perfectly sensible. Here, let me spell it out for you:

1) Blockquote is not often used. I'm fond of it myself, and for that reason I learned early on how to do it in the MeFi context, but it's quite possible to go through one's entire MeFi existence without ever even noticing this alleged problem.

2) I understand the point about how people familiar with coding expect things to work, but frankly that's their problem. It is easy to make blockquote work in MeFi. How it works elsewhere is not especially relevant.

3) There are actual problems that need fixing, so why fixate on a nonproblem that doesn't?

Mind you, I'm not saying there's anything wrong with making the grousers happy, and I'm glad pb is going to do so. I just thought, and continue to think, the issue has been overblown, and I don't appreciate the insults for daring to differ from your opinion.
posted by languagehat at 6:38 AM on May 27, 2008


For example, if you type "&lt;" into the textarea, if we give back exactly that in the textarea on the Preview page, the browser will render it as <

Ohhh, that's more complex than I realized. Pardon my ignorance here, but isn't there some way of saying, "this text is just text, not html, and it should be the default in this entry field"?

For what it's worth, on the PHP-BB style web forums, they've solved this problem somehow. I just went to Gamers With Jobs and tested an HTML entity, (nbsp), and it both previews correctly and comes back with precisely the text I started with. It looks easy -- which isn't necessarily a sign that it is -- so it might be worth poking around in the code base of whatever package they're using to find out what they're doing.

There might be an 'encode this text for return to user' function... but, hmm, you're working in ColdFusion, it may not be that advanced. :(

Are you playing with this right now? I'm seeing some rather odd results from my usual workarounds in posting codes. :)
posted by Malor at 8:06 AM on May 27, 2008


Are you playing with this right now?

Nope. Hopefully later this week.

And yep, there are some built-in ColdFusion functions that I'll take a look at. For some reason the CF-brewed solutions always turn out to be less than fantastic and we end up writing something from scratch anyway.
posted by pb (staff) at 8:14 AM on May 27, 2008


Argh. There's a perfect tag to do exactly what you want -- XMP -- but it's been deprecated, and no alternative has replaced it. Suckage.
posted by Malor at 9:05 AM on May 27, 2008 [1 favorite]


Yeah, I do a lot of CF development in my day job and have found that the built-ins are lacking (in particular HTMLEditFormat(), which probably the most applicable thing here, is full of omissions and fail - one is better off using a regular expression, or even just using Replace() a bunch of times).

I thought somebody posted a very simple escaping solution the last time this came up that would have solved a lot of problems, which if I recall correctly had to do with ampersands. But maybe it was already implemented. In any event, I will try to dig it up.
posted by whir at 11:57 AM on May 27, 2008


Hey, my comment was wildly stupid! I'll be shutting up and going away now :(

Please reconsider, Kwine. What you're contemplating would be highly atypical behavior on Metafilter. If this became a trend, there'd soon be no one left to post.
posted by Crabby Appleton at 12:48 PM on May 27, 2008


Languagehat favors us with the following:
Oh, give me a fucking break. What, it's OK for you to repeat yourself endlessly but no one else can get a word in edgewise?
Well, in a perfect world... But seriously, in the comment I linked to above I was answering a question you asked.
It's not a stupid objection, it's perfectly sensible. Here, let me spell it out for you:
Thank you. I mean it. For the first time you've actually given a rationale of sorts for your position on this issue, instead of making some snarky, dismissive remark, which is what I was objecting to.
1) Blockquote is not often used.
I wonder if that's because of the way it looks if you don't know the little trick for avoiding the excess vertical space. If you're quoting more than a sentence or two, you should use it (the MetaFilter Wiki notwithstanding).
I'm fond of it myself, and for that reason I learned early on how to do it in the MeFi context, [...]
If you figured it out own your own, I'm impressed. It's not trivial for someone with no technical background to do that. I think that if this doesn't get fixed pretty soon, the trick should be documented in the HTML help.
[...] but it's quite possible to go through one's entire MeFi existence without ever even noticing this alleged problem.
I notice the problem with other people's posts all the time.
2) I understand the point about how people familiar with coding expect things to work, but frankly that's their problem. It is easy to make blockquote work in MeFi. How it works elsewhere is not especially relevant.
It's easy only if you know the trick. Initially, this requires knowing (or suspecting) that there is a trick and either figuring it out for yourself or searching MetaTalk (or maybe AskMetafilter) to find it.
3) There are actual problems that need fixing, so why fixate on a nonproblem that doesn't?
The distinction between "actual" and "non-" problem is in the eye of the beholder. If you tell me the problems you consider to be of higher priority than this one, I'd be surprised if there were many on which I'd agree with you. AmbroseChapel makes a similar point in an earlier comment.
Mind you, I'm not saying there's anything wrong with making the grousers happy, and I'm glad pb is going to do so.
Thanks.
I just thought, and continue to think, the issue has been overblown, and I don't appreciate the insults for daring to differ from your opinion.
The insult was not for your difference of opinion, but for being a dick about it. ("Is that so hard?" "I don't understand all the whining about blockquote")
posted by Crabby Appleton at 3:13 PM on May 27, 2008


I wonder if that's because of the way it looks if you don't know the little trick for avoiding the excess vertical space. If you're quoting more than a sentence or two, you should use it (the MetaFilter Wiki notwithstanding).

All else aside, I think that it's actually because most people just plain don't use <blockquote> or even know that it exists. While I don't disagree in spirit (and with a degree of qualification) with your "should", there, that's a far cry from anything like "do" or "would if not for that darned bug".
posted by cortex (staff) at 3:30 PM on May 27, 2008


You're probably right, cortex. I'd like to see it used more, but it's a hard sell when you have to jump through hoops to make it look right.
posted by Crabby Appleton at 3:57 PM on May 27, 2008


Yeah, I should have said "grousing" or something instead of "whining." My bad, and thanks for the response.
posted by languagehat at 3:58 PM on May 27, 2008


You're welcome. And thanks.
posted by Crabby Appleton at 4:16 PM on May 27, 2008


For example, if you type "&lt;" into the textarea, if we give back exactly that in the textarea on the Preview page, the browser will render it as <

The solution: escape HTML characters before you output them to the page. Maybe in Coldfusion this is difficult, but in PHP, Perl, et al it is pretty simple (for example, see htmlspecialchars). If you have to roll your own, you want to do this simple two-step process:
  1. Replace “&” with “&amp;”.
  2. Replace “<”, “>”, “"”, and “'” with “&lt;”, “&gt;”, “&quot;”, and “&apos;”, respectively.
Bada bing, bada boom, preview becomes non-destructive.
posted by Khalad at 6:51 PM on May 27, 2008


Kind of assumes you NEVER want HTML though, doesn't it?
posted by Artw at 7:08 PM on May 27, 2008


No, this is just when populating the <textarea> for editing. When rendering the comment—in the preview area, or in the comment list proper—you don't escape anything. That part of Metafilter isn't broken, after all, so it doesn't change. Only the code that populates the <textarea> applies this transformation.
posted by Khalad at 8:02 PM on May 27, 2008


BBCode people! BBCode!
posted by blue_beetle at 6:40 AM on May 28, 2008


Oh, god, please no. And no Textile or Markdown, either!
posted by timeistight at 7:36 AM on May 28, 2008


Setting aside the <blockquote> and <pre> linebreak issues for a moment, I just added the escaping that Khalad recommended to comments Preview only. That seems to preserve HTML entities and escaped markup. Let me know if you hit any problems with it. If not, I'll move this over to posts as well.
posted by pb (staff) at 9:57 AM on May 28, 2008


Looks good after a minute of messing with it, pb. Good job!
posted by knave at 8:07 PM on May 28, 2008


If anyone's still tuning in here, we're testing out stripping breaks from <pre> and <ul> blocks in comments right now. We're also now stripping breaks that precede and follow <blockquote> tags, which should help with spacing. The test is running on MetaTalk only. Please test it out and see if these changes help.
posted by pb (staff) at 11:59 AM on June 3, 2008


TEST:

               .<>. 
            .<>. 
         .<>@@@@@>. 
      .<>@@@@@>. 
   .<>@@@@@>. 
   '<>@@@@@>' 
     '<>@@@@>' 
       '@@@@<>@@@@>' 
         '<>' 
           '<>' 
             '<>' 
               '<>' 
                 '<>' 
                   '<>' 
                     '<>@@@@>' 
                       '<>@@@@>' 
                         '<>@@@@>' 
                           '<>@@@@>' 
                             '<>@@@@>' 
                               '<>' 
                                 '<>' 
                                   ^^   
posted by grumblebee at 12:09 PM on June 3, 2008


:-( that was supposed to be the superman logo. I put it in a pre. Looked perfect in the live preview.
posted by grumblebee at 12:09 PM on June 3, 2008


Live preview hasn't changed at all, and it's still not a faithful representation of what you'll see when you post. Please use the HTML Preview instead for testing, that's supposed to be an accurate representation of formatting. (Plus ASCII art that includes less-than and greater-than signs are probably going to be eaten alive by our HTML-cleaner.) But hey, thanks for trying it out!
posted by pb (staff) at 12:17 PM on June 3, 2008


((
\\``.
\_`.``-. 
( `.`.` `._  
 `._`-.    `._ 
   \`--.   ,' `. 
    `--._  `.  .`. 
     `--.--- `. ` `. 
         `.--  `;  .`._ 
           :-   :   ;. `.__,.,__ __ 
            `\  :       ,-(     ';o`>.
              `-.`:   ,'   `._ .:  (,-`,
                 \    ;      ;.  ,: 
             ,"`-._>-:        ;,'  `---.,---.
             `>'"  "-`       ,'   "":::::".. `-.
              `;"'_,  (\`\ _ `:::::::::::'"     `---.
      -hrr-    `-(_,' -'),)\`.       _      .::::"'  `----._,-"")
                   \_,': `.-' `-----' `--;-.   `.   ``.`--.____/ 
                     `-^--'                \(-.  `.``-.`-=:-.__)
                                            `  `.`.`._`.-._`--.)
                                                 `-^---^--.`--

posted by grumblebee at 12:47 PM on June 3, 2008


COOL!

I don't want to sound like I'm begging for more and more features, since it's awesome that you we have this at all. But it would be great -- ultimately -- to NOT parse greater-and-less-than symbols inside pre tags.

One of the main uses for this, as I see it, is for putting code examples in AskMe. And you'll often need gt and lt symbols in code. Also, they're really good for arrow heads in diagrams.
posted by grumblebee at 12:49 PM on June 3, 2008


TEST:

-------->   <---------

posted by grumblebee at 1:10 PM on June 3, 2008


<pre> isn't supposed to escape HTML, so we need to make sure any markup within is valid. You'll still have to escape any HTML examples with &lt;, even within a <pre> tag. As mathowie mentioned above, discerning your intention when posting HTML is difficult, so we recommend linking to pastebin for large code examples. The main thing we're trying to achieve with this new change is better formatting for plain text.
posted by pb (staff) at 1:44 PM on June 3, 2008


Thanks to thsi thread I didn't fuck up PRE this time when i used it. I'll prbably forget next time though.

Here's a thought - how about styling PRE, and other tags liable to fuck up, bright red in the live preview so that people know extra caution is required?
posted by Artw at 1:53 PM on June 3, 2008


grumblebee: You might want to throw the Superman logo at the FCK Editor & throw its output in here. It fixes the angle brackets, anyway.

The preview page makes already posted "pre-"using comments look funky. (Not a complaint, just an observation which might save a WTF?! moment.)
posted by Pronoiac at 2:18 PM on June 3, 2008


oops, thanks Pronoiac, <pre> blocks on the Preview page should look better now.
posted by pb (staff) at 3:45 PM on June 3, 2008


There was this one comment:
Thanks to thsi thread I didn't fuck up PRE this time when i used it. I'll prbably forget next time though.
And then there was this other comment, which is as follows:
I don't want to sound like I'm begging for more and more features, since it's awesome that you we have this at all. But it would be great -- ultimately -- to NOT parse greater-and-less-than symbols inside pre tags.
And all was well.
posted by Khalad at 6:07 PM on June 3, 2008


I'm trying to put this great new feature through its paces. Here's a chart a friend gave me of some family trees of characters in a fantasy novel. As you can see, it's close to working. But it doesn't quite work. I made sure there were only spaces -- no tabs.
                                                                                                                                     
                                                                     
George R.R. Martin's "Westeros"
                                             
MAIN STARKS AND TULLYS

                                                                                         |----------|
                                                                                         |             |
                                                                              Hoster Tulley   Brynden (Blackfish) Tully
                    |--------|                                                     |
                    |          |                                              -------------
                    |   Benjen Stark                                  |               |
?--------------Eddard Stark----------------------Catelyn Tully      Lysa (Tulley) ---- Jon Arryn (dead)
    |                           |                                                                               |
    |                           |                                                                           Robert
    |                  --------------------------------------      
John Snow       |         |      |          |                |
                Robb    Sansa   Arya    Brandon     Rickon
                
                
LANISTER AND BARATHEON


                            Tywin Lanister
                                |
                                |                                                          |-------------------------------|------------|
                --------------------------------                                   |                                       |               |
                |                   |                  |                                  |                                       |               |
            Tyrion            Jamime        Cersei -------------- (King) Robert Baratheon         Renly      Stannis
                                                        |
                                                        |
                                            -----------------------------
                                            |           |                      |
                                        Joffrey     Tommen      Myrcella
                                        
                                        
                                        
                                        
TARGARYEN (former rulers of Westeros, mostly dead)


                AERYS II (dead) ----- Rhaella (dead)
                (mad king)           |
                                           |
                        |--------------------|
                        |                         |
                    Viserys (exile)     Daenerys (exile)
                
posted by grumblebee at 7:49 AM on June 4, 2008


A chart from the JavE application


   ,''''''`.
   |       |
   |       |_______,''''''''|
   |       |       |        |
   '`'''''''       |        |
                   |        |
                   |        |
                    `'''':'''
                         `.        _,...._
                          |      ,'       `.
                           \   .'           `.
            ,'`--.          \  |             |
           ,'     `\         \|               |
          /         \         '|             |
         /           |__,,..,- \             /
        |'     /--''''          `._        ,'
         `.     \                  --...--'
          `..    |
             `'''









posted by grumblebee at 7:51 AM on June 4, 2008


Cool. That JavE chart looks exactly the way I made it.
posted by grumblebee at 7:51 AM on June 4, 2008


fire and ice ftw.

pb, point of order: we'll need to get this shit working on Recent Activity as well—I've spent the last day seeing the tests in here via that page and thinking you were all nuts. "But it doesn't work," I would cry to myself, and then scroll to the next thread.
posted by cortex (staff) at 8:04 AM on June 4, 2008


grumblebee: Could you link or pastebin that family tree?
posted by Pronoiac at 8:55 AM on June 4, 2008


heh, true cortex. Just wanted to get it working here in the safe confines of MetaTalk before infecting the other sites.
posted by pb (staff) at 9:35 AM on June 4, 2008


Pronoiac, here you go: http://pastebin.com/f4b6f326
posted by grumblebee at 9:53 AM on June 4, 2008


I spend like 90% of my time in RA, is all. If it's possible to be a hermit on a website, that right there is my cave. So I get...twitchy.

*twitches*

*twitches*
posted by cortex (staff) at 9:54 AM on June 4, 2008


MAIN STARKS AND TULLYS

                                                                |--------------------|
                                                                |                    |
                                                            Hoster Tulley       Brynden (Blackfish) Tully
                    |-----------|                               |
                    |           |                       --------------------
                    |       Benjen Stark                |                  |
?--------------Eddard Stark----------------------Catelyn Tully          Lysa (Tulley) ---- Jon Arryn (dead)
    |                           |                                                       |
    |                           |                                                     Robert
    |           -----------------------------------------               
John Snow       |         |      |          |           |
                Robb    Sansa   Arya    Brandon     Rickon
                
                
LANISTER AND BARATHEON


                            Tywin Lanister
                                |
                                |                                               |-------------------|-----------|
                ---------------------------------                               |                   |           |
                |               |               |                               |                   |           |
            Tyrion            Jamime        Cersei -------------- (King) Robert Baratheon         Renly      Stannis
                                                        |
                                                        |
                                            -------------------------
                                            |           |           |
                                        Joffrey     Tommen      Myrcella
                                        
                                        
                                        
                                        
TARGARYEN (former rulers of Westeros, mostly dead)


                AERYS II (dead) ----- Rhaella (dead)
                (mad king)        |
                                  |
                        |--------------------|
                        |                    |
                    Viserys (exile)     Daenerys (exile)
posted by pb (staff) at 9:59 AM on June 4, 2008


I copied the version at Pastebin, pasted here, looks good to me. (Maybe Pastebin does some cleaning?)
posted by pb (staff) at 9:59 AM on June 4, 2008


Wow. Worked.
posted by grumblebee at 10:03 AM on June 4, 2008


I assume you copied it from the pastebin text box, not from the HTML display, right?
posted by grumblebee at 10:04 AM on June 4, 2008


Yep, copied from the text box.
posted by pb (staff) at 10:06 AM on June 4, 2008


* waves at a twitching hermit in a cave in a friendly, reassuring way *
posted by Pronoiac at 10:40 AM on June 4, 2008


It's a cave in the Alps, by the way.

*swatches*
posted by cortex (staff) at 10:45 AM on June 4, 2008


*Riiiiicooooolaaaa*
posted by Pronoiac at 11:28 AM on June 4, 2008


It's Jaime Lannister, not "Jamime"
Why does Mr. Martin kill off so many of his main characters, anyway?
(I hope that's not a spoiler for anyone.)

Thanks for fixing <blockquote>!
posted by Crabby Appleton at 7:44 PM on June 8, 2008


Neat stuff, pb! It looks wrong in my "recent activity" page, but correct in the thread itself.

It's really cool to see this long-standing issue being resolved!
posted by knave at 9:36 PM on June 8, 2008


« Older The New York to Los Angeles Metafilter Goodwill...   |   AskMe data Newer »

You are not logged in, either login or create an account to post comments