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 645383e commit 308b34e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 38 deletions.
29 changes: 1 addition & 28 deletions lib/asciidoctor/gb/isodoc.rng
Original file line number Diff line number Diff line change
Expand Up @@ -303,23 +303,8 @@
<ref name="paragraph"/>
</element>
</define>
<define name="TextElement" combine="choice">
<ref name="concept"/>
</define>
</include>
<!-- end overrides -->
<define name="concept">
<element name="concept">
<optional>
<attribute name="term"/>
</optional>
<choice>
<ref name="eref"/>
<ref name="xref"/>
<ref name="termref"/>
</choice>
</element>
</define>
<define name="BasicBlock" combine="choice">
<choice>
<ref name="requirement"/>
Expand Down Expand Up @@ -926,26 +911,14 @@
</define>
<define name="origin">
<element name="origin">
<choice>
<ref name="erefType"/>
<ref name="termref"/>
</choice>
<ref name="erefType"/>
</element>
</define>
<define name="modification">
<element name="modification">
<ref name="paragraph"/>
</element>
</define>
<define name="termref">
<element name="termref">
<attribute name="base"/>
<attribute name="target"/>
<optional>
<text/>
</optional>
</element>
</define>
<define name="structuredidentifier">
<element name="structuredidentifier">
<optional>
Expand Down
26 changes: 21 additions & 5 deletions lib/isodoc/gb/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': 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
8 changes: 4 additions & 4 deletions spec/isodoc/gbconvert_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
expect(xmlpp(html.gsub(/"#[a-f0-9-]+"/, "#_"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
<p class="zzSTDTitle1">XXXX</p>
<div id="_terms_and_definitions"><h1 id="toc0">1.&#x3000;&#x672F;&#x8BED;&#x548C;&#x5B9A;&#x4E49;</h1>
<div id="_terms_and_definitions"><h1>1.&#x3000;&#x672F;&#x8BED;&#x548C;&#x5B9A;&#x4E49;</h1>
<p>Prefatory content</p>
<h2 class="TermNum" id="paddy">1.1.</h2><p class="Terms" style="text-align:left;">paddy</p><p class="AltTerms" style="text-align:left;">paddy rice&#x3000;rough rice</p>
Expand Down Expand Up @@ -206,7 +206,7 @@
expect(xmlpp(html.gsub(/"#[a-f0-9-]+"/, "#_"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
<p class="zzSTDTitle1">XXXX</p>
<div id="_terms_and_definitions"><h1 id="toc0">1.&#x3000;&#x672F;&#x8BED;&#x548C;&#x5B9A;&#x4E49;</h1>
<div id="_terms_and_definitions"><h1>1.&#x3000;&#x672F;&#x8BED;&#x548C;&#x5B9A;&#x4E49;</h1>
<h2 class="TermNum" id="paddy">1.1.</h2><p class="Terms" style="text-align:left;">paddy</p><p class="AltTerms" style="text-align:left;">paddy rice&#x3000;rough rice</p>
<p class="DeprecatedTerms">&#x88AB;&#x53D6;&#x4EE3;&#xFF1A;cargo rice</p>
Expand Down Expand Up @@ -246,7 +246,7 @@
expect(xmlpp(htmlencode(html.gsub(/"#[a-f0-9-]+"/, "#_")))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
<p class="zzSTDTitle1">XXXX</p>
<div id="_terms_and_definitions"><h1 id="toc0">1.&#x3000;&#x672F;&#x8BED;&#x548C;&#x5B9A;&#x4E49;</h1>
<div id="_terms_and_definitions"><h1>1.&#x3000;&#x672F;&#x8BED;&#x548C;&#x5B9A;&#x4E49;</h1>
<h2 class="TermNum" id="paddy">1.1.</h2><p class="Terms" style="text-align:left;">paddy</p><p class="AltTerms" style="text-align:left;">paddy rice&#x3000;rough rice</p>
<p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p>
Expand Down Expand Up @@ -286,7 +286,7 @@
expect(xmlpp(htmlencode(html.gsub(/"#[a-f0-9-]+"/, "#_")))).to be_equivalent_to xmlpp(<<~"OUTPUT")
<main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
<p class="zzSTDTitle1">XXXX</p>
<div id="_terms_and_definitions"><h1 id="toc0">1.&#x3000;&#x672F;&#x8BED;&#x548C;&#x5B9A;&#x4E49;</h1>
<div id="_terms_and_definitions"><h1>1.&#x3000;&#x672F;&#x8BED;&#x548C;&#x5B9A;&#x4E49;</h1>
<h2 class="TermNum" id="paddy">1.1.</h2><p class="Terms" style="text-align:left;">paddy</p><p class="AltTerms" style="text-align:left;">paddy rice&#x3000;rough rice</p>
<p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p>
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">XXXX</p>
<div id="H"><h1 id="toc0">1.&#x3000;Terms and definitions</h1>
<div id="H"><h1>1.&#x3000;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 308b34e

Please sign in to comment.