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 14a98f6 commit e2e4fc6
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 29 deletions.
60 changes: 54 additions & 6 deletions lib/asciidoctor/generic/biblio.rng
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,17 @@
</define>
<define name="stage">
<element name="stage">
<optional>
<attribute name="abbreviation"/>
</optional>
<text/>
</element>
</define>
<define name="substage">
<element name="substage">
<optional>
<attribute name="abbreviation"/>
</optional>
<text/>
</element>
</define>
Expand Down Expand Up @@ -452,9 +458,14 @@
<attribute name="bibitemid">
<data type="IDREF"/>
</attribute>
<zeroOrMore>
<ref name="locality"/>
</zeroOrMore>
<choice>
<zeroOrMore>
<ref name="locality"/>
</zeroOrMore>
<zeroOrMore>
<ref name="localityStack"/>
</zeroOrMore>
</choice>
<optional>
<ref name="date"/>
</optional>
Expand All @@ -469,6 +480,25 @@
<ref name="BibItemLocality"/>
</element>
</define>
<define name="localityStack">
<element name="localityStack">
<zeroOrMore>
<ref name="locality"/>
</zeroOrMore>
</element>
</define>
<define name="sourceLocality">
<element name="sourceLocality">
<ref name="BibItemLocality"/>
</element>
</define>
<define name="sourceLocalityStack">
<element name="sourceLocalityStack">
<zeroOrMore>
<ref name="sourceLocality"/>
</zeroOrMore>
</element>
</define>
<define name="BibItemLocality">
<attribute name="type">
<ref name="LocalityType"/>
Expand Down Expand Up @@ -1028,12 +1058,30 @@
<attribute name="type">
<ref name="DocRelationType"/>
</attribute>
<optional>
<element name="description">
<ref name="FormattedString"/>
</element>
</optional>
<element name="bibitem">
<ref name="BibliographicItem"/>
</element>
<zeroOrMore>
<ref name="locality"/>
</zeroOrMore>
<choice>
<zeroOrMore>
<ref name="locality"/>
</zeroOrMore>
<zeroOrMore>
<ref name="localityStack"/>
</zeroOrMore>
</choice>
<choice>
<zeroOrMore>
<ref name="sourceLocality"/>
</zeroOrMore>
<zeroOrMore>
<ref name="sourceLocalityStack"/>
</zeroOrMore>
</choice>
</element>
</define>
<define name="version">
Expand Down
29 changes: 28 additions & 1 deletion lib/asciidoctor/generic/isodoc.rng
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,23 @@
<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 @@ -911,14 +926,26 @@
</define>
<define name="origin">
<element name="origin">
<ref name="erefType"/>
<choice>
<ref name="erefType"/>
<ref name="termref"/>
</choice>
</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
25 changes: 4 additions & 21 deletions lib/isodoc/generic/html/scripts.html
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
<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>
//TOC toggle animation
$('#toggle').on('click', function(){
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 @@ -59,7 +59,7 @@
<button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
<p class="zzSTDTitle1"></p>
<div id="H">
<h1>1.&#xA0; Terms and definitions</h1>
<h1 id='toc0'>1.&#xA0; Terms and definitions</h1>
<h2 class="TermNum" id="J">1.1.&#xA0;<p class="Terms" style="text-align:left;">Term2</p></h2>
</div>
</main>
Expand Down

0 comments on commit e2e4fc6

Please sign in to comment.