ſ achieved

It has always been a dream of mine to convert the medial esses in my posts to long esses, you know, the ones look like effs. The practice went out a long time ago (probably thanks in no small part to the confusion of ſ with f), but that's certainly no reason not to do it on my blog. You can read more about the long s at wikipedia or even better, Babelstone.

The code below is how I achieved it in JavaScript. JavaScript apparently doesn't have true heredocs, so the strange "CDATA" line is a hack I found online for how to mimic one. JavaScript does have regular expressions, otherwise I wouldn't have bothered. also, the "unmatch_xml" regex is to undo the damage done by the parser inside xml/html tags. "ſ" doesn't work inside URL or script strings.

var match_longs = "([^f])s([a-eg-z\-])";
var unmatch_xml = '(<[^>]*)ſ([^<]*>)';
var replace_longs = "$1ſ$2";
var replace_shorts = "$1s$2";
var reg_longs = new RegExp(match_longs, "g");
var reg_unlongs = new RegExp(unmatch_xml, "g");

var blogitembody = (<r><![CDATA[



var longs_blogitembody = blogitembody.replace(reg_longs,replace_longs).replace(reg_unlongs,replace_shorts);





]]>).toString(); var longs_blogitembody = blogitembody.replace(reg_longs2,replace_longs2).replace(reg_longs1,replace_longs1).replace(reg_nolongs,replace_shorts).replace(reg_unlongs,replace_shorts); // if (document.longs.check.checked==true) { document.write("
"); document.write("
"); // } else { // document.write(blogitembody); // } -->


Post a Comment

<< Home

   Subscribe to: Posts (Atom)