scan-adoc-refs: allow to overwrite title using attribute
authorDietmar Maurer <dietmar@proxmox.com>
Mon, 10 Oct 2016 06:42:20 +0000 (08:42 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 10 Oct 2016 07:11:51 +0000 (09:11 +0200)
scan-adoc-refs

index 96f5182..3885348 100755 (executable)
@@ -97,7 +97,13 @@ sub register_title {
     $title =~ s!http://\S+\[(.*?)\]!$1!g;
 
     $fileinfo->{titles}->{$env}->{$filename} = $title;
-    $fileinfo->{doctype}->{$env}->{$filename} = $doctype;
+
+    if (defined($doctype)) {
+       $fileinfo->{doctype}->{$env}->{$filename} = $doctype;
+    } else {
+       die "unable to change title (no doctype)"
+           if !defined($fileinfo->{doctype}->{$env}->{$filename});
+    }
 }
 
 sub scan_adoc_file {
@@ -157,6 +163,10 @@ sub scan_adoc_file {
                        if !defined($title);
                    $fileinfo->{toplevel}->{$e}->{$filename} = 1;
                }
+           } elsif ($key eq 'title') {
+               foreach my $e (@{$env_stack->[-1]}) {
+                   register_title($filename, $e, undef, $value);
+               }
            }
        }