docs/gen-html-index: Extract titles from HTML documents

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
Acked-by: Lars Kurth <lars.kurth@citrix.com>
This commit is contained in:
Ian Jackson authored and Ian Jackson committed 2018-04-12 16:13:39 +01:00
1 parent a569c6f815
commit 7782db9260
1 file changed
+13
+13
View File
@@ -10,6 +10,7 @@ use warnings;
use Getopt::Long; use Getopt::Long;
use IO::File; use IO::File;
use File::Basename; use File::Basename;
use HTML::TreeBuilder::XPath;
Getopt::Long::Configure('bundling'); Getopt::Long::Configure('bundling');
@@ -64,6 +65,18 @@ sub make_linktext ($) {
return "$1($2)" if $l =~ m,^man/(.*)\.([0-9].*)\.html,; return "$1($2)" if $l =~ m,^man/(.*)\.([0-9].*)\.html,;
$l =~ s/.(?:html|txt)$//g; $l =~ s/.(?:html|txt)$//g;
return $index{$l} if exists $index{$l}; return $index{$l} if exists $index{$l};
my $from_html;
eval {
my $tree = new HTML::TreeBuilder::XPath;
my $f = "$outdir/$l.html";
open F, '<', $f or die "$l $f $!";
$tree->parse_file(\*F) or die;
close F;
$from_html = $tree->findvalue("/html/head/title");
};
return $from_html if $from_html;
return basename($l); return basename($l);
} }
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.