Skip to content

Commit 6f37cab

Browse files
committed
make rubocop and rspec happy
1 parent afcbbb1 commit 6f37cab

2 files changed

Lines changed: 33 additions & 8 deletions

File tree

lib/ucpec_static/tei/elements/body.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module TEI
55
module Elements
66
class Body < UCPECStatic::TEI::Nodes::Element
77
before_prepare_html :collect_chapters!
8-
8+
99
around_render_children :render_with_toc!
1010

1111
matches_tei_tag! "body"
@@ -26,22 +26,22 @@ def has_chapters?
2626
# @return [void]
2727
def collect_chapters!
2828
@chapters = []
29-
29+
3030
# Traverse all descendants to find any division element with type="chapter"
3131
traverse do |node|
3232
next unless node.kind_of?(Elements::Division)
3333
next unless node.xml_attributes["type"] == "chapter"
34-
34+
3535
chapter_id = node.xml_attributes["id"]
3636
next if chapter_id.blank?
37-
37+
3838
# Find the heading within this chapter
3939
heading = node.find_first_descendant { |child| child.kind_of?(Elements::Heading) }
4040
next unless heading
41-
41+
4242
# Extract the heading text
4343
heading_text = extract_heading_text(heading)
44-
44+
4545
@chapters << {
4646
id: chapter_id,
4747
title: heading_text,
@@ -71,7 +71,7 @@ def render_table_of_contents!
7171
wrap_with_tag!("h1", class: "toc-title") do
7272
html_builder.text "Table of Contents"
7373
end
74-
74+
7575
wrap_with_tag!("ol", class: "toc-list") do
7676
chapters.each do |chapter|
7777
wrap_with_tag!("li", class: "toc-item") do

spec/data/sample-tei.html

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,32 @@ <h1>The Hellenistic Settlements in Europe, the Islands, and Asia Minor</h1>
77
<div data-tei-tag="docImprint"><span data-tei-tag="publisher">UNIVERSITY OF CALIFORNIA PRESS</span><span data-tei-tag="pubPlace">Berkeley · Los Angeles · Oxford</span><time data-tei-tag="docDate">1996</time></div>
88
</div>
99
</header>
10-
<section data-tei-tag="body">
10+
<section data-tei-tag="body"><nav class="table-of-contents">
11+
<h1 class="toc-title">Table of Contents</h1>
12+
<ol class="toc-list">
13+
<li class="toc-item"><a href="#d0e111" class="toc-link">The Scholarship and the Sources</a></li>
14+
<li class="toc-item"><a href="#d0e796" class="toc-link">Introduction</a></li>
15+
<li class="toc-item"><a href="#d0e3680" class="toc-link">I Illyria and Epirus</a></li>
16+
<li class="toc-item"><a href="#d0e4087" class="toc-link">II Thrace</a></li>
17+
<li class="toc-item"><a href="#d0e4913" class="toc-link">III Macedonia and Paeonia</a></li>
18+
<li class="toc-item"><a href="#d0e6850" class="toc-link">IV Thessaly, Aetolia, and Boeotia</a></li>
19+
<li class="toc-item"><a href="#d0e8237" class="toc-link">V The Peloponnese</a></li>
20+
<li class="toc-item"><a href="#d0e9000" class="toc-link">VI The Islands</a></li>
21+
<li class="toc-item"><a href="#d0e10071" class="toc-link">VII The Troad</a></li>
22+
<li class="toc-item"><a href="#d0e11686" class="toc-link">VIII Mysia and Aeolis</a></li>
23+
<li class="toc-item"><a href="#d0e12900" class="toc-link">IX Ionia</a></li>
24+
<li class="toc-item"><a href="#d0e14550" class="toc-link">X Lydia</a></li>
25+
<li class="toc-item"><a href="#d0e20532" class="toc-link">XI Caria</a></li>
26+
<li class="toc-item"><a href="#d0e24224" class="toc-link">XII Phrygia</a></li>
27+
<li class="toc-item"><a href="#d0e30625" class="toc-link">XIII Lycia</a></li>
28+
<li class="toc-item"><a href="#d0e30899" class="toc-link">XIV Pamphylia</a></li>
29+
<li class="toc-item"><a href="#d0e31740" class="toc-link">XV Pisidia and Lycaonia</a></li>
30+
<li class="toc-item"><a href="#d0e32521" class="toc-link">XVI Cilicia</a></li>
31+
<li class="toc-item"><a href="#d0e35047" class="toc-link">XVII Cappadocia and Galatia</a></li>
32+
<li class="toc-item"><a href="#d0e35773" class="toc-link">XVIII Pontus and Paphlagonia</a></li>
33+
<li class="toc-item"><a href="#d0e36491" class="toc-link">XIX Bithynia</a></li>
34+
</ol>
35+
</nav>
1136
<div id="d0e111" data-tei-tag="div1" data-type="chapter">
1237
<h1 class="Heading-Heading2B"><a href="#d0e111" class="heading-link">The Scholarship and the Sources</a></h1>
1338
<div id="d0e115" data-tei-tag="div2" data-type="ss1">

0 commit comments

Comments
 (0)