]> git.proxmox.com Git - pve-docs.git/commitdiff
scan-adoc-refs: improve title parser, store doctype
authorDietmar Maurer <dietmar@proxmox.com>
Sun, 9 Oct 2016 08:08:50 +0000 (10:08 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Sun, 9 Oct 2016 08:08:50 +0000 (10:08 +0200)
We store the titel heading level (0 => chapter, 1 => article).

scan-adoc-refs

index c3ac08f9b4c57623a98741588d6312f21829382f..6563c3534c10041e5f28e050698a13a54a4e582e 100755 (executable)
@@ -122,9 +122,20 @@ sub scan_adoc_file {
            my $title = $fileinfo->{titles}->{$e}->{$filename};
            next if defined($title);
 
-           if (($line =~ m/^=====+/) || ($line =~ m/^-----+/)) {
+           if ($line =~ m/^=====+$/) {
                $fileinfo->{titles}->{$e}->{$filename} = $env_last_line->{$e};
+               $fileinfo->{doctype}->{$e}->{$filename} = 0;
+           } elsif ($line =~ m/^-----+$/) {
+               $fileinfo->{titles}->{$e}->{$filename} = $env_last_line->{$e};
+               $fileinfo->{doctype}->{$e}->{$filename} = 1;
+           } elsif ($line =~ m/^= +(\S.*?)( +=)?$/) {
+               $fileinfo->{titles}->{$e}->{$filename} = $1;
+               $fileinfo->{doctype}->{$e}->{$filename} = 0;
+           } elsif ($line =~ m/^== +(\S.*?)( +==)?$/) {
+               $fileinfo->{titles}->{$e}->{$filename} = $1;
+               $fileinfo->{doctype}->{$e}->{$filename} = 1;
            }
+
            $env_last_line->{$e} = $line;
            chomp $env_last_line->{$e};
        }