projects
/
pve-docs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
17d8be0
)
asciidoc-pve.in: cleanup for code reuse
author
Dietmar Maurer
<dietmar@proxmox.com>
Mon, 10 Oct 2016 08:41:27 +0000
(10:41 +0200)
committer
Dietmar Maurer
<dietmar@proxmox.com>
Mon, 10 Oct 2016 08:42:14 +0000
(10:42 +0200)
asciidoc-pve.in
patch
|
blob
|
history
diff --git
a/asciidoc-pve.in
b/asciidoc-pve.in
index
0e17b7a
..
b578556
100644
(file)
--- a/
asciidoc-pve.in
+++ b/
asciidoc-pve.in
@@
-82,9
+82,18
@@
sub replace_wiki_xref {
return "$link\[$text\]";
}
return "$link\[$text\]";
}
-sub
prepare_adoc_file
{
- my ($
filename, $attributes
) = @_;
+sub
replace_xref
{
+ my ($
env, $blockid, $text
) = @_;
+ if ($env eq 'wiki') {
+ return replace_wiki_xref($blockid, $text);
+ } else {
+ die "implement me";
+ }
+}
+
+sub prepare_adoc_file {
+ my ($target_env, $filename, $attributes) = @_;
return if $prepared_files->{$filename};
return if $prepared_files->{$filename};
@@
-125,14
+134,14
@@
sub prepare_adoc_file {
if ($line =~ m/^include::(\S+)(\[.*\]\s*)$/) {
my ($fn, $rest) = ($1, $2);
print "INCLUDE: $fn\n";
if ($line =~ m/^include::(\S+)(\[.*\]\s*)$/) {
my ($fn, $rest) = ($1, $2);
print "INCLUDE: $fn\n";
- my $new_fn = prepare_adoc_file($fn, $attributes);
+ my $new_fn = prepare_adoc_file($
target_env, $
fn, $attributes);
$line = "include::${new_fn}$rest\n";
}
# fix xrefs
$line = "include::${new_fn}$rest\n";
}
# fix xrefs
- $line =~ s/xref:([^\s\[\]]+)\[([^\]]*)\]/replace_
wiki_xref(
$1,$2)/ge;
+ $line =~ s/xref:([^\s\[\]]+)\[([^\]]*)\]/replace_
xref(${target_env},
$1,$2)/ge;
- $line =~ s/<<([^\s,\[\]]+)(?:,(.*?))?>>/replace_
wiki_xref(
$1,$2)/ge;
+ $line =~ s/<<([^\s,\[\]]+)(?:,(.*?))?>>/replace_
xref(${target_env},
$1,$2)/ge;
print $outfh $line;
}
print $outfh $line;
}
@@
-140,11
+149,11
@@
sub prepare_adoc_file {
return $outfilename;
}
return $outfilename;
}
-sub compile_wiki {
+sub compile_asciidoc {
+ my ($env) = @_;
my $verbose;
my $outfile;
my $verbose;
my $outfile;
- my $target_env;
GetOptions ("outfile=s" => \$outfile,
"verbose" => \$verbose) or
GetOptions ("outfile=s" => \$outfile,
"verbose" => \$verbose) or
@@
-156,13
+165,16
@@
sub compile_wiki {
scalar(@ARGV) == 0 or
die "too many arguments...\n";
scalar(@ARGV) == 0 or
die "too many arguments...\n";
- my $env = 'wiki';
+ if ($env eq 'wiki') {
+ } else {
+ die "unknown environment '$env'";
+ }
+
my $title = $fileinfo->{titles}->{$env}->{$infile} or
die "unable to get title for '$infile'\n";
my $title = $fileinfo->{titles}->{$env}->{$infile} or
die "unable to get title for '$infile'\n";
-
print "compile: $title\n";
my $leveloffset = 0;
print "compile: $title\n";
my $leveloffset = 0;
@@
-182,6
+194,10
@@
sub compile_wiki {
revnumber => $release,
};
revnumber => $release,
};
+ if (!($env eq 'wiki') || ($env ne 'manvolnum')) {
+ $attributes->{toc} = undef;
+ }
+
my $cmd = ['asciidoc', '-s'];
foreach my $key (keys %$attributes) {
my $cmd = ['asciidoc', '-s'];
foreach my $key (keys %$attributes) {
@@
-203,7
+219,7
@@
sub compile_wiki {
push @$cmd, '--out-file', $outfile;
push @$cmd, '--out-file', $outfile;
- my $new_infile = prepare_adoc_file($infile, $attributes);
+ my $new_infile = prepare_adoc_file($
env, $
infile, $attributes);
push @$cmd, $new_infile;
push @$cmd, $new_infile;
@@
-213,9
+229,10
@@
sub compile_wiki {
die "aciidoc error";
}
die "aciidoc error";
}
+
if ($clicmd eq 'compile-wiki') {
if ($clicmd eq 'compile-wiki') {
- eval { compile_
wiki(
); };
+ eval { compile_
asciidoc('wiki'
); };
my $err = $@;
cleanup();
my $err = $@;
cleanup();