So, like, i just C!ed this node that turned out to have a <pre> tag in it, and the front page got all fucked up, and some people started bitching in chatterbox about CoCed nodes overextending their space and saying CoC should restrict some html....
So i think "Hey! I've got a great idea! I'll dump some worthless, obvious code with a wordy writeup on edev and waste nate's time!" ... and, um, here it is.

I would like to propose that this line of code be added at what is now line 30 of the reallycool nodelet:

$text =~ s[</?pre>][]ig;

to strip out any <pre>s when the node is displayed on the front page.

So.. feel free to nuke this node anytime, but...
is this the kind of stuff edev was intended for? is this writeup the kind of thing you're inviting?
or should i crawl back in my hole now?

stop reading this

I have another line of code you might want to add right after the one above. It is an attempt to impose a Chatterbox-style word length limit that inserts spaces every 36 letters but does not take into account or touch html tags (Something i see happening a *lot* in the CB is that someone will hardlink to a node that contains a word longer than the limit, and the spaces will break the link up and it will point to the wrong thing. This is fine in the CB, but the CoC should probably be more dignified.)

I'm thinking now that this is just a really bad idea, which is why i moved it down here. It would more than likely be too computationally expensive to run every time the front page loads, and long words in CoC nodes really aren't that much of a problem, and you really should have just stopped reading at the HR above. But:

$text =~ s[(?:(<[^>]*>)|((?:[^\s<>]|\&[\w\#]+;){36}))][${\($2?"$2 ":$1)}]g;

(this attempts to treat html entities as individual letters, in case someone does something like post a big perl regexp such as, well, that one. it assumes everyone plays nicely and uses semicolons on their entities like they're supposed to. If you want it to be more flexible add a ? after the ; in the regexp, but that could cause bad things if we run across people who do crazy things like say &amplt in writeups. Oh, maybe the question mark should be in there. Whatever. Or maybe you should just leave out the html entity bit altogether, which would be
$text =~ s[(?:(<[^>]*>)|([^\s<>]{36}))][${\($2?"$2 ":$1)}]g;
Or maybe none of this matters, or maybe there's some infinitely more readable way i could have done this using m??, or maybe it would be better to use the semistandard <WBR> anyway, or maybe i should learn how to do extended regexps. Whatever! Augh.

I'm tired. Sleep tonight.

Log in or register to write something here or to contact authors.