[pmwiki-users] Long-s Redux

Lars Eighner surname at larseighner.com
Sat Feb 17 14:18:29 CST 2018

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

#These are assorted text smoothers not all thoroughly tested.
#straight quote for ditto and seconds/inches
#straight apostrophe for minutes/feet
# make curly quotes
# curly single quote in contraction
# make single curly quotes --fails if quoted matterial ends in s
# m-dash
Markup( "mdash", '<ndash', "/---([^-])/", '—$1' );
# n-dash (beware [-- and --])
Markup( "ndash", '>_end', "/([^\\[])--([^-\\]])/", '$1–$2' );
# ellipsis
Markup( "...", '>end', "/\.\.\./", '…' );
##Just for medieval types
#old style etc.
Markup( "etc", '>_end', "/etc\./", '&c.' );
Markup( "Eetc", '>_end', "/Etc\./", '&c.' );

Laurence Eighner Hexamer
surname at larseighner.com

More information about the pmwiki-users mailing list