Skip to content

Commit

Permalink
Fix list of tables/flowcharts
Browse files Browse the repository at this point in the history
Fixes the order and adds missing link
  • Loading branch information
hendricius committed Dec 12, 2023
1 parent a23e449 commit e138a23
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.DEFAULT_GOAL := build_pdf

DOCKER_IMAGE := ghcr.io/hendricius/the-sourdough-framework
DOCKER_CMD := docker run -it -v $(PWD):/opt/repo $(DOCKER_IMAGE) /bin/bash -c
DOCKER_CMD := docker run -it -v $(PWD):/opt/repo --platform linux/x86_64 $(DOCKER_IMAGE) /bin/bash -c

.PHONY: bake build_pdf build_docker_image push_docker_image validate website
.PHONY: print_os_version start_shell printvars show_tools_version mrproper
Expand Down
18 changes: 16 additions & 2 deletions website/modify_build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ def fix_cover_page(text)
# Users are lost and can't easily access the root page of the book. This
# adds a home menu item.
def add_home_link_to_menu(text)
doc = build_doc(text)
# Remove duplicate menu entries first before building clean menu
doc = build_doc(remove_duplicate_entries_menu(text))

menu = doc.css(".menu-items")[0]
return text if menu.nil?

Expand All @@ -266,7 +268,7 @@ def add_home_link_to_menu(text)
</a>
</span>
<span class="chapterToc">
<a href="listfigurename">
<a href="listfigurename.html">
<span class="link_text">List of Figures</span>
</a>
</span>
Expand All @@ -292,6 +294,18 @@ def add_home_link_to_menu(text)
doc.to_html
end

# Some of the menu links are added in the wrong order. Remove them since we
# later on add them in the structure that we want.
def remove_duplicate_entries_menu(text)
doc = build_doc(text)
remove = ["List of Tables", "List of Figures"]
selected_elements = doc.css(".menu-items .chapterToc > a").select do |el|
remove.include?(el.text)
end
selected_elements.each(&:remove)
doc.to_html
end

# Some of the links in the menu have an anchor. This makes clicking through
# the menu frustrating as the browser jumps a lot on each request. Only do
# this for the top level menu entries though.
Expand Down

0 comments on commit e138a23

Please sign in to comment.