mirror of
https://github.com/hendricius/the-sourdough-framework
synced 2025-11-30 06:43:59 -06:00
Make audax happy, add anchors to glossary terms (#343)
* Add .DS_Store to ignore for Mac users * Permalinks to glossary terms
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -15,6 +15,7 @@
|
|||||||
*.dlog
|
*.dlog
|
||||||
*.bak
|
*.bak
|
||||||
*.opf
|
*.opf
|
||||||
|
.DS_Store
|
||||||
book/book.out
|
book/book.out
|
||||||
.vscode/
|
.vscode/
|
||||||
book/bookch*
|
book/bookch*
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ GEM
|
|||||||
method_source (1.0.0)
|
method_source (1.0.0)
|
||||||
nokogiri (1.15.3-arm64-darwin)
|
nokogiri (1.15.3-arm64-darwin)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
|
nokogiri (1.15.3-x86_64-darwin)
|
||||||
|
racc (~> 1.4)
|
||||||
nokogiri (1.15.3-x86_64-linux)
|
nokogiri (1.15.3-x86_64-linux)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
pry (0.14.2)
|
pry (0.14.2)
|
||||||
@@ -14,6 +16,7 @@ GEM
|
|||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
arm64-darwin-22
|
arm64-darwin-22
|
||||||
|
x86_64-darwin-22
|
||||||
x86_64-linux
|
x86_64-linux
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ class ModifyBuild
|
|||||||
text = fix_list_of_tables_figures_duplicates(text)
|
text = fix_list_of_tables_figures_duplicates(text)
|
||||||
text = add_anchors_to_headers(text)
|
text = add_anchors_to_headers(text)
|
||||||
text = fix_https_links(text)
|
text = fix_https_links(text)
|
||||||
|
text = add_anchors_to_glossary_items(text) if is_glossary_page?(filename)
|
||||||
text = fix_menus_list_figures_tables(text) if is_list_figures_tables?(filename)
|
text = fix_menus_list_figures_tables(text) if is_list_figures_tables?(filename)
|
||||||
text = fix_list_of_figures_tables_display(text) if is_list_figures_tables?(filename)
|
text = fix_list_of_figures_tables_display(text) if is_list_figures_tables?(filename)
|
||||||
File.open(filename, "w:UTF-8") {|file| file.puts text }
|
File.open(filename, "w:UTF-8") {|file| file.puts text }
|
||||||
@@ -76,6 +77,10 @@ class ModifyBuild
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def is_glossary_page?(filename)
|
||||||
|
filename.include?("Glossary.html")
|
||||||
|
end
|
||||||
|
|
||||||
def is_list_figures_tables?(filename)
|
def is_list_figures_tables?(filename)
|
||||||
["listfigurename.html", "listtablename.html", "listoflocname.html", "bibname.html"].any? do |name|
|
["listfigurename.html", "listtablename.html", "listoflocname.html", "bibname.html"].any? do |name|
|
||||||
filename.include?(name)
|
filename.include?(name)
|
||||||
@@ -499,6 +504,23 @@ class ModifyBuild
|
|||||||
doc.to_html
|
doc.to_html
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def add_anchors_to_glossary_items(text)
|
||||||
|
doc = build_doc(text)
|
||||||
|
content = doc.css("dt.description")
|
||||||
|
content.each do |el|
|
||||||
|
term = el.css("span")[0]
|
||||||
|
item_name = term&.text
|
||||||
|
# No anchor for whatever reason
|
||||||
|
next unless item_name
|
||||||
|
|
||||||
|
anchor = item_name.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
|
||||||
|
copy_link = %Q{<a href="#term-#{anchor}" class="permalink">🔗</a>}
|
||||||
|
el.set_attribute("id", "term-#{anchor}")
|
||||||
|
term.inner_html = "#{term.inner_html}#{copy_link}"
|
||||||
|
end
|
||||||
|
doc.to_html
|
||||||
|
end
|
||||||
|
|
||||||
def build_cover_page_content
|
def build_cover_page_content
|
||||||
%Q{
|
%Q{
|
||||||
<h2 class="chapterHead home-title">
|
<h2 class="chapterHead home-title">
|
||||||
|
|||||||
Reference in New Issue
Block a user