html2confman.pl 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #!/usr/bin/perl -w
  2. #
  3. # A Perl script for converting pdnsd html documentation to a man page.
  4. #
  5. # Written by Paul A. Rombouts
  6. #
  7. # This file Copyright 2004 Paul A. Rombouts
  8. # It may be distributed under the GNU Public License, version 2, or
  9. # any higher version. See section COPYING of the GNU Public license
  10. # for conditions under which this file may be redistributed.
  11. #
  12. use strict;
  13. use POSIX qw(strftime);
  14. while(<>) {
  15. if(/<h[1-4]>[^<]*configuration file/i) {
  16. last;
  17. }
  18. }
  19. exit unless defined($_);
  20. while(<>) {
  21. if(/<h[1-4]>[^<]*layout/i) {
  22. last;
  23. }
  24. }
  25. exit unless defined($_);
  26. (my $myname=$0) =~ s{.*/}{};
  27. print <<ENDOFHEADER;
  28. .\\\" Generated automatically from the html documentation by $myname
  29. .\\\"
  30. .\\\" Manpage for pdnsd.conf (pdnsd configuration file)
  31. .\\\"
  32. .\\\" Copyright (C) 2000, 2001 Thomas Moestl
  33. .\\\" Copyright (C) 2003, 2004, 2005, 2006, 2007 Paul A. Rombouts
  34. .\\\"
  35. .\\\" This manual is a part of the pdnsd package, and may be distributed in
  36. .\\\" original or modified form under terms of the GNU General Public
  37. .\\\" License, as published by the Free Software Foundation; either version
  38. .\\\" 3, or (at your option) any later version.
  39. .\\\" You can find a copy of the GNU GPL in the file COPYING in the source
  40. .\\\" or documentation directory.
  41. .\\\"
  42. ENDOFHEADER
  43. print ".TH PDNSD.CONF 5 \"",strftime("%b %Y",localtime),"\" \"pdnsd \@fullversion\@\"\n";
  44. print <<ENDOFHEADER2;
  45. .SH NAME
  46. pdnsd.conf \\- The configuration file for pdnsd
  47. .hw config
  48. .SH DESCRIPTION
  49. .PP
  50. This manual page describes the layout of the
  51. .BR pdnsd (8)
  52. configuration file and the available configuration options.
  53. The default location of the file is \@sysconfdir\@/pdnsd.conf. This may be changed
  54. with the \\fB-c\\fP command line option.
  55. An example pdnsd.conf comes with the pdnsd distribution in the documentation directory
  56. or in \@sysconfdir\@/pdnsd.conf.sample.
  57. .SH \"FILE FORMAT\"
  58. .PP
  59. ENDOFHEADER2
  60. my $taggedparagraph=0;
  61. my $displayed=0;
  62. while(<>) {
  63. if(/<h[1-4]>.*\bpdnsd-ctl\b/) {
  64. last;
  65. }
  66. s{^\s*((?:<[^<>]+>)*?)<h[1-4]>[\d.]*\s*(.*)</h[1-4]>((?:<[^<>]+>)*?)(?:<br>)?\s*$}{.SS $1$2$3\n}i;
  67. if(s{^\s*<tr>\s*}{.TP\n}i) {$taggedparagraph=1}
  68. if(m{^\s*</tr>}i) {$taggedparagraph=0}
  69. s{^\s*((?:<[^<>]+>)*?)<b>(.*)</b>((?:<[^<>]+>)*?)(?:<br>)?\s*$}{.B $1$2$3\n}i if $taggedparagraph;
  70. s{^\s*((?:<[^<>]+>)*?or(?:<[^<>]+>)*?)(?:<br>)?\s*$}{$1\n.PD 0\n.TP\n.PD\n}i if $taggedparagraph;
  71. if(s{^\s*<pre>}{.DS L\n}i) {$displayed=1}
  72. s{^\t}{ } if $displayed;
  73. if(s{</pre>\s*$}{\n.DE\n\n}i) {$displayed=0}
  74. elsif(!$displayed) {s{^\s*}{}}
  75. s{^\s*<li>}{.IP\n\\(bu }i;
  76. s{<li>}{\n.IP\n\\(bu }i;
  77. s{<ul>}{\n}i;
  78. s{</ul>}{\n}i;
  79. s{<b>}{\\fB}ig;
  80. s{</b>}{\\fP}ig;
  81. s{<(i|em)>}{\\fI}ig;
  82. s{</(i|em)>}{\\fP}ig;
  83. unless(s{^\s*(<[^<>]+>)*(<br>|<p>)(<[^<>]+>)*\s*$}{\n}i) {
  84. s{<p\b[^<>]*>(.*)</p>}{\n$1\n}i;
  85. s{^\s*<br>}{.br\n}i;
  86. s{<br>\s*<br>\s*$}{\n\n}i;
  87. s{<br>\s*$}{\n.br\n}i;
  88. s{<br>}{\n.br\n}i;
  89. s{^\s*(<[^<>]+>)*\s*$}{};
  90. }
  91. s{<[^<>]+>}{}g;
  92. s{&lt;}{<}ig;
  93. s{&gt;}{>}ig;
  94. s{&quot;}{"}ig;
  95. s{&nbsp;}{\\ }ig;
  96. s{/var/cache/pdnsd\b}{\@cachedir\@}g;
  97. s{(?<![-\w\\])-[-\w]*}{(my $s=$&) =~ s{-}{\\-}g;$s}ge;
  98. s{\bpdnsd-ctl\b}{pdnsd\\-ctl}g;
  99. s{\blist-rrtypes\b}{list\\-rrtypes}g;
  100. print;
  101. }
  102. print <<ENDOFTRAILER;
  103. .SH \"VERSION\"
  104. .PP
  105. This man page is correct for version \@fullversion\@ of pdnsd.
  106. .SH \"SEE ALSO\"
  107. .PP
  108. .BR pdnsd (8),
  109. .BR pdnsd\\-ctl (8)
  110. .PP
  111. More documentation is available in the \\fBdoc/\\fP subdirectory of the source,
  112. or in \\fB/usr/share/doc/pdnsd/\\fP if you are using a binary package.
  113. .SH AUTHORS
  114. \\fBpdnsd\\fP was originally written by Thomas Moestl
  115. .UR
  116. <tmoestl\@gmx.net>
  117. .UE
  118. and was extensively revised by Paul A. Rombouts
  119. .UR
  120. <p.a.rombouts\@home.nl>
  121. .UE
  122. (for versions 1.1.8b1\\-par and later).
  123. .PP
  124. Several others have contributed to \\fBpdnsd\\fP; see files in the source or
  125. \\fB/usr/share/doc/pdnsd/\\fP directory.
  126. .PP
  127. This man page was automatically generated from the html documentation for \\fBpdnsd\\fP,
  128. using a customized Perl script written by Paul A. Rombouts.
  129. ENDOFTRAILER
  130. if(defined($_)) {
  131. while(<>) {
  132. if(/last\s+revised/i) {
  133. s{^\s*}{};
  134. s{<[^<>]+>}{}g;
  135. s{&lt;}{<}ig;
  136. s{&gt;}{>}ig;
  137. s{&quot;}{"}ig;
  138. s{&nbsp;}{\\ }ig;
  139. print ".PP\n";
  140. print;
  141. last;
  142. }
  143. }
  144. }
  145. exit;