Skip to content

Commit f65a2ef

Browse files
Fix chapter title generation in algebra-1
1 parent 4866c4a commit f65a2ef

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

lib/recipes/algebra-1/recipe.rb

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@
5454
classes: notes,
5555
options: { bake_subtitle: true })
5656

57-
BakeChapterTitle.v2(
58-
chapters: book.units.chapters,
59-
numbering_options: {
60-
mode: :unit_chapter_page,
61-
unit_offset: -2,
62-
chapter_offset: -1
63-
}
64-
)
57+
skipped_units = book.units("$[#{unnumbered_unit_marker}]").count - 1
58+
book.units.each do |unit|
59+
skipped_chapters = unit.search("$[#{unnumbered_chapter_marker}]").count - 1
60+
numbering_options = { mode: :unit_chapter_page,
61+
unit_offset: -skipped_units,
62+
chapter_offset: -skipped_chapters }
63+
BakeChapterTitle.v2(chapters: unit.chapters, numbering_options: numbering_options)
64+
end
6565

6666
chapter_numbering_options = {
6767
unnumbered: { mode: :chapter_page, page_offset: -1 },
@@ -186,7 +186,6 @@
186186
)
187187
end
188188

189-
skipped_units = book.units("$[#{unnumbered_unit_marker}]").count - 1
190189
BakeToc.v1(
191190
book: book,
192191
options: {
@@ -211,7 +210,7 @@
211210
HTML
212211
else
213212
unit = chapter.ancestor(:unit)
214-
skipped_chapters = unit.chapters("$[#{unnumbered_chapter_marker}]").count - 1
213+
skipped_chapters = unit.search("$[#{unnumbered_chapter_marker}]").count - 1
215214
number = chapter.os_number({ mode: :unit_chapter_page,
216215
unit_offset: -skipped_units,
217216
chapter_offset: -skipped_chapters })

0 commit comments

Comments
 (0)