[pmwiki-users] How to get fmt=#titlespaced to not separate 'LyX'
christian.ridderstrom at gmail.com
christian.ridderstrom at gmail.com
Sun Aug 12 05:40:02 CDT 2007
On Sat, 11 Aug 2007, H. Fox wrote:
> On 8/11/07, christian.ridderstrom at gmail.com
> <christian.ridderstrom at gmail.com> wrote:
>> The LyX wiki site obviously uses the word 'LyX' (written like that). I'd
>> now like to use the pagelist formt #titlespaced, however all pages with
>> 'LyX' get split up in an unfortunate way. For instance, 'LyXSomePage'
>> becomes 'Ly X Some Page', rather than 'LyX Some Page'.
>>
>> Any ideas on how I can make the wiki treat 'LyX' as something that should
>> not have spaces inserted?
>
> The automatically generated title will be overridden if you explicitly
> specify a title, as in (:title LyX Some Page:) on LyXSomePage.
This is true, but requires that I (or the users) add a title directive to
a _lot_ of pages. For some reason 'LyX' is very popular in the name of the
pages on the LyX wiki..
Anyway, looking at the code, it seems I have to provide my own
function that 'spaces' names, and then let the function reference
$AsSpaceFunction refer to this function. The default function is AsSpaced:
function AsSpaced($text) {
$text = preg_replace("/([[:lower:]\\d])([[:upper:]])/", '$1 $2', $text);
$text = preg_replace('/([^-\\d])(\\d[-\\d]*( |$))/','$1 $2',$text);
return preg_replace("/([[:upper:]])([[:upper:]][[:lower:]\\d])/",
'$1 $2', $text);
}
The following works, but it's a bit of a hack:
#
# Introduce a special function that converts a text to a 'spaced'
# form, that prevents 'LyX' from being split up into 'Ly X'.
# This is a bit of a hack, as a name originally containing 'Ly__x__' will
# be converted to contain 'LyX ' instead.
#
function AsSpaced_preserving_LyX($text) {
$text = preg_replace("/(LyX *)/", "Ly__x__ ", $text);
$text = preg_replace("/([[:lower:]\\d])([[:upper:]])/", '$1 $2', $text);
$text = preg_replace('/([^-\\d])(\\d[-\\d]*( |$))/','$1 $2',$text);
$text = preg_replace("/([[:upper:]])([[:upper:]][[:lower:]\\d])/",
'$1 $2', $text);
return preg_replace("/Ly__x__ /", "LyX ", $text);
}
$AsSpacedFunction = 'AsSpaced_preserving_LyX';
cheers
/Christian
--
Christian Ridderström, +46-8-768 39 44 http://www.md.kth.se/~chr
More information about the pmwiki-users
mailing list