48 |
} |
} |
49 |
$contents =~ s,(<title>)([^<]+)(</title>),$1$2: $title$3,gsi if ($title); |
$contents =~ s,(<title>)([^<]+)(</title>),$1$2: $title$3,gsi if ($title); |
50 |
|
|
51 |
|
} elsif ($contents =~ m,<!--\s+METADATA(.*?)METADATA\s+-->,is) { |
52 |
|
# LJ metadata |
53 |
|
my $metadata = $1; |
54 |
|
my $title = "LJ"; |
55 |
|
|
56 |
|
$title .= "$1: " if ($metadata =~ m,<issue>(.+?)</issue>,is); |
57 |
|
$title .= "$1 - " if ($metadata =~ m,<category>(.+?)</category>,is); |
58 |
|
$title .= $1 if ($metadata =~ m,<title>(.+?)</title>,is); |
59 |
|
$title =~ s/\s+/ /gsi; |
60 |
|
$contents =~ s,<title>[^<]+</title>,<title>$title</title>,is; |
61 |
} |
} |
62 |
|
|
63 |
# is second argument collection? |
# is second argument collection? |
68 |
|
|
69 |
if ($contents =~ m,<!--SafTocEntry="([^"]+)"-->,is) { |
if ($contents =~ m,<!--SafTocEntry="([^"]+)"-->,is) { |
70 |
$new_title = $1; |
$new_title = $1; |
71 |
} elsif ($contents =~ m,<(h\d)\sclass="docPartTitle"[^>]*>(.+?)<\1>,is) { |
print STDERR "using title '$new_title' from <!--SafTocEntry-->\n" if ($verbose); |
72 |
|
} elsif ($contents =~ m,<(h\d)\s+class="docPartTitle"[^>]*>(.+?)</\1>,is) { |
73 |
|
$new_title = $2; |
74 |
|
print STDERR "using title '$new_title' from docPartTitle\n" if ($verbose); |
75 |
|
} elsif ($contents =~ m,<(h\d)\s+class="docChapterTitle"[^>]*>(.+?)</\1>,is) { |
76 |
$new_title = $2; |
$new_title = $2; |
77 |
} elsif ($contents =~ m,<(h\d)\sclass="docChapterTitle"[^>]*>(.+?)<\1>,is) { |
print STDERR "using title '$new_title' from docChapterTitle\n" if ($verbose); |
78 |
|
} elsif ($contents =~ m,<(h\d)\s+class="docSection1Title"[^>]*>(.+?)</\1>,is) { |
79 |
$new_title = $2; |
$new_title = $2; |
80 |
} elsif ($contents =~ m,<(h\d)\sclass="docSection1Title"[^>]*>(.+?)<\1>,is) { |
print STDERR "using title '$new_title' from docSection1Title\n" if ($verbose); |
81 |
|
} elsif ($contents =~ m,<(h\d)\s+class="doc[^"]*Title"[^>]*>(.+?)</\1>,is) { |
82 |
$new_title = $2; |
$new_title = $2; |
83 |
} elsif ($contents =~ m,<(h\d)\sclass="chapter"[^>]*>(.+?)<\1>,is) { |
print STDERR "using title '$new_title' from doc.+Title\n" if ($verbose); |
84 |
|
} elsif ($contents =~ m,<(h\d)\s+class="chapter"[^>]*>(.+?)</\1>,is) { |
85 |
$new_title = $2; |
$new_title = $2; |
86 |
} elsif ($contents =~ m,<(h\d)\sclass="sect1"[^>]*>(.+?)<\1>,is) { |
print STDERR "using title '$new_title' from chapter\n" if ($verbose); |
87 |
|
} elsif ($contents =~ m,<(h\d)\s+class="sect1"[^>]*>(.+?)</\1>,is) { |
88 |
$new_title = $2; |
$new_title = $2; |
89 |
|
print STDERR "using title '$new_title' from sect1\n" if ($verbose); |
90 |
} else { |
} else { |
91 |
if ($contents =~ m,<title>([^<]+)</title>,is) { |
if ($contents =~ m,<title>([^<]+)</title>,is) { |
92 |
$new_title = $1; |
$new_title = $1; |
93 |
|
print STDERR "using title '$new_title' from <title>\n" if ($verbose); |
94 |
} elsif ($contents =~ m,<h\d[^>]*>([^<]+)</h\d>,is) { |
} elsif ($contents =~ m,<h\d[^>]*>([^<]+)</h\d>,is) { |
95 |
$new_title = $1; |
$new_title = $1; |
96 |
|
print STDERR "using title '$new_title' from <h_>\n" if ($verbose); |
97 |
} |
} |
98 |
} |
} |
99 |
|
|
108 |
$b =~ s/([^a-zA-Z])+/ /gs; |
$b =~ s/([^a-zA-Z])+/ /gs; |
109 |
if ($a =~ m/$b/i) { |
if ($a =~ m/$b/i) { |
110 |
$new_title = $collection; |
$new_title = $collection; |
111 |
|
print STDERR "new_title and collection are same! [$new_title]\n" if ($verbose); |
112 |
} else { |
} else { |
113 |
$new_title = "$collection :: $new_title"; |
$new_title = "$collection :: $new_title"; |
114 |
} |
} |