Skip to content

Commit

Permalink
static ToC, correct header processing; metanorma/isodoc#113; metanorm…
Browse files Browse the repository at this point in the history
  • Loading branch information
opoudjis committed Apr 21, 2020
1 parent deda061 commit 480711b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 23 deletions.
24 changes: 4 additions & 20 deletions lib/isodoc/itu/html/scripts.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
<script>
//TOC generation
$('#toc').toc({
'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();
}
});

$("#toc").on('click', 'li', function(e) {
$(this).parent().find('li.toc-active').removeClass('toc-active');
$(this).addClass('toc-active');
});
</script>

<script>
Expand Down
4 changes: 2 additions & 2 deletions spec/isodoc/ituconvert_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
<main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
<p class="zzSTDTitle1"></p>
<p class="zzSTDTitle2"></p>
<div id="H"><h1>1&#xA0; Definitions</h1>
<div id="H"><h1 id="toc0">1&#xA0; Definitions</h1>
<div id="J"><p class="TermNum" id="J"><b>1.1&#xA0; Term2</b> [XYZ]: This is a journey into sound</p>
Expand Down Expand Up @@ -549,7 +549,7 @@
<main xmlns:epub='epub' class='main-section'>
<button onclick='topFunction()' id='myBtn' title='Go to top'>Top</button>
<div>
<h1 class='IntroTitle' id='toc0'/>
<h1 class='IntroTitle'/>
<p>
A.
<a rel='footnote' href='#fn:2' epub:type='footnote' id='fnref:1'>
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 @@ -50,7 +50,7 @@
<p class="zzSTDTitle1"></p>
<p class="zzSTDTitle2"></p>
<div id="H">
<h1>1&#xA0; Definitions</h1>
<h1 id="toc0">1&#xA0; Definitions</h1>
<div id="J"><p class="TermNum" id="J"><b>1.1&#xA0; Term2</b>:</p>
</div>
Expand Down

0 comments on commit 480711b

Please sign in to comment.