bin/jw.in | 4 helpers/docbook2man-spec.pl | 1119 +++++++++++++++++++++++++++----------------- 2 files changed, 713 insertions(+), 410 deletions(-)
New commits: commit 73cfa50a2416220e9f93fdf89737178e78c3ee52 Author: OndÅej VaÅ¡Ãk ovasik@redhat.com Date: Tue Feb 1 15:37:31 2011 +0100
bin/jw.in - fix jw script to find SGML_BASE_DIR evein with grep with colors(rhbz #473278)
diff --git a/bin/jw.in b/bin/jw.in index 4bfb312..ff12036 100644 --- a/bin/jw.in +++ b/bin/jw.in @@ -81,9 +81,9 @@ SGML_CATALOGS_DIR="/etc/sgml" if [ -f "$SGML_CONF" ] then RE='^[:space:]*SGML_BASE_DIR[:space:]*=[:space:]*' - SGML_BASE_DIR=`grep $RE $SGML_CONF | sed "s/$RE//"` + SGML_BASE_DIR=`grep --color=never $RE $SGML_CONF | sed "s/$RE//"` RE='^[:space:]*SGML_CATALOGS_DIR[:space:]*=[:space:]*' - SGML_CATALOGS_DIR=`grep $RE $SGML_CONF | sed "s/$RE//"` + SGML_CATALOGS_DIR=`grep --color=never $RE $SGML_CONF | sed "s/$RE//"` fi
# Set frontend to use
commit 21e6e85f8fe8343a277ac9780d9e68d4a864adc6 Author: OndÅej VaÅ¡Ãk ovasik@redhat.com Date: Tue Feb 1 15:32:25 2011 +0100
docbook2man-spec.pl - update docbook2man-spec.pl to latest version
diff --git a/helpers/docbook2man-spec.pl b/helpers/docbook2man-spec.pl index 8e46a1e..6717a06 100644 --- a/helpers/docbook2man-spec.pl +++ b/helpers/docbook2man-spec.pl @@ -1,45 +1,26 @@ =head1 NAME
-docbook2man-spec - convert DocBook RefEntries to Unix manpages +docbook2man-spec.pl - convert DocBook RefEntries to Unix manpages
=head1 SYNOPSIS
-The SGMLSpm package from CPAN. This contains the sgmlspl script which -is used to grok this file. Use it like this: +The sgmlspl script from the SGMLSpm Perl module must be used to run +this script. Use it like this:
nsgmls some-docbook-document.sgml | sgmlspl docbook2man-spec.pl
+See man page or included DocBook documentation for details. + =head1 DESCRIPTION
This is a sgmlspl spec file that produces Unix-style -manpages from RefEntry markup. - -See the accompanying RefEntry man page for 'plain new' documentation. :) - -=head1 LIMITATIONS - -Trying docbook2man on non-DocBook or non-conformant SGML results in -undefined behavior. :-) - -This program is a slow, dodgy Perl script. - -This program does not come close to supporting all the possible markup -in DocBook, and will produce wrong output in some cases with supported -markup. - -=head1 TODO - -Add new element handling and fix existing handling. Be robust. -Produce cleanest, readable man output as possible (unlike some -other converters). Follow Linux man(7) convention. -If this results in added logic in this script, -that's okay. The code should still be reasonably organized. - -Make it faster. If Perl sucks port it to another language. +man pages from DocBook RefEntry markup.
=head1 COPYRIGHT
-Copyright (C) 1998-1999 Steve Cheng steve@ggi-project.org +Copyright (C) 1998-2001 Steve Cheng stevecheng@users.sourceforge.net + +Copyright (C) 1999 Thomas Lockhart lockhart@alumni.caltech.edu
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 @@ -52,12 +33,13 @@ Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
=cut
-# $Id: docbook2man-spec.pl,v 1.10 2003/06/10 08:30:30 twaugh Exp $ +# $Id: docbook2man-spec.pl,v 1.11 2010/10/04 10:23:31 ovasik 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 # @@ -65,9 +47,41 @@ use SGMLS::Refs; # Edited by: me :) ########################################################################
+ $write_manpages = 0; $blank_xrefs = 0;
+$default_sect = "1"; +$default_date = `date "+%d %B %Y"`; +$cite_numeral_only = 1; + +while (@ARGV) { + my $arg = shift @ARGV; + if ($arg eq "--section") { + $default_sect = shift @ARGV || die "$arg requires an argument\n"; + } elsif ($arg eq "--date") { + $default_date = shift @ARGV || die "$arg requires an argument\n"; + } elsif ($arg eq "--lowercase") { + $lowercase_names = 1; + } elsif ($arg eq "--preserve-case") { + $lowercase_names = 0; + } elsif ($arg eq "--cite-numeral-only") { + $cite_numeral_only = 1; + } elsif ($arg eq "--nocite-numeral-only") { + $cite_numeral_only = 0; + } elsif ($arg eq "--help") { + print "Usage: $0", + " [ --section <label> ]", + " [ --date <string> ]", + " [ --lowercase | --preserve-case ]", + " [ --cite-numeral-only | --nocite-numeral-only ]", + "\n"; + exit; + } else { + die "unrecognized switch $arg; try $0 --help\n"; + } +} + sgml('start', sub { push_output('nul'); $raw_cdata = 1; # Makes it a bit faster. @@ -75,24 +89,64 @@ sgml('start', sub { # Links file open(LINKSFILE, ">manpage.links");
- $Refs = new SGMLS::Refs("manpage.refs"); + $Refs = new SGMLS::Refs("manpage.refs", "manpage.log"); }); sgml('end', sub { close(LINKSFILE); + + # Explicitly invoke destructor, + # otherwise cache file may not get written! + # Thomas Lockhart, 1999-08-03, perl-5.004, RedHat5.2 + undef $Refs; + if($blank_xrefs) { - print STDERR "Warning: output contains unresolved XRefs\n"; + warn "Warning: output contains unresolved XRefs\n"; } });
- - ######################################################################## # # Output helpers # ########################################################################
+# Remove leading and trailing blanks. + +sub StripString +{ + my $str = shift; + + $str = $1 if ($str =~ m#^\s*(\S.*)#); + $str = $1 if ($str =~ m#^(.*\S)\s*$#); + + return $str; +} + +# Generate a good file name, for given manpage title and manvolnum +# (cdata content). +# Cleanup whitespace and convert to lower case if required. + +sub FileInfo +{ + my $title = StripString(shift); + my $volnum = StripString(shift); + + $title = lc $title if $lowercase_names; + + $title =~ tr/ /_/; + $volnum =~ tr/ /_/; + + my $sectcite = $volnum; + # The 'package name' part of the section should + # not be used when citing it. + if ($cite_numeral_only) { + $sectcite = $1 if ($volnum =~ /^([0-9]+)/); + } + + return ("$title.$volnum", "$title($sectcite)"); +} + # Our own version of sgml() and output() to allow simple string output # to play well with roff's stupid whitespace rules.
@@ -103,31 +157,20 @@ sub man_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; }")); - } - } + sgml($_[0], eval("sub { man_output '$s' }")); }
sub man_output { + if($separator eq 'full') { + output "\n" unless $newline_last++; + output ".PP\n"; + $separator = ''; + } + $_ = shift; if(s/^\n//) { output "\n" unless $newline_last++; @@ -152,8 +195,9 @@ sub fold_string s/\/\\/g; s/"/\&"/g;
- # Change tabs to spaces - tr/\t\n/ /; + # Change tabs and newlines to spaces + # The newlines will be swallowed later while trimming + tr/[\t\n]/ /;
# Trim whitespace from beginning and end. s/^ +//; @@ -175,7 +219,7 @@ sub bold_on() if($fontstack[$#fontstack] ne 'bold') { if(!$raw_cdata) { output '\fB'; - $newline_last = 0; + #$newline_last = 0; } } push(@fontstack, 'bold'); @@ -187,7 +231,7 @@ sub italic_on() if($fontstack[$#fontstack] ne 'italic') { if(!$raw_cdata) { output '\fI'; - $newline_last = 0; + #$newline_last = 0; } } push(@fontstack, 'italic'); @@ -205,15 +249,11 @@ sub font_off() elsif($lastfont eq 'italic') { output '\fI'; } else { output '\fR'; } - $newline_last = 0; + #$newline_last = 0; } }
- - - - ######################################################################## # # Manpage management @@ -237,13 +277,26 @@ sgml('<REFENTRY>', sub { # it to a string and process it, etc. @fontstack = (); # Fonts being activated. + $list_nestlevel = 0; # Indent certain nested content. + + # Separator to use between 'elements' in the content of a + # paragraph (usually). This makes sure that PCDATA after a list + # in a PARA gets a break in between and not become part of the + # last listitem. Note that we can't do it after the list ends, + # because often the list ends the paragraph and we'll get an + # extra break. Anything that changes the separator status from + # the default should also save its last state in the parent + # element's ext, but I'm not going to explain further. It's a + # gross hack and almost guaranteed to fail in unforseen cases. + # The only way to avoid all this is to use a tree/grove model, which + # we're _not_ doing. + $separator = ''; + $manpage_title = ''; # Needed for indexing. $manpage_sect = ''; @manpage_names = (); $manpage_misc = ''; - - $list_nestlevel = 0; # Indent certain nested content.
# check refentry's language if(defined($_[0]->attribute('LANG')->value)) { @@ -258,30 +311,26 @@ sgml('</REFENTRY>', sub { output "\n"; } - $write_manpages = 0; $raw_cdata = 1; push_output('nul'); + + $write_manpages = 0; });
sgml('</REFMETA>', sub { - if ($manpage_lang) { - push_output('file', "$manpage_title.$manpage_lang.$manpage_sect"); - } else { - push_output('file', "$manpage_title.$manpage_sect"); - } + my ($filename, $citation) = + FileInfo($manpage_title, $manpage_sect || $default_sect); + + push_output('file', $filename);
- output <<_END_BANNER; -.\" This manpage has been automatically generated by docbook2man -.\" from a DocBook document. This tool can be found at: -.\" http://shell.ipoline.com/~elmert/comp/docbook2X/ -.\" Please send any bug reports, improvements, comments, patches, -.\" etc. to Steve Cheng <steve@ggi-project.org>. + output <<'_END_BANNER'; +." auto-generated by docbook2man-spec from docbook-utils package _END_BANNER
- my $manpage_date = `date "+%d %B %Y"`; - + my $manpage_date = $_[0]->parent->ext->{'date'} || $default_date; + output '.TH "'; - + # If the title is not mixed-case, convention says to # uppercase the whole title. (The canonical title is # lowercase.) @@ -292,7 +341,7 @@ _END_BANNER } output '" "', fold_string($manpage_sect), - '" "', fold_string(`date "+%d %B %Y"`), + '" "', fold_string($manpage_date), '" "', $manpage_misc, '" "', $manpage_manual, ""\n"; @@ -300,19 +349,16 @@ _END_BANNER $newline_last = 1;
# References to this RefEntry. - my $id = $_[0]->parent->attribute('ID')->value; - if($id ne '') { - # The 'package name' part of the section should - # not be used when citing it. - my ($sectnum) = ($manpage_sect =~ /([0-9]*)/); - - if($_[0]->parent->attribute('XREFLABEL')->value eq '') { - $Refs->put("refentry:$id", "$manpage_title($sectnum)"); - } else { - $Refs->put("refentry:$id", - $_[0]->parent->attribute('XREFLABEL')->value . - "($sectnum)"); + if(defined($_[0]->parent->attribute('ID')->value)) { + my $id = $_[0]->parent->attribute('ID')->value; + + # Append XREFLABEL content to citations. + if(defined($_[0]->parent->attribute('XREFLABEL')->value)) { + $citation = $_[0]->parent->attribute('XREFLABEL')->value . + ' [' . $citation . ']'; } + + $Refs->put("refentry:$id", $citation); } });
@@ -330,6 +376,11 @@ sgml('</REFENTRYTITLE>', sub { $manpage_title = pop_output(); } else { font_off(); } + + if (defined($_[0]->attribute('ID')->value)) { + my $id = $_[0]->attribute('ID')->value; + $Refs->put("refentrytitle:$id", $manpage_title); + } });
sgml('<MANVOLNUM>', sub { @@ -356,13 +407,20 @@ sgml('</REFMISCINFO>', sub {
# NAME section +#man_sgml('<REFNAMEDIV>', "\n.SH NAME\n"); man_sgml('<REFNAMEDIV>', sub { - my %words = qw( fr NOM es NOMBRE de NAME ); - if (defined($_[0]->attribute('LANG')->value)) { - my $id = $_[0]->attribute('LANG')->value; - my $ad = $words{$id}; - output("\n.SH $ad\n");} - else {output("\n.SH NAME\n");} + my %text = { fr=>'NOM', es=>'NOMBRE', pl=>'NAZWA' }; + + if(defined $text{lc($manpage_lang)}) + { + man_output "\n.SH " . $text{lc($manpage_lang)} . "\n"; + } elsif(defined $_[0]->attribute('LANG') and + defined $text{lc($_[0]->attribute('LANG')->value)}) + { + man_output "\n.SH " . $text{lc($_[0]->attribute('LANG'))} . "\n"; + } else { + man_output "\n.SH NAME\n"; + } });
sgml('<REFNAME>', &save_cdata); @@ -398,16 +456,20 @@ man_sgml('<REFCLASS>', "\n.sp\n"); #RefDescriptor
- - - ######################################################################## # # SYNOPSIS section and synopses # ########################################################################
-man_sgml('<REFSYNOPSISDIV>', "\n.SH SYNOPSIS\n"); +#man_sgml('<REFSYNOPSISDIV>', "\n.SH SYNOPSIS\n"); +man_sgml('<REFSYNOPSISDIV>', sub { + if ($manpage_lang eq "pl") { man_output "\n.SH SK£ADNIA\n"; } + # waits for another languages + #elsif ($manpage_lang eq "xx") { man_output "\n.SH xxxxxxx\n"; } + else { man_output "\n.SH SYNOPSIS\n"; } +}); + man_sgml('</REFSYNOPSISDIV>', "\n");
## FIXME! Must be made into block elements!! @@ -417,63 +479,25 @@ man_sgml('</REFSYNOPSISDIV>', "\n"); #sgml('</CMDSYNOPSIS>', &font_off);
man_sgml('<FUNCSYNOPSIS>', sub { - man_output("\n.sp\n"); + man_output("\n.nf\n"); bold_on(); }); man_sgml('</FUNCSYNOPSIS>', sub { font_off(); - man_output("\n"); + man_output "\n.fi"; });
-man_sgml('<CMDSYNOPSIS>', "\n\n"); -man_sgml('</CMDSYNOPSIS>', "\n\n"); +man_sgml('<CMDSYNOPSIS>', "\n.sp\n"); +man_sgml('</CMDSYNOPSIS>', "\n");
man_sgml('<FUNCPROTOTYPE>', "\n.sp\n");
# Arguments to functions. This is C convention. -sub paramdef -{ - if($_[0]->parent->ext->{'inparams'}) { - output ', '; - } else { - output ' ('; - $_[0]->parent->ext->{'inparams'} = 1; - } -} -man_sgml('<PARAMDEF>', ¶mdef); -man_sgml('</FUNCPROTOTYPE>', ");\n"); -man_sgml('<VOID>', "(void"); -man_sgml('<VARARGS>', "(..."); - +man_sgml('<PARAMDEF>', '('); +man_sgml('</PARAMDEF>', ");\n"); +man_sgml('<VOID>', "(void);\n");
-sub group_start -{ - if(not $_[0]->parent->in('TERM')) { - if($_[0]->attribute('CHOICE')->value =~ /opt/i) { - output ' ['; - } elsif($_[0]->attribute('CHOICE')->value =~ /req/i) { - output ' {'; - } - } - $_[0]->ext->{'count'} = 1; -} -sub group_end -{ - if($_[0]->attribute('REP')->value =~ /^Repeat/i) { - italic_on(); - output ' ...'; - font_off(); - } - if(not $_[0]->parent->in('TERM')) { - if($_[0]->attribute('CHOICE')->value =~ /opt/i) { - output ' ]'; - } elsif($_[0]->attribute('CHOICE')->value =~ /req/i) { - output ' }'; - } - } -} - sub arg_start { # my $choice = $_[0]->attribute('CHOICE')->value; @@ -481,13 +505,10 @@ sub arg_start # The content model for CmdSynopsis doesn't include #PCDATA, # so we won't see any of the whitespace in the source file, # so we have to add it after each component. - output ' '; + man_output ' ';
- if($_[0]->in('GROUP')) { - output '| ' if $_[0]->parent->ext->{'count'} > 1; - $_[0]->parent->ext->{'count'}++; - } elsif($_[0]->attribute('CHOICE')->value =~ /opt/i) { - output '[ '; + if($_[0]->attribute('CHOICE')->value =~ /opt/i) { + man_output '[ '; } bold_on(); } @@ -496,24 +517,24 @@ sub arg_end font_off(); if($_[0]->attribute('REP')->value =~ /^Repeat/i) { italic_on(); - output ' ...'; + man_output '...'; font_off(); } - if($_[0]->attribute('CHOICE')->value =~ /opt/i and - not $_[0]->in('GROUP')) { - output ' ]'; + if($_[0]->attribute('CHOICE')->value =~ /opt/i) { + man_output ' ] '; } }
sgml('<ARG>', &arg_start); sgml('</ARG>', &arg_end); -sgml('<GROUP>', &group_start); -sgml('</GROUP>', &group_end); +sgml('<GROUP>', &arg_start); +sgml('</GROUP>', &arg_end);
sgml('<OPTION>', &bold_on); sgml('</OPTION>', &font_off);
-man_sgml('<SBR>', "\n "); +# FIXME: This is one _blank_ line. +man_sgml('<SBR>', "\n\n");
######################################################################## @@ -524,9 +545,9 @@ man_sgml('<SBR>', "\n ");
# The name of the section is handled by TITLE. This just sets # up the roff markup. -man_sgml('<REFSECT1>', "\n.SH "); -man_sgml('<REFSECT2>', "\n.SS "); -man_sgml('<REFSECT3>', "\n.SS "); +man_sgml('<REFSECT1>', sub { $separator = ''; man_output "\n.SH "}); +man_sgml('<REFSECT2>', sub { $separator = ''; man_output "\n.SS "}); +man_sgml('<REFSECT3>', sub { $separator = ''; man_output "\n.SS "});
######################################################################## @@ -541,16 +562,17 @@ sgml('<TITLE>', sub { } save_cdata(); }); -sgml('</TITLE>', sub { +sgml('</TITLE>', sub { + my ($element, $event) = @_; my $title = fold_string(pop_output()); $raw_cdata--; - if($_[0]->in('REFERENCE') or $_[0]->in('BOOK')) { + if($element->in('REFERENCE') or $element->in('BOOK')) { # We use TITLE of enclosing Reference or Book as manual name $manpage_manual = $title; $write_manpages = 0; } - elsif(exists $_[0]->parent->ext->{'title'}) { + elsif(exists $element->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; @@ -559,27 +581,63 @@ sgml('</TITLE>', sub { # If the parent element's handlers are lazy, # output the folded string for them :) # We assume they want uppercase and a newline. - output '"', uc($title), ""\n"; - $newline_last = 1; + man_output '"', uc($title), ""\n"; + } + + if (defined($element->attribute('ID')->value)) { + my $id = $_[0]->attribute('ID')->value; + $Refs->put("title:$id", $title); + } + + my ($filename, $citation) = + FileInfo($manpage_title, $manpage_sect || $default_sect); + my $parentid = $element->parent->attribute('ID')->value; + if ($parentid and ($element->in('REFSECT1') or $element->in('REFSECT2') or $element->in('REFSECT3'))) { + $Refs->put("refsect:$parentid", "$citation"); + } +}); + +sgml('<ATTRIBUTION>', sub { + if($_[0]->in('BLOCKQUOTE')) { + push_output('string'); } }); +sgml('</ATTRIBUTION>', sub { + if($_[0]->in('BLOCKQUOTE')) { + $_[0]->parent->ext->{'attribution'} = pop_output(); + } else { + # For an Epigraph. + man_output "\n\n"; + } +}); + +sgml('<DATE>', sub { + save_cdata(); +}); +sgml('</DATE>', sub { + $_[0]->parent->parent->ext->{'date'} = fold_string(pop_output()); + $raw_cdata--; +});
-sgml('<ATTRIBUTION>', sub { push_output('string') }); -sgml('</ATTRIBUTION>', sub { $_[0]->parent->ext->{'attribution'} = pop_output(); }); +sub ignore_content { push_output 'nul'; } +sub restore_content { pop_output(); }
+sgml('<DOCINFO>', &ignore_content); +sgml('</DOCINFO>', &restore_content); +sgml('<REFSYNOPSISDIVINFO>', &ignore_content); +sgml('</REFSYNOPSISDIVINFO>', &restore_content); +sgml('<REFSECT1INFO>', &ignore_content); +sgml('</REFSECT1INFO>', &restore_content); +sgml('<REFSECT2INFO>', &ignore_content); +sgml('</REFSECT2INFO>', &restore_content); +sgml('<REFSECT3INFO>', &ignore_content); +sgml('</REFSECT3INFO>', &restore_content);
-# IGNORE. -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('<INDEXTERM>', &ignore_content); +sgml('</INDEXTERM>', &restore_content);
-sgml('<INDEXTERM>', sub { push_output('nul'); }); -sgml('</INDEXTERM>', sub { pop_output(); }); +sgml('<AUTHORBLURB>', &ignore_content); +sgml('</AUTHORBLURB>', &restore_content);
######################################################################## @@ -588,10 +646,11 @@ sgml('</INDEXTERM>', sub { pop_output(); }); # ########################################################################
-sgml('<APPLICATION>', &bold_on); sgml('</APPLICATION>', &font_off); +sgml('<APPLICATION>', &bold_on); +sgml('</APPLICATION>', &font_off);
sgml('<CLASSNAME>', &bold_on); sgml('</CLASSNAME>', &font_off); -sgml('<STRUCTNANE>', &bold_on); sgml('</STRUCTNAME>', &font_off); +sgml('<STRUCTNAME>', &bold_on); sgml('</STRUCTNAME>', &font_off); sgml('<STRUCTFIELD>', &bold_on); sgml('</STRUCTFIELD>', &font_off); sgml('<SYMBOL>', &bold_on); sgml('</SYMBOL>', &font_off); sgml('<TYPE>', &bold_on); sgml('</TYPE>', &font_off); @@ -614,15 +673,30 @@ sgml('<GUIICON>', &bold_on); sgml('</GUIICON>', &font_off); # GUIMENUITEM # GUISUBMENU # MENUCHOICE -# MOUSEBUTTON
sgml('<ACCEL>', &bold_on); sgml('</ACCEL>', &font_off); -sgml('<KEYCAP>', &bold_on); sgml('</KEYCAP>', &font_off); -sgml('<KEYSYM>', &bold_on); sgml('</KEYSYM>', &font_off); # KEYCODE -# KEYCOMBO # SHORTCUT
+ +sgml('<KEYCOMBO>', sub { + $separator = 'none'; + $_[0]->ext->{'separator'} = 'none'; +}); +sgml('</KEYCOMBO>', sub { $separator = $_[0]->parent->ext->{'separator'}; }); + +sub _keycombo { + if($_[0]->in('KEYCOMBO')) { + if($separator eq 'none') { $separator = '' } + else { man_output "+"; } + } + bold_on(); +} +sgml('<KEYCAP>', &_keycombo); sgml('</KEYCAP>', &font_off); +sgml('<KEYSYM>', &_keycombo); sgml('</KEYSYM>', &font_off); +sgml('<MOUSEBUTTON>', &_keycombo); sgml('</MOUSEBUTTON>', &font_off); + + sgml('<USERINPUT>', &bold_on); sgml('</USERINPUT>', &font_off);
sgml('<INTERFACEDEFINITION>', &bold_on); @@ -633,9 +707,6 @@ sgml('<SYSTEMITEM>', &bold_on); sgml('</SYSTEMITEM>', &font_off);
- - - ######################################################################## # # Set italic on enclosed content @@ -668,10 +739,6 @@ sgml('<FOREIGNPHRASE>', &italic_on); sgml('</FOREIGNPHRASE>', &font_off); sgml('<LINEANNOTATION>', &italic_on); sgml('</LINEANNOTATION>', &font_off);
- - - - ######################################################################## # # Other 'inline' elements @@ -693,26 +760,49 @@ man_sgml('</QUOTE>', "''");
#man_sgml('<LITERAL>', '"'); #man_sgml('</LITERAL>', '"'); +# There doesn't seem to be a good way to represent LITERAL in -man +# ComputerOutput, SGMLTag, Markup are the same thing. + +# These create spaces between content in special elements +# without PCDATA content. +man_sgml('</HONORIFIC>', " "); +man_sgml('</FIRSTNAME>', " "); +man_sgml('</SURNAME>', " "); +man_sgml('</LINEAGE>', " "); +man_sgml('</OTHERNAME>', " "); + +man_sgml('<AFFILIATION>', "("); +man_sgml('</AFFILIATION>', ") "); +man_sgml('<CONTRIB>', "("); +man_sgml('</CONTRIB>', ") "); + +man_sgml('</STREET>', " "); +man_sgml('</POB>', " "); +man_sgml('</POSTCODE>', " "); +man_sgml('</CITY>', " "); +man_sgml('</STATE>', " "); +man_sgml('</COUNTRY>', " "); +man_sgml('</PHONE>', " "); +man_sgml('</FAX>', " "); +man_sgml('</OTHERADDRESS>', " "); + +man_sgml('</ALT>', ": "); +man_sgml('<GRAPHIC>', " [GRAPHIC] ");
# No special presentation:
-# AUTHOR # AUTHORINITIALS
# ABBREV # ACTION # ACRONYM -# ALT # CITATION # PHRASE # QUOTE # WORDASWORD
-# COMPUTEROUTPUT -# MARKUP # PROMPT # RETURNVALUE -# SGMLTAG # TOKEN
# DATABASE @@ -720,9 +810,6 @@ man_sgml('</QUOTE>', "''"); # INTERFACE # MEDIALABEL
-# There doesn't seem to be a good way to represent LITERAL in -man - -
######################################################################## # @@ -731,30 +818,20 @@ man_sgml('</QUOTE>', "''"); ########################################################################
sub para_start { - output "\n" unless $newline_last++; - - # In lists, etc., don't start paragraph with .PP since - # the indentation will be gone. - - if($_[0]->parent->ext->{'nobreak'}==1) { - # Usually this is the FIRST element of - # a hanging tag, so we MUST not do a full - # paragraph break. - $_[0]->parent->ext->{'nobreak'} = 2; - } elsif($_[0]->parent->ext->{'nobreak'}==2) { - # Usually these are the NEXT elements of - # a hanging tag. If we break using a blank - # line, we're okay. - output "\n"; - } else { - # Normal case. (For indented blocks too, at least - # -man isn't so braindead in this area.) - output ".PP\n"; + if($separator eq '' or $separator eq 'full') { + $separator = ''; + man_output "\n.PP\n"; + } elsif($separator eq 'blank') { + man_output "\n\n"; + } elsif($separator eq 'none' ) { + $_[0]->parent->ext->{'separator'} = 'blank'; + $separator = 'blank'; } } # Actually applies to a few other block elements as well sub para_end { - output "\n" unless $newline_last++; + $separator = $_[0]->parent->ext->{'separator'}; + man_output "\n"; }
sgml('<PARA>', ¶_start); @@ -767,9 +844,6 @@ sgml('<INFORMALEXAMPLE>', ¶_start); sgml('</INFORMALEXAMPLE>', ¶_end);
- - - ######################################################################## # # Blocks using SS sections @@ -796,21 +870,29 @@ sgml('</ABSTRACT>', sub { output "\n" unless $newline_last++; });
+ + # Ah, I needed a break. Example always has a title. -man_sgml('<EXAMPLE>', "\n.SS "); +sgml('<EXAMPLE>', sub { $separator = ''; man_output "\n.SS "}); sgml('</EXAMPLE>', ¶_end);
# Same with sidebar. -man_sgml('<SIDEBAR>', "\n.SS "); +sgml('<SIDEBAR>', sub { $separator = ''; man_output "\n.SS "}); sgml('</SIDEBAR>', ¶_end);
-# NO title. -man_sgml('<HIGHLIGHTS>', "\n.SS HIGHLIGHTS\n"); -sgml('</HIGHLIGHTS>', ¶_end); +sgml('<FORMALPARA>', sub { $separator = ''; man_output "\n.SS "}); +sgml('</FORMALPARA>', ¶_end);
+sgml('<FIGURE>', sub { $separator = ''; man_output "\n.SS "}); +sgml('</FIGURE>', ¶_end);
+# NO title. +sgml('<HIGHLIGHTS>', sub { $separator = ''; man_output "\n.SS HIGHLIGHTS\n"}); +sgml('</HIGHLIGHTS>', ¶_end); + + ######################################################################## # # Indented 'Block' elements @@ -819,28 +901,41 @@ sgml('</HIGHLIGHTS>', ¶_end);
sub indent_block_start { - output "\n" unless $newline_last++; - output ".sp\n.RS\n"; + $separator = ''; + man_output "\n.sp\n.RS\n"; } sub indent_block_end { - output "\n" unless $newline_last++; - output ".RE\n"; + $separator = $_[0]->parent->ext->{'separator'}; + man_output "\n.RE\n.sp\n"; }
+sgml('<ADDRESS>', sub { + &indent_block_start; + if($_[0]->attribute('FORMAT')->type eq 'NOTATION' + and $_[0]->attribute('FORMAT')->value->name eq 'LINESPECIFIC') { + &verbatim_start; + } +}); +sgml('</ADDRESS>', sub { + if($_[0]->attribute('FORMAT')->type eq 'NOTATION' + and $_[0]->attribute('FORMAT')->value->name eq 'LINESPECIFIC') { + &verbatim_end; + } + &indent_block_end; +}); + # This element is almost like an admonition (below), # only the default title is blank :)
sgml('<BLOCKQUOTE>', sub { $_[0]->ext->{'title'} = ''; - output "\n" unless $newline_last++; + &indent_block_start; push_output('string'); }); sgml('</BLOCKQUOTE>', sub { my $content = pop_output();
- indent_block_start(); - if($_[0]->ext->{'title'}) { output ".B "", $_[0]->ext->{'title'}, ":"\n"; } @@ -848,13 +943,11 @@ sgml('</BLOCKQUOTE>', sub { output $content;
if($_[0]->ext->{'attribution'}) { - output "\n" unless $newline_last++; - # One place where roff's space-sensitivity makes sense :) - output "\n -- "; - output $_[0]->ext->{'attribution'} . "\n"; + man_output "\n\n -- ", + $_[0]->ext->{'attribution'}, "\n"; } - indent_block_end(); + &indent_block_end; });
# Set off admonitions from the rest of the text by indenting. @@ -862,8 +955,6 @@ sgml('</BLOCKQUOTE>', sub { sub admonition_end { my $content = pop_output();
- indent_block_start(); - # When the admonition is only one paragraph, # it looks nicer if the title was inline. my $num_para; @@ -875,7 +966,7 @@ sub admonition_end { output ".B "" . $_[0]->ext->{'title'} . ":"\n"; output $content; - indent_block_end(); + &indent_block_end; }
sgml('<NOTE>', sub { @@ -883,11 +974,9 @@ sgml('<NOTE>', sub { # element, so we have to save the output now and add it back # at the end of this admonition. $_[0]->ext->{'title'} = 'Note'; - - # Although admonition_end's indent_block_start will do this, - # we need to synchronize the output _now_ - output "\n" unless $newline_last++; - + + &indent_block_start; + push_output('string'); }); sgml('</NOTE>', &admonition_end); @@ -895,42 +984,32 @@ sgml('</NOTE>', &admonition_end); # Same as above. sgml('<WARNING>', sub { $_[0]->ext->{'title'} = 'Warning'; - output "\n" unless $newline_last++; + &indent_block_start; push_output('string'); }); sgml('</WARNING>', &admonition_end);
sgml('<TIP>', sub { $_[0]->ext->{'title'} = 'Tip'; - output "\n" unless $newline_last++; + &indent_block_start; push_output('string'); }); sgml('</TIP>', &admonition_end); sgml('<CAUTION>', sub { $_[0]->ext->{'title'} = 'Caution'; - output "\n" unless $newline_last++; + &indent_block_start; push_output('string'); }); sgml('</CAUTION>', &admonition_end);
sgml('<IMPORTANT>', sub { $_[0]->ext->{'title'} = 'Important'; - output "\n" unless $newline_last++; + &indent_block_start; push_output('string'); }); sgml('</IMPORTANT>', &admonition_end);
- - - - - - - - - - ######################################################################## # # Verbatim displays. @@ -938,23 +1017,15 @@ sgml('</IMPORTANT>', &admonition_end); ########################################################################
sub verbatim_start { - output "\n" unless $newline_last++; - - if($_[0]->parent->ext->{'nobreak'}==1) { - # Usually this is the FIRST element of - # a hanging tag, so we MUST not do a full - # paragraph break. - $_[0]->parent->ext->{'nobreak'} = 2; - } else { - output "\n"; - } - - output(".nf\n") unless $nocollapse_whitespace++; + $separator = ''; + man_output "\n.sp\n"; + man_output "\n.nf\n" unless $nocollapse_whitespace++; }
sub verbatim_end { - output "\n" unless $newline_last++; - output(".fi\n") unless --$nocollapse_whitespace; + man_output "\n.sp\n"; + man_output "\n.fi\n" unless --$nocollapse_whitespace; + $separator = $_[0]->parent->ext->{'separator'}; }
sgml('<PROGRAMLISTING>', &verbatim_start); @@ -966,31 +1037,32 @@ sgml('</SCREEN>', &verbatim_end); sgml('<LITERALLAYOUT>', &verbatim_start); sgml('</LITERALLAYOUT>', &verbatim_end);
-#sgml('<SYNOPSIS>', sub { -# if($_[0]->attribute('FORMAT')->value =~ /linespecific/i) { -# &verbatim_start; -# } else { -# roffcmd(""); -# } -#}); -# -#sgml('</SYNOPSIS>', sub { -# if($_[0]->attribute('FORMAT')->value =~ /linespecific/i) { -# &verbatim_end; -# } -# else { -# roffcmd("");# not sure about this. -# } -#}); -sgml('<SYNOPSIS>', &verbatim_start); -sgml('</SYNOPSIS>', &verbatim_end); - - - - - +sgml('<SYNOPSIS>', sub { + my $format = $_[0]->attribute('FORMAT');
+ if($format->type eq 'NOTATION' + and $format->value->name eq 'LINESPECIFIC') + { + &verbatim_start; + } else { + $separator = ''; + man_output "\n.sp\n"; + } +});
+sgml('</SYNOPSIS>', sub { + my $format = $_[0]->attribute('FORMAT'); + + if($format->type eq 'NOTATION' + and $format->value->name eq 'LINESPECIFIC') + { + &verbatim_end; + } else { + man_output "\n"; + $_[0]->parent->ext->{'separator'} = 'full'; + $separator = 'full'; + } +});
######################################################################## @@ -1000,54 +1072,33 @@ sgml('</SYNOPSIS>', &verbatim_end); ########################################################################
# Indent nested lists. -sub indent_list_start { - if($list_nestlevel++) { - output "\n" unless $newline_last++; - output ".RS\n"; - } +sub list_start { + man_output "\n.RS\n" if $list_nestlevel++; } -sub indent_list_end { - if(--$list_nestlevel) { - output "\n" unless $newline_last++; - output ".RE\n"; - } +sub list_end { + man_output "\n.RE\n" if --$list_nestlevel; + $_[0]->parent->ext->{'separator'} = 'full'; + $separator = 'full'; }
-sgml('<VARIABLELIST>', &indent_list_start); -sgml('</VARIABLELIST>', &indent_list_end); -sgml('<ITEMIZEDLIST>', &indent_list_start); -sgml('</ITEMIZEDLIST>', &indent_list_end); +sgml('<VARIABLELIST>', &list_start); +sgml('</VARIABLELIST>', &list_end); +sgml('<ITEMIZEDLIST>', &list_start); +sgml('</ITEMIZEDLIST>', &list_end); sgml('<ORDEREDLIST>', sub { - indent_list_start(); + &list_start; $_[0]->ext->{'count'} = 1; }); -sgml('</ORDEREDLIST>', &indent_list_end); -sgml('<GLOSSLIST>', &indent_list_start); -sgml('</GLOSSLIST>', &indent_list_end); +sgml('</ORDEREDLIST>', &list_end); # Output content on one line, bolded. sgml('<TERM>', sub { - output "\n" unless $newline_last++; - output ".TP\n"; + man_output "\n.TP\n"; bold_on(); push_output('string'); }); sgml('</TERM>', sub { - my $term = pop_output(); - $term =~ tr/\n/ /; - output $term; - font_off(); - output "\n"; - $newline_last = 1; -}); -sgml('<GLOSSTERM>', sub { - output "\n" unless $newline_last++; - output ".TP\n"; - bold_on(); - push_output('string'); -}); -sgml('</GLOSSTERM>', sub { - my $term = pop_output(); + my $term = StripString(pop_output()); $term =~ tr/\n/ /; output $term; font_off(); @@ -1058,73 +1109,57 @@ sgml('</GLOSSTERM>', sub { sgml('<LISTITEM>', sub { # A bulleted list. if($_[0]->in('ITEMIZEDLIST')) { - output "\n" unless $newline_last++; - output ".TP 0.2i\n\(bu\n"; + man_output "\n.TP 0.2i\n\(bu\n"; }
# Need numbers. # Assume Arabic numeration for now. elsif($_[0]->in('ORDEREDLIST')) { - output "\n" unless $newline_last++; - output ".TP 3\n", $_[0]->parent->ext->{'count'}++, ". \n"; + man_output "\n.IP ", $_[0]->parent->ext->{'count'}++, ". \n"; } - $_[0]->ext->{'nobreak'} = 1; -}); -sgml('<GLOSSDEF>', sub { - $_[0]->ext->{'nobreak'} = 1; + $_[0]->ext->{'separator'} = 'none'; + $separator = 'none'; });
sgml('<SIMPLELIST>', sub { $_[0]->ext->{'first_member'} = 1; }); - sgml('<MEMBER>', sub { my $parent = $_[0]->parent; if($parent->attribute('TYPE')->value =~ /Inline/i) { - if($parent->ext->{'first_member'}) { + if($parent->ext->{'first_member'}) { # If this is the first member don't put any commas $parent->ext->{'first_member'} = 0; } else { - output ", "; + man_output ", "; } - } elsif($parent->attribute('TYPE')->value =~ /Vert/i) { - output "\n" unless $newline_last++; - output "\n"; + + # We don't really have Horiz rendering, so it's the same + # as Vert. + } else { + man_output "\n\n"; } });
+# We implement Procedures as indent and lists
+sgml('<PROCEDURE>', sub { + $_[0]->ext->{'count'} = 1; + &indent_block_start; +}); +sgml('</PROCEDURE>', sub { + &indent_block_end; + $_[0]->parent->ext->{'separator'} = 'full'; + $separator = 'full'; +});
- - -######################################################################## -# -# Stuff we don't know how to handle (yet) -# -######################################################################## - -# Address blocks: - -# Credit stuff: -# ACKNO -# ADDRESS -# AFFILIATION -# ARTPAGENUMS -# ATTRIBUTION -# AUTHORBLURB -# AUTHORGROUP -# OTHERCREDIT -# HONORIFIC - -# Areas: -# AREA -# AREASET -# AREASPEC - - - +sgml('<STEP>', sub { + man_output "\n.IP ", $_[0]->parent->ext->{'count'}++, ". \n"; + $_[0]->ext->{'separator'} = 'none'; + $separator = 'none'; +});
######################################################################## @@ -1135,48 +1170,308 @@ sgml('<MEMBER>', sub {
# Print the URL sgml('</ULINK>', sub { - output ' <URL:', $_[0]->attribute('URL')->value, '>'; - $newline_last = 0; + man_output ' <URL:', $_[0]->attribute('URL')->value, '>'; });
# If cross reference target is a RefEntry, # output CiteRefEntry-style references. sgml('<XREF>', sub { my $id = $_[0]->attribute('LINKEND')->value; - my $manref = $Refs->get("refentry:$id");
- if($manref) { - my ($title, $sect) = ($manref =~ /(.*)((.*))/); - bold_on(); - output $title; - font_off(); - output $sect; - } else { + my $manref = $Refs->get("refentry:$id") || $Refs->get("refsect:$id"); + if(!defined $manref) { $blank_xrefs++ if $write_manpages; - output "[XRef to $id]"; + man_output "[XRef to $id]"; + return; }
- $newline_last = 0; -}); - -# Anchor + # Limited ENDTERM support. + if(defined $_[0]->attribute('ENDTERM')->value) { + my $endterm = $_[0]->attribute('ENDTERM')->value; + my $content = $Refs->get("title:$endterm") || + $Refs->get("refentrytitle:$endterm"); + man_output $content, ' ['; + }
+ # This also displays the XREFLABEL (as bold)... + # It's not worth the bother to fix it though, there + # are better tools for this. + my ($title, $sect) = ($manref =~ /(.*)((.*))/); + bold_on(); + man_output $title; + font_off(); + man_output $sect;
+ if(defined $_[0]->attribute('ENDTERM')->value) { + man_output ']'; + } +});
+# Anchor
######################################################################## # -# Other handlers +# SDATA # ########################################################################
man_sgml('|[lt ]|', '<'); +man_sgml('|[equals]|', '='); man_sgml('|[gt ]|', '>'); +man_sgml('|[plus ]|', '(pl'); +man_sgml('|[dollar]|', '$'); +man_sgml('|[num ]|', '#'); +man_sgml('|[percnt]|', '%'); man_sgml('|[amp ]|', '&'); -man_sgml('|[minus ]|', '-'); -man_sgml('|[copy ]|', '(C)'); -man_sgml('|[nbsp ]|', '~'); -man_sgml('|[thinsp]|', '~'); +man_sgml('|[commat]|', '@'); +man_sgml('|[lsqb ]|', '['); +man_sgml('|[bsol ]|', '\e'); +man_sgml('|[rsqb ]|', ']'); +man_sgml('|[lcub ]|', '{'); +man_sgml('|[verbar]|', '(or'); +man_sgml('|[rcub ]|', '}'); +man_sgml('|[excl ]|', '!'); +man_sgml('|[quot ]|', '"'); +man_sgml('|[apos ]|', '\&''); +man_sgml('|[lpar ]|', '('); +man_sgml('|[rpar ]|', ')'); +man_sgml('|[comma ]|', ','); +man_sgml('|[lowbar]|', '_'); +man_sgml('|[period]|', '.'); +man_sgml('|[sol ]|', '/'); +man_sgml('|[colon ]|', ':'); +man_sgml('|[semi ]|', ';'); +man_sgml('|[quest ]|', '?'); +man_sgml('|[grave ]|', '`'); +man_sgml('|[tilde ]|', '~'); +man_sgml('|[half ]|', '(12'); +man_sgml('|[frac12]|', '(12'); +man_sgml('|[frac14]|', '(14'); +man_sgml('|[frac34]|', '(34'); +man_sgml('|[frac18]|', '1/8'); +man_sgml('|[frac38]|', '3/8'); +man_sgml('|[frac58]|', '5/8'); +man_sgml('|[frac78]|', '7/8'); +man_sgml('|[sup1 ]|', '\u1\l'); +man_sgml('|[sup2 ]|', '\u2\l'); +man_sgml('|[sup3 ]|', '\u3\l'); +man_sgml('|[plusmn]|', '(+-'); +man_sgml('|[divide]|', '(di'); +man_sgml('|[times ]|', '(ti'); +man_sgml('|[pound ]|', '#'); +man_sgml('|[cent ]|', '(ct'); +man_sgml('|[yen ]|', 'yen'); +man_sgml('|[ast ]|', '*'); +man_sgml('|[horbar]|', '_'); +man_sgml('|[micro ]|', '(*m'); +man_sgml('|[ohm ]|', '(*W'); +man_sgml('|[deg ]|', '(de'); +man_sgml('|[sect ]|', '(sc'); +man_sgml('|[larr ]|', '(<-'); +man_sgml('|[rarr ]|', '(->'); +man_sgml('|[uarr ]|', '(ua'); +man_sgml('|[darr ]|', '(da'); +man_sgml('|[copy ]|', '(co'); +man_sgml('|[reg ]|', '(rg'); +man_sgml('|[trade ]|', '(tm'); +man_sgml('|[brvbar]|', '|'); +man_sgml('|[not ]|', '(no'); +man_sgml('|[hyphen]|', '-'); +man_sgml('|[laquo ]|', '<<'); +man_sgml('|[raquo ]|', '>>'); +man_sgml('|[lsquo ]|', '`'); +man_sgml('|[rsquo ]|', '&''); +man_sgml('|[ldquo ]|', '"'); +man_sgml('|[rdquo ]|', '"'); +man_sgml('|[nbsp ]|', '\ '); +man_sgml('|[shy ]|', '%'); +man_sgml('|[emsp ]|', '\ \ '); +man_sgml('|[ensp ]|', '\ '); +man_sgml('|[emsp3 ]|', '\ '); +man_sgml('|[emsp4 ]|', '\ '); +man_sgml('|[numsp ]|', '\0'); +man_sgml('|[puncsp]|', '|'); +man_sgml('|[thinsp]|', '!'); +man_sgml('|[hairsp]|', '\^'); +man_sgml('|[mdash ]|', '(em'); +man_sgml('|[ndash ]|', '-'); +man_sgml('|[dash ]|', '-'); +man_sgml('|[blank ]|', '\ '); +man_sgml('|[hellip]|', '&...'); +man_sgml('|[nldr ]|', '&..'); +man_sgml('|[frac13]|', '1/3'); +man_sgml('|[frac23]|', '2/3'); +man_sgml('|[frac15]|', '1/5'); +man_sgml('|[frac25]|', '2/5'); +man_sgml('|[frac35]|', '3/5'); +man_sgml('|[frac45]|', '4/5'); +man_sgml('|[frac16]|', '1/6'); +man_sgml('|[frac56]|', '5/6'); +man_sgml('|[cir ]|', '(ci'); +man_sgml('|[squ ]|', '(sq'); +man_sgml('|[star ]|', '(**'); +man_sgml('|[bull ]|', '(bu'); +man_sgml('|[dagger]|', '(dg'); +man_sgml('|[Dagger]|', '(dd'); +man_sgml('|[caret ]|', '^'); +man_sgml('|[lsquor]|', '`'); +man_sgml('|[ldquor]|', '``'); +man_sgml('|[fflig ]|', '(ff'); +man_sgml('|[filig ]|', '(fi'); +man_sgml('|[ffilig]|', '(Fi'); +man_sgml('|[ffllig]|', '(Fl'); +man_sgml('|[fllig ]|', '(fl'); +man_sgml('|[rdquor]|', '&'''); +man_sgml('|[rsquor]|', '&''); +man_sgml('|[vellip]|', '&...'); +man_sgml('|[aacute]|', '(a''); +man_sgml('|[Aacute]|', '(A''); +man_sgml('|[acirc ]|', '(a^'); +man_sgml('|[Acirc ]|', '(A^'); +man_sgml('|[agrave]|', '(a`'); +man_sgml('|[Agrave]|', '(A`'); +man_sgml('|[auml ]|', '(a:'); +man_sgml('|[aelig ]|', '(ae'); +man_sgml('|[AElig ]|', '(AE'); +man_sgml('|[eacute]|', '(e''); +man_sgml('|[Eacute]|', '(E''); +man_sgml('|[egrave]|', '(e`'); +man_sgml('|[Egrave]|', '(E`'); +man_sgml('|[iacute]|', '(i''); +man_sgml('|[Iacute]|', '(I''); +man_sgml('|[igrave]|', '(i`'); +man_sgml('|[Igrave]|', '(I`'); +man_sgml('|[ntilde]|', '(n~'); +man_sgml('|[Ntilde]|', '(N~'); +man_sgml('|[oacute]|', '(o''); +man_sgml('|[Oacute]|', '(O''); +man_sgml('|[ograve]|', '(o`'); +man_sgml('|[Ograve]|', '(O`'); +man_sgml('|[oslash]|', '(o/'); +man_sgml('|[Oslash]|', '(O/'); +man_sgml('|[szlig ]|', '(ss'); +man_sgml('|[thorn ]|', '(th'); +man_sgml('|[uacute]|', '(u''); +man_sgml('|[Uacute]|', '(U''); +man_sgml('|[ugrave]|', '(u`'); +man_sgml('|[Ugrave]|', '(U`'); +man_sgml('|[aogon ]|', '(ao'); +man_sgml('|[agr ]|', '(*a'); +man_sgml('|[Agr ]|', '(*A'); +man_sgml('|[bgr ]|', '(*b'); +man_sgml('|[Bgr ]|', '(*B'); +man_sgml('|[ggr ]|', '(*g'); +man_sgml('|[Ggr ]|', '(*G'); +man_sgml('|[dgr ]|', '(*d'); +man_sgml('|[Dgr ]|', '(*D'); +man_sgml('|[egr ]|', '(*e'); +man_sgml('|[Egr ]|', '(*E'); +man_sgml('|[zgr ]|', '(*z'); +man_sgml('|[Zgr ]|', '(*Z'); +man_sgml('|[eegr ]|', '(*y'); +man_sgml('|[EEgr ]|', '(*Y'); +man_sgml('|[thgr ]|', '(*h'); +man_sgml('|[THgr ]|', '(*H'); +man_sgml('|[igr ]|', '(*i'); +man_sgml('|[Igr ]|', '(*I'); +man_sgml('|[kgr ]|', '(*k'); +man_sgml('|[Kgr ]|', '(*K'); +man_sgml('|[lgr ]|', '(*l'); +man_sgml('|[Lgr ]|', '(*L'); +man_sgml('|[mgr ]|', '(*m'); +man_sgml('|[Mgr ]|', '(*M'); +man_sgml('|[ngr ]|', '(*n'); +man_sgml('|[Ngr ]|', '(*N'); +man_sgml('|[xgr ]|', '(*c'); +man_sgml('|[Xgr ]|', '(*C'); +man_sgml('|[ogr ]|', '(*o'); +man_sgml('|[Ogr ]|', '(*O'); +man_sgml('|[pgr ]|', '(*p'); +man_sgml('|[Pgr ]|', '(*P'); +man_sgml('|[rgr ]|', '(*r'); +man_sgml('|[Rgr ]|', '(*R'); +man_sgml('|[sgr ]|', '(*s'); +man_sgml('|[Sgr ]|', '(*S'); +man_sgml('|[sfgr ]|', '(ts'); +man_sgml('|[tgr ]|', '(*t'); +man_sgml('|[Tgr ]|', '(*T'); +man_sgml('|[ugr ]|', '(*u'); +man_sgml('|[Ugr ]|', '(*U'); +man_sgml('|[phgr ]|', '(*f'); +man_sgml('|[PHgr ]|', '(*F'); +man_sgml('|[khgr ]|', '(*x'); +man_sgml('|[KHgr ]|', '(*X'); +man_sgml('|[psgr ]|', '(*q'); +man_sgml('|[PSgr ]|', '(*Q'); +man_sgml('|[ohgr ]|', '(*w'); +man_sgml('|[OHgr ]|', '(*W'); +man_sgml('|[alpha ]|', '(*a'); +man_sgml('|[beta ]|', '(*b'); +man_sgml('|[gamma ]|', '(*g'); +man_sgml('|[Gamma ]|', '(*G'); +man_sgml('|[delta ]|', '(*d'); +man_sgml('|[Delta ]|', '(*D'); +man_sgml('|[epsi ]|', '(*e'); +man_sgml('|[epsis ]|', '(*e'); +man_sgml('|[zeta ]|', '(*z'); +man_sgml('|[eta ]|', '(*y'); +man_sgml('|[thetas]|', '(*h'); +man_sgml('|[Theta ]|', '(*H'); +man_sgml('|[iota ]|', '(*i'); +man_sgml('|[kappa ]|', '(*k'); +man_sgml('|[lambda]|', '(*l'); +man_sgml('|[Lambda]|', '(*L'); +man_sgml('|[mu ]|', '(*m'); +man_sgml('|[nu ]|', '(*n'); +man_sgml('|[xi ]|', '(*c'); +man_sgml('|[Xi ]|', '(*C'); +man_sgml('|[pi ]|', '(*p'); +man_sgml('|[Pi ]|', '(*P'); +man_sgml('|[rho ]|', '(*r'); +man_sgml('|[sigma ]|', '(*s'); +man_sgml('|[Sigma ]|', '(*S'); +man_sgml('|[tau ]|', '(*t'); +man_sgml('|[upsi ]|', '(*u'); +man_sgml('|[Upsi ]|', '(*U'); +man_sgml('|[phis ]|', '(*f'); +man_sgml('|[Phi ]|', '(*F'); +man_sgml('|[chi ]|', '(*x'); +man_sgml('|[psi ]|', '(*q'); +man_sgml('|[Psi ]|', '(*X'); +man_sgml('|[omega ]|', '(*w'); +man_sgml('|[Omega ]|', '(*W'); +man_sgml('|[ap ]|', '(ap'); +man_sgml('|[equiv ]|', '(=='); +man_sgml('|[ge ]|', '(>='); +man_sgml('|[infin ]|', '(if'); +man_sgml('|[isin ]|', '(sb'); +man_sgml('|[le ]|', '(<='); +man_sgml('|[minus ]|', '(mi'); +man_sgml('|[ne ]|', '(!='); +man_sgml('|[prop ]|', '(pt'); +man_sgml('|[square]|', '(sq'); +man_sgml('|[sub ]|', '(sb'); +man_sgml('|[sube ]|', '(ib'); +man_sgml('|[sup ]|', '(sp'); +man_sgml('|[supe ]|', '(ip'); +man_sgml('|[acute ]|', '&''); +man_sgml('|[breve ]|', '(be'); +man_sgml('|[caron ]|', '(hc'); +man_sgml('|[cedil ]|', '(cd'); +man_sgml('|[dot ]|', '(dt'); +man_sgml('|[macr ]|', '(ma'); +man_sgml('|[ogon ]|', '(og'); +man_sgml('|[ring ]|', '(ri'); +man_sgml('|[uml ]|', '(..'); + +sgml('sdata',sub { + my ($element, $event) = @_; + my ($file, $line) = ($event->file, $event->line); + man_output "|[", $_[0], "]|"; + warn "Warning: unrecognized SDATA '$_[0]'" + . ($file && $line ? " in $file on line $line" : "") + . ": please add definition to docbook2man-spec.pl\n"; +});
# # Default handlers (uncomment these if needed). Right now, these are set @@ -1194,26 +1489,38 @@ sgml('cdata', sub { if(!$write_manpages) { return; } elsif($raw_cdata) { output $_[0]; return; } + + if($separator eq 'full') { + output "\n" unless $newline_last++; + output ".PP\n"; + $separator = ''; + } # Escape backslashes $_[0] =~ s/\/\\/g;
- # Escape dots and single quotes in column 1 - $_[0] =~ s/^./\&./; - $_[0] =~ s/^'/\&'/; + # Escape dots and single quotes in column 1 + $_[0] =~ s/^[ \t]*./\&./; + $_[0] =~ s/^[ \t]*'/\&'/; +
# In non-'pre'-type elements: if(!$nocollapse_whitespace) { # Change tabs to spaces - $_[0] =~ tr/\t/ /; + $_[0] =~ tr/\t / /s;
# Do not allow indents at beginning of line # groff chokes on that. if($newline_last) { - $_[0] =~ s/^ +//; + $_[0] =~ s/^ //;
# If the line is all blank, don't do anything. if($_[0] eq '') { return; } + + $_[0] =~ s/^./\&./; + + # Argh... roff doesn't like ' for some unknown reason + $_[0] =~ s/^'/\&'/; } }
@@ -1234,15 +1541,11 @@ sgml('re', sub $newline_last = 1; });
-sgml('sdata',sub -{ - die "Unknown SDATA: " . $_[0]; -}); -sgml('pi',sub { die "Unknown processing instruction: " . $_[0]; }); +sgml('pi', sub {}); sgml('entity',sub { die "Unknown external entity: " . $_[0]->name; }); sgml('start_subdoc',sub { die "Unknown subdoc entity: " . $_[0]->name; }); -sgml('end_subdoc',''); -sgml('conforming',''); +sgml('end_subdoc',sub{}); +sgml('conforming',sub{});
1;
docbook-utils-commits@lists.fedorahosted.org