#!/usr/bin/perl
my
$local_links
= 0;
my
$local_dir
=
''
;
if
(
@ARGV
&&
$ARGV
[0] =~ /--
local
(=(.*))?/) {
$local_links
= 1;
$local_dir
= $2;
shift
@ARGV
;
}
my
$local_pagename
=
'manpage.html'
;
if
(
@ARGV
&&
$ARGV
[0] =~ /--
local
-page(=(.*))?/) {
$local_pagename
= $2;
shift
@ARGV
;
}
{
our
$VERSION
= 1;
my
%table
;
BEGIN {
%table
=
'rss'
.
'2email'
=>
'http://rss'
.
'2email.infogami.com'
,
);
}
sub
resolve_man_page_link {
my
(
$self
,
$to
,
$frag
) =
@_
;
$to
=
"$to"
;
if
(
my
(
$page
,
$section
) = (
$to
=~ /(.*)\(\d+\)$/)) {
if
(
my
$url
=
$table
{
$page
}) {
return
$url
;
}
}
return
shift
->SUPER::resolve_man_page_link (
@_
);
}
sub
resolve_pod_link_by_table {
my
(
$self
,
$to
,
$section
) =
@_
;
my
$tux_link
=
sub
{
my
(
$dir
,
$filename
) =
@_
;
if
(
$dir
eq
$local_dir
) {
return
$filename
; }
return
"../$dir/$filename"
;
};
my
$url
;
if
(
defined
$to
) {
if
(
$to
eq
'AptPkg'
) {
}
if
(
$to
=~ /^Glib::Ex::(SourceIds|SignalIds|FreezeNotify|TieProperties)/) {
$url
=
$tux_link
->(
"glib-ex-ob"
.
"jectbits"
,
"$1.html"
);
}
if
(
$to
eq
'Gtk2::Ex::Widget'
.
'Cursor'
) {
$url
=
$tux_link
->(
'gtk2-ex-widget'
.
'cursor'
,
'Widget'
.
'Cursor.html'
);
}
if
(
$to
eq
'Ti'
.
'e:'
.
':TZ'
) {
$url
=
$tux_link
->(
'ti'
.
'e-'
.
'tz'
,
'TZ.html'
);
}
if
(
$to
eq
'Time:'
.
':TZ'
) {
$url
=
$tux_link
->(
'ti'
.
'e-'
.
'tz'
,
'Time-'
.
'TZ.html'
);
}
if
(
$to
=~ /^(Glib|Gtk2)($|::(?!Ex::))/) {
$to
=~ s{::}{/};
}
if
(
defined
$url
) {
return
(
$url
. (
defined
$section
&&
$section
ne
''
?
"#$section"
:
''
));
}
}
return
$self
->SUPER::resolve_pod_link_by_table(
$to
,
$section
);
}
sub
resolve_man_page_link {
my
(
$self
,
$to
,
$frag
) =
@_
;
my
(
$page
,
$section
) =
$to
=~ /^([^(]+)(?:[(](\d+)\w*[)])?$/;
return
undef
unless
defined
$page
and
length
$page
;
$section
||= 1;
return
$self
->man_url_prefix .
"$section/"
.
$self
->manpage_url_escape(
$page
)
.
$self
->man_url_postfix;
}
sub
version_tag_comment {
my
$self
=
shift
;
my
$pod_simple_html_version
= Pod::Simple::HTML->VERSION;
my
$str
=
<<"HERE";
generated by $FindBin::Script - DO NOT EDIT
using subclassed Pod::Simple::HTML version $pod_simple_html_version under Perl $]
HERE
$str
= HTML::Entities::encode_entities (
$str
);
return
<<"HERE";
<!--
$str-->
HERE
}
}
my
$pod2html
= MyPod2HTML->new;
$pod2html
->title_postfix(
' Man Page'
);
$pod2html
->top_anchor(
undef
);
{
my
$str
=
$pod2html
->html_header_after_title;
$str
=~ s{</head>}{<meta name=
"viewport"
content=
"width=device-width"
>\n</head>} or
die
;
if
(
$local_links
) {
}
$pod2html
->html_header_after_title(
$str
);
}
if
(!
@ARGV
) {
die
"no filename given"
;
}
$pod2html
->output_string(\
my
$str
);
$pod2html
->parse_file(
@ARGV
);
$str
=~ s{<code>(M-x.*?)</code>}{<kbd>$1</kbd>}ig;
print
$str
;
exit
0;