Recently I asked about substituting long-s for s in pages.

I wrongly assumed this would require a callback function, which in general, it doesn't.

I got script suggests which sort of worked, but as one of the many tutorials I have reviews in resent days puts, substituting only in text parts using JavaScript is not trivial. Many attempts that seemed to work died in after the first inline element in the text. Moreover, long-s is not merely a matter of substituting every s in the text with long-s, but have variously defined contexts for making the substitution according to the clerical traditions or idiosyncrasies of the scribes. For rendering in print whether a particular font has suitable ligatures or digraphs is also a consideration.

For PmWiki, the most important thing is that the substitutions NOT be made when the action is edit. The reason for this seems simple in retrospect. Editing exposes the directives and variable names and if substitutions are made in these, the results are catastrophic. Also I found it best to avoid pages in groups which generally are no rendered publicly.

This is my result (along with some text-smoothing markup based on a recipes in the Cookbook but somewhat adapted. This takes a middle of the road approach to when to use long s, but can be easily adapted to other rules. Basically only s within words is changed and only the first of ss is changed. It is also easy to exclude the change when long s with the following letter is particularly unattractive. These could be shorter and faster if regex modifier g works, but it does not in some installations, so this is for the most general case.


global $pagename;
$pagename = ResolvePageName($pagename);
$group = PageVar($pagename, '$Group');
if( $group !== 'Site' && $group !== 'SiteAdmin' && $group !== 'PageAction'
   && $action != 'edit') {

#This is the long s line
Markup('longs','>_end','/\>([^<]*?)([A-Za-rt-z])s([A-Za-z])([^<]*?)\</',
      ">$1$2ſ$3$4<");


#These are assorted text smoothers not all thoroughly tested.
#straight quote for ditto and seconds/inches
Markup("ditto",'>_end',"/\>([^<]*?)(\s)\"(\s)([^<]*?)\</",'>$1$2&quot;$3$4<');
Markup("second",'>_end',"/\>([^<]*?)(\d)\"([^<]*?)\</",'>$1$2&quot;$3<');
#straight apostrophe for minutes/feet
Markup("minutes",'_end',"/\>([^<]*?)(\d)\'([^<]*?)\</",'>$1$2&#39;$3<');
# make curly quotes
Markup("curly",'>_end',"/\>([^<]*?)\"([^\"<]*?)\</", '>$1&#8220;$2&#8221;$3<');
# curly single quote in contraction
Markup("aasq",'_end',"/([A-Za-z])\'([A-Za-z])/",'>$1&#8217;$2');
# make single curly quotes --fails if quoted matterial ends in s
Markup("sq",'>_end',"/\>([^<]*?)(\W)'([^'<]*?)'([^<]*?)\</",
   '>$1$2&#8216;$3&#8217;$4<');
# m-dash
Markup( "mdash", '<ndash', "/---([^-])/", '&mdash;$1' );
# n-dash (beware [-- and --])
Markup( "ndash", '>_end', "/([^\\[])--([^-\\]])/", '$1&ndash;$2' );
# ellipsis
Markup( "...", '>end', "/\.\.\./", '&hellip;' );
##Just for medieval types
#old style etc.
Markup( "etc", '>_end', "/etc\./", '&amp;c.' );
Markup( "Eetc", '>_end', "/Etc\./", '&amp;c.' );
}

--
Laurence Eighner Hexamer
surn...@larseighner.com
_______________________________________________
pmwiki-users mailing list
pmwiki-users@pmichaud.com
http://www.pmichaud.com/mailman/listinfo/pmwiki-users

Reply via email to