/usr/share/perl5/sgmlspl-specs/docbook2texi-spec.pl is in docbook-utils 0.6.14-3.3.
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 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 | =head1 NAME
docbook2texi-spec - convert DocBook Books to a Texinfo document
=head1 DESCRIPTION
This is a sgmlspl spec file that produces a Texinfo file
from DocBook markup.
=head1 LIMITATIONS
Trying docbook2info on non-DocBook or non-conformant SGML results in
undefined behavior. :-)
This program is a slow, dodgy Perl script.
=head1 COPYRIGHT
Copyright (C) 1998-1999 Steve Cheng <steve@ggi-project.org>
This program 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, or (at your option) any later
version.
You should have received a copy of the GNU General Public License along with
this program; see the file COPYING. If not, please write to the Free
Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
=cut
# $Id: docbook2texi-spec.pl,v 1.1 2000/07/21 20:22:30 rosalia Exp $
use SGMLS; # Use the SGMLS package.
use SGMLS::Output; # Use stack-based output.
use SGMLS::Refs;
########################################################################
# SGMLSPL script produced automatically by the script sgmlspl.pl
#
# Document Type: BOOK
# Edited by: me :)
########################################################################
$nocollapse_whitespace = 0; # Current whitespace collapse counter.
$newline_last = 1; # At beginning of line?
$skip_inline = 0;
$id_counter = 1;
$raw_cdata = 0;
$basename = shift || "db2texi";
sgml('start', sub {
$Refs = new SGMLS::Refs("$basename.refs");
});
sgml('end', sub {
$Refs->warn();
});
########################################################################
#
# Output helpers
#
########################################################################
sub save_cdata
{
$raw_cdata++;
push_output('string');
}
# Copied from docbook2man.
# Texinfo's newline rules aren't so stringent, so
# perhaps we can do away with at least some of these cases for speed.
sub texi_sgml
{
if(ref($_[1]) eq 'CODE') {
return &sgml;
}
my $s = $_[1];
$s =~ s/\\/\\\\/g;
$s =~ s/'/\\'/g;
# \n at the beginning means start at beginning of line
if($s =~ s/^\n//) {
$sub = 'sub { output "\n" unless $newline_last++; ';
if($s eq '') {
sgml($_[0], eval('sub { output "\n" unless $newline_last++; }'));
} elsif($s =~ /\n$/) {
sgml($_[0], eval("sub { output \"\\n\" unless \$newline_last++; output '$s'; }"));
} else {
sgml($_[0], eval("sub { output \"\\n\" unless \$newline_last; output '$s'; \$newline_last = 0; }"));
}
} else {
if($s =~ /\n$/) {
sgml($_[0], eval("sub { output '$s'; \$newline_last = 1; }"));
} else {
sgml($_[0], eval("sub { output '$s'; \$newline_last = 0; }"));
}
}
}
sub texi_output
{
$_ = shift;
if(s/^\n//) {
output "\n" unless $newline_last++;
}
return if $_ eq '';
output $_;
if(@_) {
output @_;
$newline_last = (pop(@_) =~ /\n$/);
} else {
$newline_last = ($_ =~ /\n$/)
}
}
# Fold lines into one, quote some characters
sub fold_string
{
$_ = shift;
for($_[0]) {
tr/\t/\n /;
s/\@/\@\@/g;
s/\{/\@\{/g;
s/\}/\@\}/g;
}
# Trim whitespace from beginning and end.
s/^ +//;
s/ +$//;
return $_;
}
# Another version of sgml(), for 'inline' @-commands,
# and prevent nesting them.
sub _inline
{
my ($gi, $tcmd) = @_;
$tcmd =~ s/\\/\\\\/g;
$tcmd =~ s/'/\\'/g;
sgml($gi, eval("sub { output '${tcmd}\{' unless \$raw_cdata or \$skip_inline++ }"));
$gi =~ s/^</<\//;
sgml($gi, eval("sub { output '}' unless \$raw_cdata or --\$skip_inline }"));
}
sub generate_id {
return "ID" . $id_counter++;
}
########################################################################
#
# Metadata
#
########################################################################
sub author_start {
if($_[0]->within('BOOKINFO')) {
save_cdata();
}
}
sub author_end {
if($_[0]->within('BOOKINFO')) {
texi_output('@author{' . fold_string(pop_output()) . "\}\n");
$raw_cdata--;
}
}
sgml('<AUTHOR>', \&author_start);
sgml('</AUTHOR>', \&author_end);
sgml('<EDITOR>', \&author_start);
sgml('</EDITOR>', \&author_end);
sgml('<COLLAB>', \&author_start);
sgml('</COLLAB>', \&author_end);
sgml('<CORPAUTHOR>', \&author_start);
sgml('</CORPAUTHOR>', \&author_end);
sgml('<OTHERCREDIT>', \&author_start);
sgml('</OTHERCREDIT>', \&author_end);
sgml('</FIRSTNAME>', ' ');
sgml('</SURNAME>', ' ');
sgml('</HONORIFIC>', ' ');
sgml('</LINEAGE>', ' ');
sgml('</OTHERNAME>', ' ');
sgml('</AFFILIATION>', ' ');
# Ignore content.
sgml('<CONTRIB>', sub { push_output('nul') });
sgml('</CONTRIB>', sub { pop_output });
sgml('<AUTHORBLURB>', sub { push_output('nul') });
sgml('</AUTHORBLURB>', sub { pop_output });
sgml('<DOCINFO>', sub { push_output('nul'); });
sgml('</DOCINFO>', sub { pop_output(); });
sgml('<REFSECT1INFO>', sub { push_output('nul'); });
sgml('</REFSECT1INFO>', sub { pop_output(); });
sgml('<REFSECT2INFO>', sub { push_output('nul'); });
sgml('</REFSECT2INFO>', sub { pop_output(); });
sgml('<REFSECT3INFO>', sub { push_output('nul'); });
sgml('</REFSECT3INFO>', sub { pop_output(); });
sgml('<TITLEABBREV>', sub { push_output('nul') });
sgml('</TITLEABBREV>', sub { pop_output() });
texi_sgml('<LEGALNOTICE>', "\n\@page\n\@vskip 0pt plus 1fill\n");
sgml('<BOOKINFO>', sub {
texi_output("\n\@titlepage\n");
texi_output('@title{', $doc_title, "\}\n");
});
#texi_sgml('</BOOKINFO>', "\n\@end titlepage\n");
texi_sgml('</BOOKINFO>', sub {
texi_output "\n\@end titlepage\n\n";
texi_output "\@node Top\n\@top\n\n";
# Generate top menu for BOOK.
$_[0]->parent->ext->{'output_toc'} = 1;
# This is so that elements below can find me.
$_[0]->parent->ext->{'id'} = $_[0]->parent->attribute('ID')->value || generate_id();
});
sgml('<TITLE>', \&save_cdata);
sgml('</TITLE>', sub {
my $title = fold_string(pop_output());
$raw_cdata--;
if($_[0]->in('BOOKINFO')) {
texi_output("\n\@subtitle{", $title, "\}\n");
}
elsif(exists $_[0]->parent->ext->{'title'}) {
# By far the easiest case. Just fold the string as
# above, and then set the parent element's variable.
$_[0]->parent->ext->{'title'} = $title;
}
elsif(exists $_[0]->parent->ext->{'nodesection'}) {
# Start new node, since we now know its title.
# This node.
$me = $_[0]->parent;
my $nodename = fold_string($me->attribute('XREFLABEL')->value) || $title;
$nodename =~ s/,/ /;
texi_output("\n\n\@node $nodename\n");
# The heading such as @chapter $title.
texi_output($me->ext->{'nodesection'}, " $title\n");
# This is so that elements below can find me.
my $id = $me->attribute('ID')->value || generate_id();
$me->ext->{'id'} = $id;
# Don't overwrite info from previous parse.
if($Refs->get($id) eq '') {
$Refs->put($id, $nodename);
# Add myself to parent node's list of nodes.
my $pid = $me->parent->ext->{'id'};
$Refs->put($pid, $Refs->get($pid) . ",$id");
}
}
else {
if($_[0]->in('BOOK')) {
$doc_title = $title;
}
output $title, "\n";
$newline_last++;
}
});
# Appendix
# Article
########################################################################
#
# Major sectioning elements
#
########################################################################
sgml('<BOOK>', "\\input texinfo\n\@settitle ");
texi_sgml('</BOOK>', "\n\n\@bye\n");
# Start a new section with new node.
# Most of the handling is at </TITLE>.
sub start_node
{
$_[0]->ext->{'nodesection'} = $_[1];
# Flag that the first child node ...
$_[0]->ext->{'output_toc'} = 1;
# ... need to output a list of nodes.
if($_[0]->parent->ext->{'output_toc'}) {
$_[0]->parent->ext->{'output_toc'} = 0;
my @nodes = split(/,/, $Refs->get($_[0]->parent->ext->{'id'}));
shift @nodes;
texi_output("\n\n\@menu\n");
foreach(@nodes) {
my ($nodename) = split(/,/, $Refs->get($_));
output "* ", $nodename, "::\n";
}
texi_output("\n\n\@end menu\n");
}
}
sgml('<PREFACE>', sub { start_node $_[0], '@chapter'; });
sgml('<CHAPTER>', sub { start_node $_[0], '@chapter'; });
sgml('<SECT1>', sub { start_node $_[0], '@section'; });
sgml('<SECT2>', sub { start_node $_[0], '@subsection'; });
sgml('<SECT3>', sub { start_node $_[0], '@subsubsection'; });
sgml('<SECT4>', sub { start_node $_[0], '@subsubsection'; });
sgml('<SECT5>', sub { start_node $_[0], '@subsubsection'; });
########################################################################
#
# Reference pages
#
########################################################################
sgml('<REFENTRY>', sub {
# Determine what it is under ...
# FIXME! Add more of these parents!
if($_[0]->in('CHAPTER')) {
start_node $_[0], '@section';
} elsif($_[0]->in('SECT1')) {
start_node $_[0], '@subsection';
} else {
# From Sect2 and after
start_node $_[0], '@subsubsection';
}
});
sgml('<REFENTRYTITLE>', sub {
if($_[0]->in('REFMETA')) {
save_cdata();
}
});
sgml('</REFENTRYTITLE>', sub {
if($_[0]->in('REFMETA')) {
my $title = fold_string(pop_output());
$raw_cdata--;
# This node.
my $me = $_[0]->parent->parent;
my $nodename = fold_string($me->attribute('XREFLABEL')->value) || $title;
$nodename =~ s/,/ /;
texi_output("\n\n\@node $nodename\n");
# The heading such as @chapter $title.
texi_output($me->ext->{'nodesection'}, " $title\n");
# This is so that elements below can find me.
my $id = $me->attribute('ID')->value || generate_id();
$me->ext->{'id'} = $id;
# Don't overwrite info from previous parse.
if($Refs->get($id) eq '') {
$Refs->put($id, $nodename);
# Add myself to parent node's list of nodes.
my $pid = $me->parent->ext->{'id'};
$Refs->put($pid, $Refs->get($pid) . ",$id");
}
}
});
sgml('<MANVOLNUM>', sub {
if($_[0]->in('REFMETA')) { push_output('nul') }
else { texi_output '(' }
});
sgml('</MANVOLNUM>', sub {
if($_[0]->in('REFMETA')) { pop_output() }
else { texi_output ')' }
});
sgml('<REFMISCINFO>', sub { push_output('nul') });
sgml('</REFMISCINFO>', sub { pop_output() });
sgml('<REFNAMEDIV>', sub {
$_[0]->ext->{'first_refname'} = 1;
# FIXME! Add more of these parents!
if($_[0]->parent->in('CHAPTER')) {
texi_output "\n\n\@unnumberedsubsec Name\n";
} else {
texi_output "\n\n\@unnumberedsubsubsec Name\n";
}
});
sgml('<REFNAME>', sub {
if($_[0]->parent->ext->{'first_refname'}) {
$_[0]->parent->ext->{'first_refname'} = 0;
return;
}
output ", ";
});
sgml('<REFPURPOSE>', " --- ");
# RefDescriptor
sgml('<REFSYNOPSISDIV>', sub {
# FIXME! Add more of these parents!
if($_[0]->parent->in('CHAPTER')) {
texi_output "\n\@unnumberedsubsec Synopsis\n";
} else {
texi_output "\n\@unnumberedsubsubsec Synopsis\n";
}
});
sgml('<REFSECT1>', sub {
# FIXME! Add more of these parents!
if($_[0]->parent->in('CHAPTER')) {
texi_output "\n\n\@unnumberedsubsec ";
} else {
texi_output "\\nn\@unnumberedsubsubsec ";
}
});
sgml('<REFSECT2>', sub { start_node $_[0], '@unnumberedsubsubsec' });
sgml('<REFSECT3>', sub { start_node $_[0], '@unnumberedsubsubsec' });
########################################################################
#
# Synopses
#
########################################################################
sgml('<FUNCSYNOPSIS>', sub { $skip_inline++ });
sgml('</FUNCSYNOPSIS>', sub { $skip_inline-- });
sgml('<CMDSYNOPSIS>', sub { $skip_inline++ });
sgml('</CMDSYNOPSIS>', sub { $skip_inline-- });
sgml('<FUNCPROTOTYPE>', "\n\n");
# Arguments to functions. This is C convention.
texi_sgml('<PARAMDEF>', '(');
texi_sgml('</PARAMDEF>', ');');
texi_sgml('<VOID>', '(void);');
## ARG: should be bold, but not needed.
#
########################################################################
#
# 'Useful highlighting'
#
########################################################################
_inline('<CITETITLE>', '@cite');
_inline('<EMAIL>', '@email');
_inline('<FIRSTTERM>', '@dfn');
_inline('<FILENAME>', '@file');
_inline('<ACCEL>', '@key');
_inline('<KEYCAP>', '@key');
_inline('<KEYCOMBO>', '@key');
_inline('<KEYSYM>', '@key');
_inline('<USERINPUT>', '@kbd');
_inline('<LITERAL>', '@samp');
_inline('<MARKUP>', '@samp');
_inline('<SGMLTAG>', '@samp');
_inline('<TOKEN>', '@samp');
_inline('<CLASSNAME>', '@code');
_inline('<ENVAR>', '@code');
_inline('<FUNCTION>', '@code');
_inline('<PARAMETER>', '@code'); # not always
_inline('<RETURNVALUE>', '@code');
_inline('<STRUCTFIELD>', '@code');
_inline('<STRUCTNAME>', '@code');
_inline('<SYMBOL>', '@code');
_inline('<TYPE>', '@code');
_inline('<ACRONYM>', '@sc');
_inline('<EMPHASIS>', '@emph');
# Only in certain contexts
#sgml('<REPLACEABLE>'
sgml('<OPTIONAL>', "[");
sgml('</OPTIONAL>', "]");
sgml('<COMMENT>', "[Comment: ");
sgml('</COMMENT>', "]");
# ACTION
# ALT
# AUTHOR
# AUTHORINITIALS
# ABBREV
# CITATION
# FOREIGNPHRASE
# PHRASE
# QUOTE
# WORDASWORD
# COMPUTEROUTPUT
# LITERAL
# MARKUP
# PROMPT
# RETURNVALUE
# SGMLTAG
# TOKEN
# DATABASE
# HARDWARE
# INTERFACE
# MEDIALABEL
# SYSTEMITEM
sgml('<CITEREFENTRY>', sub { $skip_inline++ });
sgml('</CITEREFENTRY>', sub { $skip_inline-- });
########################################################################
#
# 'Block' elements
#
########################################################################
sub para_start {
output "\n" unless $newline_last++;
if($_[0]->parent->ext->{'nobreak'}) {
# Usually this is the FIRST element of
# an @item, so we MUST not do a full
# paragraph break.
$_[0]->parent->ext->{'nobreak'} = 0;
} else {
output "\n";
}
}
# Actually applies to a few other block elements as well
sub para_end {
output "\n" unless $newline_last++;
}
sgml('<PARA>', \¶_start);
sgml('<SIMPARA>', \¶_end);
texi_sgml('<EXAMPLE>', "\n\@unnumberedsubsubsec ");
texi_sgml('</EXAMPLE>', "\n\n");
########################################################################
#
# Verbatim displays.
#
########################################################################
sub verbatim_on {
texi_output("\n\n");
texi_output("\@example\n") unless $no_collapase++;
}
sub verbatim_off {
texi_output("\n\n");
texi_output("\@end example\n") unless --$no_collapase;
}
texi_sgml('<PROGRAMLISTING>', \&verbatim_on);
texi_sgml('</PROGRAMLISTING>', \&verbatim_off);
texi_sgml('<SCREEN>', \&verbatim_on);
texi_sgml('</SCREEN>', \&verbatim_off);
texi_sgml('<LITERALLAYOUT>', \&verbatim_on);
texi_sgml('</LITERALLAYOUT>', \&verbatim_off);
texi_sgml('<SYNOPSIS>', \&verbatim_on);
texi_sgml('</SYNOPSIS>', \&verbatim_off);
########################################################################
#
# Admonitions and other 'outside flow'
#
########################################################################
## These are supposed to be set off from the text, so
## proper indentation is not so important.
#
#sub admonition_end {
# output "\n" unless $newline_last++;
# output ".sp\n";
#}
#
#$admonition_end = *admonition_end{CODE};
#
# FIXME! Lotsa things!
#sgml('<NOTE>', "\n\n\@cartouche\nNote: ");
#sgml('</NOTE>', "\n\n\@end cartouche\n");
#sgml('<WARNING>', "\n\n\@cartouche\nWarning: ");
#sgml('</WARNING>', "\n\n\@end cartouche\n");
#sgml('<TIP>', "\n\n\@cartouche\nTip: ");
#sgml('</TIP>', "\n\n\@end cartouche\n");
#sgml('<CAUTION>', "\n\n\@cartouche\nCaution: ");
#sgml('</CAUTION>', "\n\n\@end cartouche\n");
#sgml('<IMPORTANT>', "\n\n\@cartouche\nImportant: ");
#sgml('</IMPORTANT>', "\n\n\@end cartouche\n");
#sgml('<NOTE>', sub {
# output "\n" unless $newline_last++;
# output ".PP\n";
# output ".B Note: \n";
# $listitem_first = 1;
#});
#sgml('</NOTE>', $admonition_end);
########################################################################
#
# Lists
#
########################################################################
texi_sgml('<VARIABLELIST>', "\n\@table \@asis\n");
texi_sgml('</VARIABLELIST>', "\n\@end table\n");
texi_sgml('<ORDEREDLIST>', "\n\@enumerate\n");
texi_sgml('</ORDEREDLIST>', "\n\@end enumerate\n");
texi_sgml('<ITEMIZEDLIST>', "\n\@itemize \@bullet\n");
texi_sgml('</ITEMIZEDLIST>', "\n\@end itemize\n");
sgml('<VARLISTENTRY>', sub {
$_[0]->ext->{'first_term'} = 1;
});
sgml('<TERM>', sub {
if($_[0]->parent->ext->{'first_term'}) {
$_[0]->parent->ext->{'first_term'} = 0;
texi_output "\n\n\@item ";
} else {
texi_output "\n\n\@itemx ";
}
save_cdata();
});
sgml('</TERM>', sub {
output fold_string(pop_output()) . "\n";
$newline_last = 1;
$raw_cdata--;
});
sgml('<LISTITEM>', sub {
texi_output "\n\n\@item\n" unless $_[0]->in('VARLISTENTRY');
$_[0]->ext->{'nobreak'} = 1;
});
sgml('<SIMPLELIST>', sub {
$_[0]->ext->{'first_member'} = 1;
});
sgml('<MEMBER>', sub {
my $listtype = $_[0]->parent->attribute(TYPE)->value;
if($listtype =~ /Inline/i) {
if($_[0]->parent->ext->{'first_member'}) {
# If this is the first member don't put any commas
$_[0]->parent->ext->{'first_member'} = 0;
} else {
output ", ";
}
} elsif($listtype =~ /Vert/i) {
texi_output("\n\n");
}
});
########################################################################
#
# Stuff we don't know how to handle (yet)
#
########################################################################
# Address blocks:
# Credit stuff:
# ACKNO
# ADDRESS
# AFFILIATION
# ARTPAGENUMS
# ATTRIBUTION
# AUTHORBLURB
# AUTHORGROUP
# OTHERCREDIT
# HONORIFIC
# Other document metadata:
# Element: BOOKINFO
# Element: RELEASEINFO
# DocInfo
# ArtHeader
# Areas:
# AREA
# AREASET
# AREASPEC
texi_sgml('<BEGINPAGE>', "\n\@page\n");
#BeginPage
#IndexTerm
########################################################################
#
# Linkage, cross references
#
########################################################################
## Print the URL
sgml('<ULINK>', sub {
if($skip_inline++) { return; } # hopefully doesn't happen
output '@uref{', $_[0]->attribute('URL')->value, ', '
});
sgml('</ULINK>', sub {
output '}' unless --$skip_inline;
});
sgml('<XREF>', sub {
my $id = $_[0]->attribute('LINKEND')->value;
my ($nodename) = split(/,/, $Refs->get($id));
if($nodename) {
texi_output("\@xref\{$nodename\}");
} else {
$blank_xrefs++;
texi_output "[XRef to $id]";
}
});
# Anchor
########################################################################
#
# Other handlers
#
########################################################################
sgml('|[lt ]|', "<");
sgml('|[gt ]|', ">");
sgml('|[amp ]|', "&");
sgml('|[ndash ]|', "-");
#
# Default handlers (uncomment these if needed). Right now, these are set
# up to gag on any unrecognised elements, sdata, processing-instructions,
# or entities.
#
# sgml('start_element',sub { die "Unknown element: " . $_[0]->name; });
# sgml('end_element','');
sgml('cdata', sub
{
for($_[0]) {
s/\@/\@\@/g;
s/\{/\@\{/g;
s/\}/\@\}/g;
}
$newline_last = 0;
output $_[0];
});
sgml('re', sub
{
if($nocollapse_whitespace || !$newline_last) {
output "\n";
}
$newline_last = 1;
});
sgml('re', "\n");
sgml('sdata',sub { die "Unknown SDATA: " . $_[0]; });
sgml('pi',sub { die "Unknown processing instruction: " . $_[0]; });
sgml('entity',sub { die "Unknown external entity: " . $_[0]->name; });
sgml('start_subdoc',sub { die "Unknown subdoc entity: " . $_[0]->name; });
sgml('end_subdoc','');
# sgml('conforming','');
1;
|