mirror of
https://github.com/hendricius/the-sourdough-framework
synced 2025-11-08 12:11:11 -06:00
Fix list tables figures (#305)
* Add links * Fix list of tables/flowcharts Fixes the order and adds missing link
This commit is contained in:
committed by
GitHub
parent
0b550a4666
commit
89f5ab6be3
2
makefile
2
makefile
@@ -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
|
||||
|
||||
@@ -76,7 +76,7 @@ class ModifyBuild
|
||||
end
|
||||
|
||||
def is_list_figures_tables?(filename)
|
||||
["listfigurename.html", "listtablename.html", "listoflocname.html"].any? do |name|
|
||||
["listfigurename.html", "listtablename.html", "listoflocname.html", "bibname.html"].any? do |name|
|
||||
filename.include?(name)
|
||||
end
|
||||
end
|
||||
@@ -245,7 +245,9 @@ class ModifyBuild
|
||||
# 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?
|
||||
|
||||
@@ -260,6 +262,21 @@ class ModifyBuild
|
||||
<span class="link_text">List of Flowcharts</span>
|
||||
</a>
|
||||
</span>
|
||||
<span class="chapterToc">
|
||||
<a href="listtablename.html">
|
||||
<span class="link_text">List of Tables</span>
|
||||
</a>
|
||||
</span>
|
||||
<span class="chapterToc">
|
||||
<a href="listfigurename.html">
|
||||
<span class="link_text">List of Figures</span>
|
||||
</a>
|
||||
</span>
|
||||
<span class="chapterToc">
|
||||
<a href="bibname.html">
|
||||
<span class="link_text">Bibliography</span>
|
||||
</a>
|
||||
</span>
|
||||
<span class="chapterToc">
|
||||
<a href="https://breadco.de/kofi">
|
||||
<span class="chapter_number">⭐️</span>
|
||||
@@ -277,6 +294,18 @@ class ModifyBuild
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user