/usr/share/perl5/Lire/DocBookParser.pm is in lire 2:2.1.1-2.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | package Lire::DocBookParser;
use strict;
use base qw/Lire::XMLParser/;
=pod
=head1 NAME
Lire::XMLParser - Base DocBook parser.
=head1 SYNOPSIS
package MyParser;
use base qw/ Lire::XMLParser /;
=head1 DESCRIPTION
This package contains a Lire::XMLParser DocBook parser. It defines the
relevant C<_start>, C<_end> and C<_char> methods for the DocBook
subset used by Lire. All defined handlers have the form
C<dbk_I<name>_start>, C<dbk_I<name>_end> and C<dbk_I<name>_char> (when
the element accepts PCDATA content).
Its base functionality is to collect the DocBook markup for later use.
It will subclassed most of the time.
=pod
=head1 CLIENT METHODS
=head2 dbk_init()
Subclasses should call this method whenever the state of the DocBook
parse should start. This is called from the parse_start() method when
the parser is used standalone.
=cut
sub dbk_init {
$_[0]->init_collector( 'docbook' );
$_[0]->{'_dbk_processing'} = 1;
return;
}
=pod
=head2 dbk_string()
Returns the DocBook XML accumulated by the parser. This is returned
from parse_end() method when used standalone.
=cut
sub dbk_string {
$_[0]->{'_dbk_processing'} = 0;
return $_[0]->get_collector( 'docbook' );
};
=pod
=head1 XML SPECIFICATIONS METHODS IMPLEMENTATION
=head2 namespaces()
DocBook doesn't use namespace, so this method returns an empty hash reference.
=cut
sub namespaces {
return{};
}
=pod
=head2 elements_spec()
Returns the elements specification for the DocBook subset supported by
Lire.
=cut
our @gen_char_mix = qw/ PCDATA abbrev acronym emphasis foreignphrase phrase
quote trademark wordasword
action application classname methodname
interfacename exceptionname ooclass oointerface
ooexception
command computeroutput database email envar
errorcode errorname errortype errortext
filename function guibutton guiicon guilabel
guimenu guimenuitem guisubmenu
hardware interface keycap keycode
keycombo keysym literal constantmarkup menuchoice
mousebutton option optional parameter prompt property
replaceable returnvalue sgmltag
structfield structname symbol
systemitem token type userinput varname nonterminal
productname productnumber subscript superscript
constant markup
/;
our @inline_mix = ( @gen_char_mix, 'ulink', 'replaceable' );
our @lists_mix = qw/orderedlist itemizedlist variablelist/;
our @var_char_mix = qw/PCDATA replaceable/;
our @admonitions_mix = qw/caution warning note tip important /;
our @top_levels = ( 'para',
@Lire::DocBookParser::admonitions_mix,
@Lire::DocBookParser::lists_mix );
my %content_models =
(
# Inline elements
'abbrev' => [ 'PCDATA' ],
'acronym' => [ 'PCDATA' ],
'emphasis' => [ @inline_mix ],
'foreignphrase' => [ @inline_mix ],
'phrase' => [ @inline_mix ],
'quote' => [ @inline_mix ],
'trademark' => [ 'PCDATA' ],
'wordasword' => [ 'PCDATA' ],
'action' => [ @var_char_mix ],
'application' => [ @var_char_mix ],
'classname' => [ @var_char_mix ],
'constant' => [ @var_char_mix ],
'markup' => [ @var_char_mix ],
'methodname' => [ @var_char_mix ],
'interfacename' => [ @var_char_mix ],
'exceptionname' => [ @var_char_mix ],
'ooclass' => [ @var_char_mix ],
'oointerface' => [ @var_char_mix ],
'ooexception' => [ @var_char_mix ],
'command' => [ @var_char_mix ],
'computeroutput' => [ @var_char_mix ],
'database' => [ @var_char_mix ],
'email' => [ @var_char_mix ],
'envar' => [ @var_char_mix ],
'errorcode' => [ @var_char_mix ],
'errorname' => [ @var_char_mix ],
'errortype' => [ @var_char_mix ],
'errortext' => [ @var_char_mix ],
'filename' => [ @var_char_mix ],
'function' => [ @var_char_mix ],
'guibutton' => [ @var_char_mix ],
'guiicon' => [ @var_char_mix ],
'guilabel' => [ @var_char_mix ],
'guimenu' => [ @var_char_mix ],
'guimenuitem' => [ @var_char_mix ],
'guisubmenu' => [ @var_char_mix],
'hardware' => [ @var_char_mix ],
'interface' => [ @var_char_mix ],
'keycap' => [ @var_char_mix ],
'keycode' => [ @var_char_mix ],
'keycombo' => [ @var_char_mix ],
'keysym' => [ @var_char_mix ],
'literal' => [ @var_char_mix ],
'constantmarkup' => [ @var_char_mix ],
'menuchoice' => [ @var_char_mix ],
'mousebutton' => [ @var_char_mix ],
'option' => [ @var_char_mix ],
'optional' => [ @inline_mix ],
'parameter' => [ @var_char_mix],
'prompt' => [ @var_char_mix ],
'property' => [ @var_char_mix ],
'replaceable' => [ 'PCDATA' ],
'returnvalue' => [ @var_char_mix ],
'sgmltag' => [ @var_char_mix ],
'structfield' => [ @var_char_mix ],
'structname' => [ @var_char_mix ],
'symbol' => [ @var_char_mix ],
'systemitem' => [ @var_char_mix ],
'token' => [ @var_char_mix ],
'type' => [ @var_char_mix ],
'userinput' => [ @var_char_mix ],
'varname' => [ @var_char_mix ],
'nonterminal' => [ @var_char_mix ],
'productname' => [ @var_char_mix ],
'productnumber' => [ @var_char_mix ],
'subscript' => [ @var_char_mix ],
'superscript' => [ @var_char_mix ],
'trademark' => [ @var_char_mix ],
# Para
'para' => [ @inline_mix, @lists_mix, @admonitions_mix ],
# Special
'ulink' => [ @inline_mix ],
'title' => [ @inline_mix ],
'listitem' => [ 'para', @lists_mix, @admonitions_mix ],
'varlistentry' => [ 'term', 'listitem' ],
'term' => [ @inline_mix ],
# Lists
'orderedlist' => [ 'title', @admonitions_mix, 'para', 'listitem' ],
'itemizedlist' => [ 'title', @admonitions_mix, 'para', 'listitem' ],
'variablelist' => [ 'title', @admonitions_mix, 'para', 'varlistentry' ],
# Admonitions
'caution' => [ 'title', 'para', @lists_mix, @admonitions_mix ],
'important' => [ 'title', 'para', @lists_mix, @admonitions_mix ],
'note' => [ 'title', 'para', @lists_mix, @admonitions_mix ],
'tip' => [ 'title', 'para', @lists_mix, @admonitions_mix ],
'warning' => [ 'title', 'para', @lists_mix, @admonitions_mix ],
);
my $spec = {};
while ( my ( $name, $content ) = each %content_models ) {
my $s = { 'start' => "dbk_${name}_start",
'end' => "dbk_${name}_end",
'content' => $content };
$s->{'char'} = "dbk_${name}_char"
if ( grep { $_ eq 'PCDATA' } @$content );
$spec->{$name} = $s;
no strict 'refs';
while ( my ($name, $content) = each %$spec ) {
*{"dbk_${name}_start"} = \&dbk_element_start;
*{"dbk_${name}_char"} = \&dbk_element_char
if defined $s->{'char'};
*{"dbk_${name}_end"} = \&dbk_element_end;
}
}
sub elements_spec {
return { %$spec };
}
sub dbk_element_start {
my ( $self, $element, $attributes ) = @_;
$self->collect( 'docbook', $self->recognized_string() );
return;
}
sub dbk_element_end {
my ( $self, $element ) = @_;
$self->collect( 'docbook', $self->recognized_string() );
return;
}
sub dbk_element_char {
my ( $self, $text ) = @_;
$self->collect( 'docbook', $self->recognized_string() );
return;
}
sub ignorable_ws {
my ( $self, $text ) = @_;
$self->collect( 'docbook', $self->recognized_string() )
if $self->{'_dbk_processing'};
return;
}
sub parse_start {
$_[0]->dbk_init();
return;
}
sub parse_end {
return $_[0]->dbk_string();
}
1;
__END__
=pod
=head1 SEE ALSO
Lire::XMLParser(3pm), Lire::ReportParser::AsciiDocBookFormatter(3pm),
Lire::ReportParser::HtmlDocBookFormatter(3pm)
=head1 AUTHOR
Francis J. Lacoste <flacoste@logreport.org>
=head1 VERSION
$Id: DocBookParser.pm,v 1.4 2006/07/23 13:16:29 vanbaal Exp $
=head1 COPYRIGHT
Copyright (C) 2004 Stichting LogReport Foundation LogReport@LogReport.org
This file is part of Lire.
Lire is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program (see COPYING); if not, check with
http://www.gnu.org/copyleft/gpl.html.
=cut
|