+ if ($env eq 'manvolnum') {
+ if (($man_target eq 'html') || ($man_target eq 'wiki')) {
+ $outfile .= ".$mansection.html";
+ } else {
+ $outfile .= ".$mansection";
+ }
+ } else {
+ $outfile .= ".html";
+ }
+ }
+
+ if (($env eq 'manvolnum') && ($man_target eq 'man')) {
+
+ # asciidoc /etc/asciidoc/docbook-xsl/manpage.xsl skip REFERENCES
+ # section like footnotes, so we cannot use a2x.
+ # We use xmlto instead.
+
+ my $cmd = ['asciidoc', '-dmanpage', '-bdocbook', '-a', 'docinfo1'];
+
+ foreach my $key (keys %$attributes) {
+ my $value = $attributes->{$key};
+ if (defined($value)) {
+ push @$cmd, '-a', "$key=$value";
+ } else {
+ push @$cmd, '-a', $key;
+ }
+ }
+
+ push @$cmd, '--verbose' if $verbose;
+
+ my $tmpxmlfile = "${outfile}.xml.tmp";
+
+ push @$cmd, '--out-file', $tmpxmlfile;
+
+ push @$files_for_cleanup, $tmpxmlfile;
+
+ my $new_infile = prepare_adoc_file($env, $infile, $attributes);
+
+ push @$cmd, $new_infile;
+
+ debug("run " . join(' ', @$cmd));
+
+ system(@$cmd) == 0 or
+ die "aciidoc error";
+
+ $cmd = ['xmlto', 'man', $tmpxmlfile];
+
+ push @$cmd, '-v' if $verbose;
+
+ debug("run " . join(' ', @$cmd));
+
+ system(@$cmd) == 0 or
+ die "xmlto error";
+
+ } else {
+
+ $attributes->{icons} = undef;
+ $attributes->{'data-uri'} = undef;
+
+ my $cmd = ['asciidoc'];
+
+ if (($env eq 'wiki') ||
+ (($env eq 'manvolnum') && ($man_target eq 'wiki'))) {
+
+ push @$cmd, '-s';
+
+ if (-f "./asciidoc/mediawiki.conf") {
+ my $cwd = getcwd();
+ push @$cmd, '-b', "$cwd/asciidoc/mediawiki";
+ } else {
+ push @$cmd, '-b', "mediawiki";
+ }
+ }
+
+ foreach my $key (keys %$attributes) {
+ my $value = $attributes->{$key};
+ if (defined($value)) {
+ push @$cmd, '-a', "$key=$value";
+ } else {
+ push @$cmd, '-a', $key;
+ }
+ }
+
+ push @$cmd, '--verbose' if $verbose;
+
+ push @$cmd, '--out-file', $outfile;
+
+ my $new_infile = prepare_adoc_file($env, $infile, $attributes);
+
+ push @$cmd, $new_infile;
+
+ debug("run " . join(' ', @$cmd));
+
+ system(@$cmd) == 0 or
+ die "aciidoc error";
+ }
+}
+
+sub get_links {
+
+ my $data = {};
+
+ foreach my $blockid (sort keys %{$fileinfo->{blockid_target}->{default}}) {
+ my $link = $fileinfo->{blockid_target}->{default}->{$blockid};
+ my $reftitle = $fileinfo->{reftitle}->{default}->{$blockid};
+ my $reftext = $fileinfo->{reftext}->{default}->{$blockid};
+ die "internal error" if $link !~ m/^link:/;
+ $link =~ s/^link://;
+
+ my $file = $fileinfo->{blockid}->{default}->{$blockid};
+ die "internal error - no filename" if ! defined($file);
+ my $title = $fileinfo->{titles}->{default}->{$file} ||
+ die "internal error - no title";
+
+ $data->{$blockid}->{title} = $title;
+ $data->{$blockid}->{link} = $link;
+ my $subtitle = $reftitle || $reftext;
+ $data->{$blockid}->{subtitle} = $subtitle
+ if $subtitle && ($title ne $subtitle);