[texhax] boldfacing words from a list
John Palmer
johnp at palmyra.uklinux.net
Fri Sep 29 21:16:28 CEST 2006
Maybe it's worth showing what a perl program to do this job would be like.
Add to the list called @vocabulary all the words you want distinguished.
No warranty !
#!/usr/bin/perl -w
use strict; # if you are a purist
my $before = '\vocabulary{';
my $after = '}';
my @vocabulary = ('word','another-word'); # alter this list as desired
my $i;
while (<>) # i.e. for each line of input
{
foreach $i(@vocabulary) # i.e. for each word in the vocabulary
{
$_ =~ s/(\W)(${i})(\W)/$1$before$2$after$3/gi; # word in middle of line
$_ =~ s/^(${i})(\W)/$before$1$after$2/i; # word at start of line
$_ =~ s/(\W)(${i})$/$1$before$2$after/i; # word at end of line
};
print $_; # i.e. output the altered line
};
# end.
--
John Palmer
Preston near Weymouth, Dorset, England
e-mail: johnp at bcs.org.uk (plain text preferred)
website: http://www.palmyra.uklinux.net/
More information about the texhax
mailing list