-
Notifications
You must be signed in to change notification settings - Fork 791
Expand file tree
/
Copy pathaddmarkup
More file actions
executable file
·29 lines (23 loc) · 847 Bytes
/
addmarkup
File metadata and controls
executable file
·29 lines (23 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/local/bin/perl -w
#Add special markup to document
#- Add keyword "Example:" before examples for non-CSS UAs
# $id$
# Ian Jacobs (ij@w3.org)
use DB_File;
use lib 'bin';
use utils;
use English;
$PROG = substr($0, rindex($0, "/") + 1);
$USAGE = "Usage: $PROG input [output]\n";
if ($#ARGV >= 0) {$input = $ARGV[0]; shift;} else {die $USAGE;}
if ($#ARGV >= 0) {$output = $ARGV[0]; shift;} else {$output = '-';}
if ($#ARGV >= 0) {die $USAGE;}
#Copy file in memory
$buf = readfile($input);
$attrs = "\\s+class\\s*=\\s*\"?example\"?";
$buf =~ s/<div$attrs>/$&<P style="display:none">Example(s):<\/P>/sgio;
$attrs = "\\s+class\\s*=\\s*\"?illegal-example\"?";
$buf =~ s/<div$attrs>/$&<P style="display:none">Illegal example(s):<\/P>/sgio;
open(OUTPUT, "> $output") || die "Cannot open for output: $output\n";
print OUTPUT $buf;
close(OUTPUT);