File: sgml-spell-filter-spec.pl

package info (click to toggle)
sgml-spell-checker 0.0.20040919-3
  • links: PTS
  • area: main
  • in suites: bullseye, buster, jessie, jessie-kfreebsd, lenny, sid, squeeze, stretch, wheezy
  • size: 148 kB
  • sloc: sh: 173; perl: 109; makefile: 2
file content (68 lines) | stat: -rw-r--r-- 1,290 bytes parent folder | download | duplicates (3)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
########################################################################
# SGML spell-check filter
#
# Copyright 2002 by Peter Eisentraut <peter_e@gmx.net>
########################################################################

use SGMLS;			# Use the SGMLS package.
use SGMLS::Output;		# Use stack-based output.

if ($ARGV[0]) {
    open(INFILE, $ARGV[0]) or die;
    @elements_skip = <INFILE>;
    chomp @elements_skip;
    close(INFILE);
}

#
# Element handler
#

sgml('start_element', sub {
    my ($element,$event) = @_;

    if (grep { uc($_) eq uc($element->name) } @elements_skip) {
        push_output('nul');
    } else {
        output(' ');
    }
});

sgml('end_element', sub {
    my ($element,$event) = @_;

    if (grep { uc($_) eq uc($element->name) } @elements_skip) {
        pop_output();
    } else {
        output(' ');
    }
});


#
# SDATA Handler
#

sgml('sdata', "");


#
# CDATA handler
#

sgml('cdata',sub {
    my ($data,$event) = @_;

    if (defined $event->file && defined $event->line
        && ($current_file ne $event->file || $current_line ne $event->line)) {
        $current_file = $event->file;
        $current_line = $event->line;
        output "\n# $current_file:$current_line\n";
    }

    $data =~ tr/\r\n//d;
    output "\n^$data";
});


1;