Test: Replacing Square Brackets in Blog Posts
For the ten years I've been running this site the square bracket has been the bane of my life.
I compose all of my blog posts in Windows Live Writer. Every now and then I include code snippets. If the code uses square brackets, which it invariably does, then it makes publishing the post a real pain in the backside.
I tend to use TextPad to create highlighted code, as it lets you copy as colour-coded HTML. Take this simple code nugget:
TextPad produces HTML that looks like this:
Nothing wrong with it, per se, but seasoned Domino-heads will see the problem immediately. If you stick this in to a Domino document then, when Domino outputs the content to the web, it will assume you want to turn on PassThru HTML mode. The results vary but at the very least you lose the square brackets and the code snippets becomes unintelligible.
The fix I've always used involves me launching Notes, finding the CodeStore database, opening it, finding the most recent blog document, opening it in ScanEZ, replacing square brackets with [ and ] before saving the document.
Now though, I've changed the Java Agent that Live Writer posts to and made it replace the brackets for me. Here's the test:
for (var i:uint = 0; i < people.length(); i++){ items.setItemAt(people[i], token + i); }
Fingers crossed, the code above will still have square brackets after I've posted.
Edit: Yay, it worked! Life just became a little easier!
For those interested the Java code is now ("content" is a Hashtable):
newPost.replaceItemValue("Body", content.get("description").toString() .replaceAll("\\[", "[") .replaceAll("\\]", "]") );
I can't believe I waited this long to do it...
And remember folks, allowing square brackets unmolested on comments opens a whole world of pain. Don't even go there.
Reply
How about using...
$$HTMLOptions
"DisablePassThruHTML=1"
to disable square bracket passthru completely?
Reply
I remember thinking about that but, for some reason, not using it. Possibly as there are parts of the *design* of the Forms which rely on the brackets through one hack or another.
Anyway, Jim, is that you? The same Jim I sat next to for a year at Merrill Lynch? You can't just turn up after ten years and post a comment like that. Where's the update on how life is treating you?
Reply
Show the rest of this thread