+ # 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'];
+
+ push @$cmd, '-s' if ($env eq 'wiki') ||
+ (($env eq 'manvolnum') && ($man_target eq 'wiki'));
+
+ 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";