AskMe causes problems when posting code March 27, 2006 9:30 PM Subscribe
Problems Posting Code To Ask yet again.
I really wish AskMeFi handled code better. As in, handled HTML, JavaScript, Perl, whatever, with linebreaks and indenting preserved. Some people are smart enough to use the PRE tag, but they still need to escape the HTML brackets, and their code gets extra linebreaks added.
When I need to post code I pre-process it with a script now but the average person isn't that obsessive.
The "regular expressions are overkill" guy has a problem in his code, please note, as does the "screw the dom" guy.
I really wish AskMeFi handled code better. As in, handled HTML, JavaScript, Perl, whatever, with linebreaks and indenting preserved. Some people are smart enough to use the PRE tag, but they still need to escape the HTML brackets, and their code gets extra linebreaks added.
When I need to post code I pre-process it with a script now but the average person isn't that obsessive.
The "regular expressions are overkill" guy has a problem in his code, please note, as does the "screw the dom" guy.
IMO we should be using a wiki markup or reStructured Text.
posted by five fresh fish at 9:50 PM on March 27, 2006
posted by five fresh fish at 9:50 PM on March 27, 2006
regex dawg... regex
wah you deaf. boi i outta slap y0!
f0real playah
posted by Dreamghost at 10:05 PM on March 27, 2006
wah you deaf. boi i outta slap y0!
f0real playah
posted by Dreamghost at 10:05 PM on March 27, 2006
>screw the fuckin dom
Sorry for not referring to you by name, Mr STFDG.
At PerlMonks they make you enclose code in <code> tags, (how logical!) and they have a nice regular expression system which not only preserves formatting but fixes lines over a certain length which is another major problem with preformatted text.
posted by AmbroseChapel at 10:25 PM on March 27, 2006
Sorry for not referring to you by name, Mr STFDG.
At PerlMonks they make you enclose code in <code> tags, (how logical!) and they have a nice regular expression system which not only preserves formatting but fixes lines over a certain length which is another major problem with preformatted text.
posted by AmbroseChapel at 10:25 PM on March 27, 2006
Yes, perlmonks does handle code snippets better. I also think perlmonks deals with comment deletions much better than mefi.
posted by boo_radley at 11:08 PM on March 27, 2006
posted by boo_radley at 11:08 PM on March 27, 2006
[comment deleted]
posted by Dreamghost at 12:18 AM on March 28, 2006
posted by Dreamghost at 12:18 AM on March 28, 2006
It is possible, but not straightforward, to post properly indented code that is not double-spaced.
posted by Rhomboid at 1:21 AM on March 28, 2006
posted by Rhomboid at 1:21 AM on March 28, 2006
if (thingy) { do_thingy; } else { some_other_thingy; }
posted by popechunk at 5:14 AM on March 28, 2006 Sorry about that. I was trying to copy Rhomboid's example from the other post. If someone deleted the screwed up ones, that would be cool.
I typed the code all on one line, and inserted <br>s and spaces (not tabs) where indention needed to happen. I wrapped the whole thing in <pre> and <code>, and I did not preview my post.
Thanks for the tip, Rhomboid, I've always wondered how to do that. Someone should stick this in the wiki!
posted by popechunk at 5:19 AM on March 28, 2006
I typed the code all on one line, and inserted <br>s and spaces (not tabs) where indention needed to happen. I wrapped the whole thing in <pre> and <code>, and I did not preview my post.
Thanks for the tip, Rhomboid, I've always wondered how to do that. Someone should stick this in the wiki!
posted by popechunk at 5:19 AM on March 28, 2006
You can use the Textile or Markdown web forms at Textism or Daring Fireball to type your message, and then paste the HTML they spit out into the web form here.
Here is some code for example:
posted by chunking express at 6:22 AM on March 28, 2006
Here is some code for example:
myTimer.Start();
set<int> test_set;
for ( int i = 0; i < x; ++i )
test_set.insert(int_array[i]);
for ( int i = 0; i < x; ++i )
test_set.find(int_array[i]);
for ( int i = 0; i < x; ++i )
test_set.find(-int_array[i]);
for ( int i = 0; i < x; ++i )
test_set.erase(int_array[i]);
myTimer.Stop();
cout << '\t' << myTimer.Elapsed();
Here is some HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head profile="http://gmpg.org/xfn/1">
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="author" content="Ramanan Sivaranjan" />
<title>A Funkaoshi Production</title>
The tricky part is dealing with the extra paragraphs and break tags that get added by MeFi.posted by chunking express at 6:22 AM on March 28, 2006
Damn it. The preview does a better job then the post I guess.
posted by chunking express at 6:22 AM on March 28, 2006
posted by chunking express at 6:22 AM on March 28, 2006
Mod note: removed popechunk's experiments per request
posted by jessamyn (staff) at 6:24 AM on March 28, 2006
posted by jessamyn (staff) at 6:24 AM on March 28, 2006
Several things I can think about:
posted by Mr Stickfigure at 8:28 AM on March 28, 2006
- I think I quoted correctly. However, it was a pain in the butt because I would submit the code with an '&' character reference and it would get translated to a '&' in the text entry box on preview. So, I'd have to go back to the previous screen (where there was a bum preview) to post the comment. I'm guessing this is a bug, but from the little I can remember about HTML processing it may not be trivially solvable.
- Has there ever been talk about allowing people to post HTML directly without the standard mefi preprocessor? It seems that a lot (but certainly not all) of the people here have some rudimentary HTML skills and may prefer to not worry about where the translation engine adds newlines (etc.)
posted by Mr Stickfigure at 8:28 AM on March 28, 2006
Oh, and the reason this particular post was such a pain was that there were three levels of quoting: HTML in regex in "" string in HTML. In my experience, most people start having problems with two and some folks start having nervous breakdowns between three and four.
Of course, I also believe that most people are bad at recognizing all the levels of quoting they need to begin with....
posted by Mr Stickfigure at 8:34 AM on March 28, 2006
Of course, I also believe that most people are bad at recognizing all the levels of quoting they need to begin with....
posted by Mr Stickfigure at 8:34 AM on March 28, 2006
Mr Stickfigure wrote:
Has there ever been talk about allowing people to post HTML directly without the standard mefi preprocessor
It would get abused like crazy. Matt's been removing html features steadily, not adding them.
I think the secret is to compose your post in vi or notepad, and repeatedly copy&paste it into the preview, totally overwriting what you previewed, until it works.
Also, I don't think that quonsar's post was sincere.
posted by popechunk at 8:36 AM on March 28, 2006
Has there ever been talk about allowing people to post HTML directly without the standard mefi preprocessor
It would get abused like crazy. Matt's been removing html features steadily, not adding them.
I think the secret is to compose your post in vi or notepad, and repeatedly copy&paste it into the preview, totally overwriting what you previewed, until it works.
Also, I don't think that quonsar's post was sincere.
posted by popechunk at 8:36 AM on March 28, 2006
Sigh. (re: quonsar)
Perhaps there is a way to allow people to post "allowable" HTML without messing with it. It seems like such a system would be far easier to maintain than the current one which allows some HTML and performs HTML-ization on some textual syntax. I'd volunteer to do a draft of such a thing (and/or a draft of the
As to using another editor.... Yes, it makes sense, and yes it gets the job done, but it is also a pain in the butt. I used to have to do this on a work-related wiki and ended up hating the process of updating the page and, as a result, performing fewer updates.
posted by Mr Stickfigure at 10:27 AM on March 28, 2006
Perhaps there is a way to allow people to post "allowable" HTML without messing with it. It seems like such a system would be far easier to maintain than the current one which allows some HTML and performs HTML-ization on some textual syntax. I'd volunteer to do a draft of such a thing (and/or a draft of the
<code>
functionality) if somebody told me the appropriate language (though I'm pretty sure that there are at least a dozen people here with more qualifications in that domain).As to using another editor.... Yes, it makes sense, and yes it gets the job done, but it is also a pain in the butt. I used to have to do this on a work-related wiki and ended up hating the process of updating the page and, as a result, performing fewer updates.
posted by Mr Stickfigure at 10:27 AM on March 28, 2006
With all due respect, people posting the very complicated and fiddly ways in which they achieve code-y goodness is missing the point.
I can already do that, as I said. I pre-process all code because I've learned through experience it's the only way.
But practically on a daily basis, someone comes along in good faith and posts some code and ... there's a whole post wasted, or the page is suddenly 2000px longer than it needs to be.
So, to sum up, HTML isn't handled well, code in general isn't handled well, and what you see on preview isn't what you get on post.
What would be better than nothing would be some help on the subject.
posted by AmbroseChapel at 12:07 PM on March 28, 2006
I can already do that, as I said. I pre-process all code because I've learned through experience it's the only way.
But practically on a daily basis, someone comes along in good faith and posts some code and ... there's a whole post wasted, or the page is suddenly 2000px longer than it needs to be.
So, to sum up, HTML isn't handled well, code in general isn't handled well, and what you see on preview isn't what you get on post.
What would be better than nothing would be some help on the subject.
posted by AmbroseChapel at 12:07 PM on March 28, 2006
Or use a frigging Wiki syntax. Type *italics* instead of a bunch of angles and symbols makes it easier to use, less error-prone, and easier to read when editing one's work.
Here's a kickass_ way of indicating weblinks; and a good way[] of indicating footnotes.
[] Here's a footnote telling you how to do a web link: use a leading underscore.
_http://do.it.like this.
One can look at reStructured Text for a syntax that has been well-hammered-out this past five years or so.
posted by five fresh fish at 12:53 PM on March 28, 2006
Here's a kickass_ way of indicating weblinks; and a good way[] of indicating footnotes.
[] Here's a footnote telling you how to do a web link: use a leading underscore.
_http://do.it.like this.
One can look at reStructured Text for a syntax that has been well-hammered-out this past five years or so.
posted by five fresh fish at 12:53 PM on March 28, 2006
Or use a frigging Wiki syntax. Type italics instead of a bunch of angles and symbols makes it easier to use, less error-prone, and easier to read when editing one's work.
Here's a kickass way of indicating weblinks; and a good way1 of indicating footnotes.
1 Here's a footnote telling you how to do a web link: use a leading underscore.
One can look at reStructured Text for a syntax that has been well-hammered-out this past five years or so.
posted by five fresh fish at 12:57 PM on March 28, 2006
Here's a kickass way of indicating weblinks; and a good way1 of indicating footnotes.
1 Here's a footnote telling you how to do a web link: use a leading underscore.
One can look at reStructured Text for a syntax that has been well-hammered-out this past five years or so.
posted by five fresh fish at 12:57 PM on March 28, 2006
Wikimarkup/reStructured/Twikitext is fundamentally broken. *This* should be bold. /This/ should be italics.
Besides, HTML works fine and is more widely known. Fix the parsing of text in <pre> and/or <code> and we're good to go.
posted by majick at 1:11 PM on March 28, 2006
Besides, HTML works fine and is more widely known. Fix the parsing of text in <pre> and/or <code> and we're good to go.
posted by majick at 1:11 PM on March 28, 2006
I agree with majick 100%. To change to Wiki or any of the other markup schemes would be adding complexity instead of removing it.
The people posting code are people who already know code, by definition.
Fix the parsing of text in <pre> and/or <code> and we're good to go.
Exact, as they say, amundo.
posted by AmbroseChapel at 3:34 PM on March 28, 2006
The people posting code are people who already know code, by definition.
Fix the parsing of text in <pre> and/or <code> and we're good to go.
Exact, as they say, amundo.
posted by AmbroseChapel at 3:34 PM on March 28, 2006
Yeah stick with html. Wiki syntax is very difficult for programmers to optimise. You can't parse it using a state machine -- there's too many irregular exception to the syntax.
If people want formatted text they can get rich textareas and submit html that way.
(technically we have linebreaks converted to <br /> around here so it's not just html)
The people who are suggesting regexes for anything but trivially simple html are... well, it's been years and they haven't learnt so I hope they're killed with fire.
posted by holloway at 4:31 PM on March 28, 2006
If people want formatted text they can get rich textareas and submit html that way.
(technically we have linebreaks converted to <br /> around here so it's not just html)
The people who are suggesting regexes for anything but trivially simple html are... well, it's been years and they haven't learnt so I hope they're killed with fire.
posted by holloway at 4:31 PM on March 28, 2006
You are not logged in, either login or create an account to post comments
posted by moift at 9:50 PM on March 27, 2006