Skip to content

Commit

Permalink
Revert "static ToC, correct header processing; metanorma/isodoc#113; m…
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Apr 21, 2020
1 parent d271b37 commit 2637489
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
26 changes: 21 additions & 5 deletions lib/isodoc/iso/html/scripts.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
<script>
$("#toc").on('click', 'li', function(e) {
$(this).parent().find('li.toc-active').removeClass('toc-active');
$(this).addClass('toc-active');
});
<script>
//TOC generation
$('#toc').toc({
//'selectors': 'h1,h2:not(.TermNum)', //elements to use as headings
'selectors': toclevel(), //elements to use as headings
'container': 'main', //element to find all selectors in
'smoothScrolling': true, //enable or disable smooth scrolling on click
'prefix': 'toc', //prefix for anchor tags and class names
'onHighlight': function(el) {}, //called when a new section is highlighted
'highlightOnScroll': true, //add class to heading that is currently in focus
'highlightOffset': 100, //offset to trigger the next headline
'anchorName': function(i, heading, prefix) { //custom function for anchor name
return prefix+i;
},
'headerText': function(i, heading, $heading) { //custom function building the header-item text
return $heading.text();
},
'itemClass': function(i, heading, $heading, prefix) { // custom function for item class
return $heading[0].tagName.toLowerCase();
}
});
</script>

<script>
Expand Down
10 changes: 5 additions & 5 deletions spec/isodoc/postproc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -285,16 +285,16 @@
<main xmlns:epub="epub" class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
<p class="zzSTDTitle1"></p>
<div id="A">
<h1 id="toc0">1&#xA0; Clause 4</h1>
<h1>1&#xA0; Clause 4</h1>
<a rel="footnote" href="#fn:3" epub:type="footnote" id="fnref:1">
<sup>1)</sup>
</a>
<div id="N">

<h2 id="toc1">1.1&#xA0; Introduction to this<a rel="footnote" href="#fn:2" epub:type="footnote" id="fnref:2"><sup>2)</sup></a></h2>
<h2>1.1&#xA0; Introduction to this<a rel="footnote" href="#fn:2" epub:type="footnote" id="fnref:2"><sup>2)</sup></a></h2>
</div>
<div id="O">
<h2 id="toc2">1.2&#xA0; Clause 4.2</h2>
<h2>1.2&#xA0; Clause 4.2</h2>
<p>A<a rel="footnote" href="#fn:2" epub:type="footnote"><sup>2)</sup></a></p>
</div>
</div>
Expand Down Expand Up @@ -459,7 +459,7 @@
<main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
<br />
<div>
<h1 class="ForewordTitle" id="toc0">Foreword</h1>
<h1 class="ForewordTitle">Foreword</h1>
<div id="_" class="figure">
<img src="test_htmlimages/_.png" height="776" width="922" />
<img src="test_htmlimages/_.png" height="800" width="53" />
Expand Down Expand Up @@ -826,7 +826,7 @@
sub(%r{</main>.*$}m, "</main>").sub(%r{^.*?<div>}m, "<div>").sub(%r{</div>.*$}m, "</div>")
expect(xmlpp(html)).to be_equivalent_to xmlpp(<<~"OUTPUT")
<div>
<h1 class='ForewordTitle' id="toc0">Foreword</h1>
<h1 class='ForewordTitle'>Foreword</h1>
<p>
<a href='#scope'>Clause 1</a>
<a href='#terms'>Clause 3</a>
Expand Down
2 changes: 1 addition & 1 deletion spec/isodoc/table_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<button onclick='topFunction()' id='myBtn' title='Go to top'>Top</button>
<br/>
<div>
<h1 class='ForewordTitle' id="toc0">Foreword</h1>
<h1 class='ForewordTitle'>Foreword</h1>
<p class='TableTitle' style='text-align:center;'>
Table 1&#xA0;&#x2014; Repeatability and reproducibility of
<i>husked</i>
Expand Down
2 changes: 1 addition & 1 deletion spec/metanorma/processor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
expect(xmlpp(File.read("test.html", encoding: "utf-8").gsub(%r{^.*<main}m, "<main").gsub(%r{</main>.*}m, "</main>"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
<p class="zzSTDTitle1"></p>
<div id="H"><h1 id="toc0">1&#xA0; Terms and definitions</h1>
<div id="H"><h1>1&#xA0; Terms and definitions</h1>
<h2 class="TermNum" id="J">1.1</h2>
<p class="Terms" style="text-align:left;">Term2</p>
</div>
Expand Down

0 comments on commit 2637489

Please sign in to comment.