mandoc2docbook.pl revision dafcb997e390efa4423883dafd100c975c4095d6
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# Copyright (C) 2001 Internet Software Consortium.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# Permission to use, copy, modify, and distribute this software for any
ad91a3d204891c4b039606f9b5ef557d9036f8c8Michael Graff# purpose with or without fee is hereby granted, provided that the above
ad91a3d204891c4b039606f9b5ef557d9036f8c8Michael Graff# copyright notice and this permission notice appear in all copies.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
9416e9751e522256dd6dd60d56cb4e8e8f549149Andreas Gustafsson# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
9416e9751e522256dd6dd60d56cb4e8e8f549149Andreas Gustafsson# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
e7fb847ed570dd8c1bcdacabb3d69bd81feb79aeMark Andrews# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
ad91a3d204891c4b039606f9b5ef557d9036f8c8Michael Graff# PERFORMANCE OF THIS SOFTWARE.
ad91a3d204891c4b039606f9b5ef557d9036f8c8Michael Graff# $Id: mandoc2docbook.pl,v 1.4 2004/03/05 05:14:16 marka Exp $
ad91a3d204891c4b039606f9b5ef557d9036f8c8Michael Graff# Do a quick-and-dirty conversion of .mandoc man pages to
ad91a3d204891c4b039606f9b5ef557d9036f8c8Michael Graff# DocBook SGML.
21cbbc3e8301f3959fa1c37d1ee7d597e15c5bf3Michael Graff# Minor hand editing of the output is usually required.
21cbbc3e8301f3959fa1c37d1ee7d597e15c5bf3Michael Graff# This has only been tested with library function man pages
b8ef99c3a7be2835b2395faff2d46e46f5c4adb3Michael Graff# (section 3); it probably does not work well for program
21cbbc3e8301f3959fa1c37d1ee7d597e15c5bf3Michael Graff<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
21cbbc3e8301f3959fa1c37d1ee7d597e15c5bf3Michael Graff - Copyright (C) 2000, 2001 Internet Software Consortium.
21cbbc3e8301f3959fa1c37d1ee7d597e15c5bf3Michael Graff - Permission to use, copy, modify, and distribute this software for any
b8ef99c3a7be2835b2395faff2d46e46f5c4adb3Michael Graff - purpose with or without fee is hereby granted, provided that the above
b8ef99c3a7be2835b2395faff2d46e46f5c4adb3Michael Graff - copyright notice and this permission notice appear in all copies.
b8ef99c3a7be2835b2395faff2d46e46f5c4adb3Michael Graff - THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
b8ef99c3a7be2835b2395faff2d46e46f5c4adb3Michael Graff - DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
b8ef99c3a7be2835b2395faff2d46e46f5c4adb3Michael Graff - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
b8ef99c3a7be2835b2395faff2d46e46f5c4adb3Michael Graff - INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
b8ef99c3a7be2835b2395faff2d46e46f5c4adb3Michael Graff - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
21cbbc3e8301f3959fa1c37d1ee7d597e15c5bf3Michael Graff - FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
21cbbc3e8301f3959fa1c37d1ee7d597e15c5bf3Michael Graff - NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
ad91a3d204891c4b039606f9b5ef557d9036f8c8Michael Graff<!-- $Id: mandoc2docbook.pl,v 1.4 2004/03/05 05:14:16 marka Exp $ -->
b8ef99c3a7be2835b2395faff2d46e46f5c4adb3Michael Graff print "<para>\n";
b8ef99c3a7be2835b2395faff2d46e46f5c4adb3Michael Graff print "</para>\n";
ad91a3d204891c4b039606f9b5ef557d9036f8c8Michael Graff print "</$cursection>\n"
b8ef99c3a7be2835b2395faff2d46e46f5c4adb3Michael Graff print "<$tag>\n";
b8ef99c3a7be2835b2395faff2d46e46f5c4adb3Michael Graff next if m/^\.\\\"/;
b8ef99c3a7be2835b2395faff2d46e46f5c4adb3Michael Graff if (/^\.Dd (.*)$/) {
b8ef99c3a7be2835b2395faff2d46e46f5c4adb3Michael Graff print "<date>$1<\/date>\n<\/refentryinfo>\n";
b8ef99c3a7be2835b2395faff2d46e46f5c4adb3Michael Graff elsif (/^\.Dt ([^ ]+) ([^ ]+)$/) {
b8ef99c3a7be2835b2395faff2d46e46f5c4adb3Michael Graff elsif (/^\.Os (.*)$/) {
ad91a3d204891c4b039606f9b5ef557d9036f8c8Michael Graff elsif (/^\.ds (.*)$/) {
ad91a3d204891c4b039606f9b5ef557d9036f8c8Michael Graff elsif (/^\.Nm (.*)$/) {
ad91a3d204891c4b039606f9b5ef557d9036f8c8Michael Graff $t =~ s/ ,$//;
ad91a3d204891c4b039606f9b5ef557d9036f8c8Michael Graff print "<refname>$t<\/refname>\n";
b8ef99c3a7be2835b2395faff2d46e46f5c4adb3Michael Graff print "<command>$1<\/command>\n";
ad91a3d204891c4b039606f9b5ef557d9036f8c8Michael Graff elsif (/^\.Nd (.*)$/) {
ad91a3d204891c4b039606f9b5ef557d9036f8c8Michael Graff print "<refpurpose>$1</refpurpose>\n";
ad91a3d204891c4b039606f9b5ef557d9036f8c8Michael Graff elsif (/^\.Sh NAME/) { section("refnamediv"); next; }
b8ef99c3a7be2835b2395faff2d46e46f5c4adb3Michael Graff elsif (/^\.Sh SYNOPSIS/) { section("refsynopsisdiv"); next; }
ad91a3d204891c4b039606f9b5ef557d9036f8c8Michael Graff elsif (/^\.Sh (.*)$/) {
ad91a3d204891c4b039606f9b5ef557d9036f8c8Michael Graff print "<title>$1</title>\n"; next;
ad91a3d204891c4b039606f9b5ef557d9036f8c8Michael Graff # special: spaces can occur in arg
ad91a3d204891c4b039606f9b5ef557d9036f8c8Michael Graff elsif (/^\.Fd (.*)$/) {
ad91a3d204891c4b039606f9b5ef557d9036f8c8Michael Graff print "<funcsynopsisinfo>$_<\/funcsynopsisinfo>\n";
ad91a3d204891c4b039606f9b5ef557d9036f8c8Michael Graff # special: add parenthesis
ad91a3d204891c4b039606f9b5ef557d9036f8c8Michael Graff print "<function>$1()<\/function>$3\n";
elsif (/^\.Ft (.*)$/) {
elsif (/^\.Fo (.*)$/) {
elsif (/^\.Xr ([^ ]+) ([^ ]+)( ([^ ]+))?$/) {
$t =~ s/</</g;
$t =~ s/>/>/g;
elsif (/^\.Fc$/) {
elsif (/^\.Pp$/) {
end_para();
begin_para();
elsif (/^\.Bd /) {
elsif (/^\.Ed$/) {
elsif (/^\.Bl /) {
elsif (/^\.El$/) {
elsif (/^\.It .. (.*)$/) {
if ($in_list) {
if ($in_list) {
begin_para();
end_para();
end_section();