Skip to content

Commit 415636d

Browse files
committed
book: work around lagging translations' image paths
At some stage in 2017, the progit2 layout was changed so that all images live in a central location. The `saveImage` method was written with that layout in mind. However, there is at least one translation that has not switched to the new layout yet, and its images are in a location relative to the respective chapters' source files that reference them. Let's make sure that we handle those layouts correctly, too, then. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent b0cc3a9 commit 415636d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

script/update-book2.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,18 @@ def genbook(language_code, &get_content)
182182
content = get_content.call(path)
183183
csection.saveImage(path, content)
184184
rescue Errno::ENOENT
185-
puts "::error::referenced image #{path} does not exit!"
185+
begin
186+
# Try again with a path relative to the chapter's source file. This
187+
# used to be common before progit2's d2152ec3 (New architecture of the
188+
# repository for manual building of the book., 2017-08-28), and not all
189+
# translations (ahem, `progit2-uz`) managed to merge that commit yet.
190+
chapter_filename = chapters["ch#{index}"][2]
191+
path2 = chapter_filename.sub(/[^\/]*$/, path)
192+
content = get_content.call(path2)
193+
csection.saveImage(path, content)
194+
rescue Errno::ENOENT
195+
puts "::error::referenced image #{path} does not exit!"
196+
end
186197
end
187198

188199
book.xrefs[id_xref] = csection

0 commit comments

Comments
 (0)