This Forum has been archived

Forums: Admin Central Index Technical Help How to prevent the insertion of p- and span-tags?
Central's forums are a place for the community to help other members.
To contact staff directly or to report bugs, please use Special:Contact.
Note: This topic has been unedited for 1585 days. It is considered archived - the discussion is over. Do not add to unless it really needs a response.

I like wikicode. I really do. It's great. But.

For the past hour or two I've been trying to throw together a template that allows wikicode but prevents the wikicode parser from inserting all kinds of useless and unwanted p- and span-tags. The "creative" interpretation of the whitespace in my wikicode is starting to get on my nerves.

(What I'm trying to create is a div with two columns of links in it btw)

Can that be done? Can you have wiki links (and wiki headers etc.) but still complete control over the whitespace? -- Pecoes 20:20, March 1, 2012 (UTC)

I did find a hack. I neutralized the unwanted markup with:
#see-also span, #see-also p {
    padding: 0;
    margin: 0;
and handled the whitespace by throwing around with <br />s like nobody's business.
That seems to have worked. Still: If someone knows how to take control of the whitespace without resorting to hacks, please, do tell me! -- Pecoes 21:29, March 1, 2012 (UTC)
I'm not sure what you mean by creative interpretation of whitespace. You'd have to provide an example of what specific bad effects you are refering to. If your problem is with the rich text editor adding extraneous html tags (such as the strings of <p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; removed in this edit), you could use the AbuseFilter extension to prohibit edits that contain those kinds of errors.
If you want a two-column list of links for a "See also" section, you could use something like the wikipedia:Template:Column-count, which uses the CSS3 "column-count" property[1]. That way you wouldn't need separate parameters for each side, and your left and right list of links would automatically have balanced lengths. The only downside is that it doesn't work in all browsers. --Gardimuer { ʈalk } 18:38, March 3, 2012 (UTC)

Here's an example:

<div style="white-space: pre;">one

Now check out the source code of the result:


two three four five


Pecoes 18:52, March 3, 2012 (UTC)

I see what you mean. That is troublesome. --Gardimuer { ʈalk } 23:49, March 3, 2012 (UTC)
In an ideal world there would be a really simple solution to this:

[[working link]]

but that tag doesn't seem to exist. -- Pecoes 00:57, March 4, 2012 (UTC)
All new lines are treated as being a new paragraph. For your example above, you should use a <br/> tag for each new line of the div, or start the first line on the next line after starting the div.
An example here.
Second line.
Third. Notice no <p> blocks.

Second example.

This time I use line breaks instead.

This time, all lines are treated equally with <p> blocks.

Rappy 01:01, March 4, 2012 (UTC)
It's not unpredictable. I give you that. And it's true that you can suppress the insertion of paragraph tags with break tags. But that's an abuse of the break tag, isn't it? Shouldn't there be a tag that allows you to use whitespace as you see fit? That's what the pre tag does in HTML. But the pre tag in wikicode is a completely different beast. It leaves the line breaks intact, yes, but it also does what the nowiki tag does. And as if that wasn't too much already the pre tag also formats the output - badly of course. The wikicode pre tag is a bad idea gone horribly wrong. And because of that we have to do dumb bs like inserting lots and lots of break tags to trick the engine into emulating the HTML pre tag. -- Pecoes 01:55, March 4, 2012 (UTC)
The alternative is to do a log of "dumb bs" to get general wiki-code formatting. Have you tested this on Wikipedia too? I believe this is a 'fault' in MediaWiki's software interpreting what you are doing rather than Wikia's interpretation of the code. Rappy 02:19, March 4, 2012 (UTC)
No. I haven't tested the pre tag on Wikipedia. Would it make a difference if I found the same problem over there?
Sorry for the rant in my previous post btw. I'm not looking for someone to blame. I'm only interested in a solution. -- Pecoes 03:05, March 4, 2012 (UTC)

(Reset indent) Depends on what you're trying to do as to a possible solution. Maybe give a link to what you're wanting to avoid? Re: Wikipedia... if it gives the same output at Wikipedia, it's something the MediaWiki software is doing and has nothing to do with changes Wikia has made. If it doesn't, it may have been fixed/addressed in their upgrades from MediaWiki 1.16.5 -> 1.18.1. Rappy 06:50, March 4, 2012 (UTC

Researching the issue over at was good advice, Rappy! I did find something very useful at MetaWikiMedia:Help:Newlines_and_spaces#Rendering. Look at this:

which renders as:


Wow! A poetry extension! Who would have thought? Awesome! :) -- Pecoes 08:46, March 4, 2012 (UTC)
Hah. I forgot about that one. It's rarely used by anyone these days. Rappy 19:48, March 4, 2012 (UTC)