diff options
author | Jeff King <peff@peff.net> | 2022-10-05 14:01:07 +0300 |
---|---|---|
committer | Jeff King <peff@peff.net> | 2022-10-05 16:28:15 +0300 |
commit | d1c799b1cd92244c80a103e0beccc00c5ce2ade4 (patch) | |
tree | 73ff242f22c8ada920f2a7670007d490ef086d9e | |
parent | c5e8c4d0cd77b301c0a45100ea7b9f94a7c64bfa (diff) |
run rubocop --autocorrect-all --only Style/SafeNavigation
These were made possible by pulling the xlink assignments to their own
line in the previous commit.
-rw-r--r-- | lib/tasks/book2.rake | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/lib/tasks/book2.rake b/lib/tasks/book2.rake index 83d85d26..a0de3930 100644 --- a/lib/tasks/book2.rake +++ b/lib/tasks/book2.rake @@ -137,38 +137,32 @@ def genbook(code, &get_content) html.gsub!(/\/h5>/, "/h4>") xlink = html.scan(/href="1-.*?\.html\#(.*?)"/) - if xlink - xlink.each do |link| - xref = link.first - begin - html.gsub!(/href="1-.*?\.html\##{xref}"/, "href=\"ch00/#{xref}\"") - rescue StandardError - nil - end + xlink&.each do |link| + xref = link.first + begin + html.gsub!(/href="1-.*?\.html\##{xref}"/, "href=\"ch00/#{xref}\"") + rescue StandardError + nil end end xlink = html.scan(/href="\#(.*?)"/) - if xlink - xlink.each do |link| - xref = link.first - begin - html.gsub!(/href="\##{xref}"/, "href=\"ch00/#{xref}\"") - rescue StandardError - nil - end + xlink&.each do |link| + xref = link.first + begin + html.gsub!(/href="\##{xref}"/, "href=\"ch00/#{xref}\"") + rescue StandardError + nil end end subsec = html.scan(/<img src="(.*?)"/) - if subsec - subsec.each do |sub| - sub = sub.first - begin - html.gsub!(/<img src="#{sub}"/, "<img src=\"/book/en/v2/#{sub}\"") - rescue StandardError - nil - end + subsec&.each do |sub| + sub = sub.first + begin + html.gsub!(/<img src="#{sub}"/, "<img src=\"/book/en/v2/#{sub}\"") + rescue StandardError + nil end end |