On 6/23/06, Chad Perrin <perrin(a)apotheon.com> wrote:
(such as the suggested Javascript method, which
wouldn't work for
everyone, but would at least circumvent the technical issues with having
the parser do it).
A dev can correct me if I'm wrong, but I don't think there would be
any substantial difference between coding it to work on the Javascript
side vs. the PHP side. Either implementation would face the same
problems: you have to make sure it doesn't substitute anything in
wikilinks, URLs, SGML attributes/values, or preferably in any of the
default monospaced things (<tt>, <code>, <pre>, space-initial line),
plus perhaps some other stuff. If you can write that in Javascript,
you can write it in PHP instead and stick it in somewhere for Yet
Another Parser Pass™ to get much more consistency as well as
eliminating a large part of the objections to current solutions,
namely that they look ugly or confusing in wikitext.
On 6/23/06, Timwi <timwi(a)gmx.net> wrote:
Steve Bennett wrote:
Let's be honest here: space indented text is
*weird*. What's the
historical context behind it? Why is it monospaced, coloured,
surrounded with a border, and why doesn't it wrap? It's such an odd
layout choice for something so easy to do by accident.
This "weirdness" comes from the fact that this particular wiki markup is
not really defined in terms of what visible output it produces, but only
in terms of what HTML it produces -- namely <pre>.
I think his actual question was: "Why was an initial space, which a
newbie would commonly add unwittingly, chosen to have such drastic and
confusing effects?" The answer to that is slightly complicated.
The first point to realize is that HTML specifies that all leading
spaces are stripped by default, and other whitespace is compressed
into a single space (this is so HTML files aren't a nightmare to read,
with tons of tags squashed together lest sensible spacing format the
resulting document weirdly). So the most obvious choice would be to
just translate the spaces literally and have them vanish when the
browser renders them; most blogging tools, Web forums, etc. do this,
and MediaWiki is not an exception―try it yourself and see. (SMF forums
are the one exception I know of offhand; they translate spaces that
would otherwise be compressed into "non-breaking spaces", possibly
familiar to you as .)
So what to do with leading spaces? Well, one common and important use
for leading spaces is to make some kind of chart or diagram, to indent
elements so they fit together properly. HTML provides the <pre> tag
for that: it overrides the default space-compressing behavior and
PREserves all spaces, line breaks, etc. exactly as entered. So, if
you knew HTML, you could make such a chart with <pre>, but what if you
didn't? Well, with this markup, just try entering it and presto, it
will work, because your leading spaces clue the parser into the fact
that you want it to display with spacing preserved.
So that explains the monospacing and space-preservation. What about
the linebreaking? Well, same principle. If you're making a chart,
you definitely don't want a line to be chopped up into pieces just
because someone's using a small screen; it would totally ruin the
relational intent. Finally, the gray thing and the border are just a
minor stylistic decision, which isn't even decided by the parser but
rather by our stylesheet. You can change that for yourself by adding
something like "pre { background: transparent; border: none; }" to
your stylesheet.
Of course, it's true that some people get confused when they try to
manually indent their paragraphs, which doesn't work. But that's
easily fixable by a more experienced editor, so it's not a big deal.
Anyway, I hope that short essay explained things. ;)