+sub replace_default_xref {
+ my ($blockid, $text) = @_;
+
+ my $link = $fileinfo->{blockid_target}->{default}->{$blockid};
+ my $reftext = $fileinfo->{reftext}->{default}->{$blockid};
+
+ die "unable to resolve chapter link (xref:$blockid)\n"
+ if !defined($link);
+
+ $text = $reftext if !length($text);
+
+ die "xref: no text for chapter link '$blockid'\n" if !$text;
+
+ return "$link\[$text\]";
+}
+
+sub replace_man_xref {
+ my ($blockid, $text) = @_;
+
+ my $link = $fileinfo->{blockid_target}->{manvolnum}->{$blockid};
+ my $reftext = $fileinfo->{reftext}->{manvolnum}->{$blockid};
+
+ die "unable to resolve man page link (xref:$blockid)\n"
+ if !defined($link);
+
+ $text = $reftext if !length($text);
+
+ die "xref: no text for man page link '$blockid'\n" if !$text;
+
+ my $section = $fileinfo->{mansection}->{manvolnum}->{$link};
+ die "link target is not a manual page" if !defined($section);
+
+
+ if (0 && $man_target_html) {
+ my $target = $link;
+ $target =~ s/\.adoc//;
+ $target .= ".$section";
+ return "link:${target}.html#${blockid}\[$text\]";
+ } else {
+ my $command = $link;
+ $command =~ s/\.adoc//;
+ return "\*${text}\* (man \*${command}\*($section))";
+ }
+}
+