Fix menu expanded on list of tables and figures

This commit is contained in:
Hendrik Kleinwaechter
2023-08-18 17:23:20 +02:00
parent 7adea5625d
commit d02124bcfb

View File

@@ -58,6 +58,7 @@ class ModifyBuild
text = add_text_to_coverpage(text, extract_file_from_path(filename))
text = fix_js_dependency_link(text)
text = fix_list_of_tables_figures_duplicates(text)
text = fix_menus_list_figures_tables(text) if is_list_figures_tables?(text)
File.open(filename, "w") {|file| file.puts text }
end
@@ -67,6 +68,12 @@ class ModifyBuild
end
end
def is_list_figures_tables?(filename)
["listfigurename.html", "listtablename.html"].any? do |name|
filename.include?(name)
end
end
def list_of_files_to_modify
Dir.glob("#{build_dir}/*.html")
end
@@ -511,6 +518,20 @@ class ModifyBuild
doc.to_html
end
# The list of tables for some reason expands the menu on other pages? Fix
# this.
def fix_menus_list_figures_tables(text)
doc = build_doc(text)
content = doc.css(".menu-items > .subsectionToc, .menu-items > .sectionToc")
content.each do |node|
node.remove
end
doc.css(".menu-items > .lotToc").each(&:remove)
doc.css(".menu-items > .lofToc").each(&:remove)
doc.css(".menu-items > br").each(&:remove)
doc.to_html
end
# For some reason the depdency is missing a // in the url.
def fix_js_dependency_link(text)
text.gsub("https:/cdn.jsdelivr.net", "https://cdn.jsdelivr.net")