summaryrefslogtreecommitdiff
path: root/src/index.rb
diff options
context:
space:
mode:
authorBenjamin Ragheb <ben@benzado.com>2022-11-05 15:47:18 -0400
committerGitHub <noreply@github.com>2022-11-05 15:47:18 -0400
commit71bdea9d51faabb54fb0d5e8668dcc1610aa87c1 (patch)
tree8370dbca28b20977cfd8e4b58d00469c9d7f85ed /src/index.rb
parent11fb1559b94ab61bd4678de3352ad8ddd0997dc7 (diff)
parent3c014cde4c3b533c045e6440fb509243582a3ac9 (diff)
Merge pull request #3 from benzado/newer-doc-titles
Newer document titles
Diffstat (limited to 'src/index.rb')
-rwxr-xr-xsrc/index.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/index.rb b/src/index.rb
index c719fcc..da58535 100755
--- a/src/index.rb
+++ b/src/index.rb
@@ -9,7 +9,7 @@ INSERT_SQL = %Q[
INSERT INTO searchIndex(name, type, path) VALUES ('%s','%s','%s');
]
-PATTERN = %r[<title>GNU make: (.+)</title>]
+PATTERN = %r[<title>(.+)</title>]
def quote(s)
s.gsub(/&amp;/, '&').gsub(/'/, "\\'")
@@ -19,9 +19,12 @@ ARGV.each do |arg|
Pathname.glob(arg) do |path|
match = path.each_line.lazy.map { |line| PATTERN.match(line) }.find { |m| m }
if match
- printf INSERT_SQL, quote(match[1]), 'Guide', path.basename
+ title = match[1]
+ title.delete_prefix!('GNU make: ') # older docs
+ title.delete_suffix!(' (GNU make)') # newer docs
+ printf INSERT_SQL, quote(title), 'Guide', path.basename
else
- $stderr.puts "%{path.basename}: no title found"
+ $stderr.puts "#{path}: no title found"
end
end
end