Skip to content

Commit 213df23

Browse files
committed
bring list and clause numbering in line with ISO: #68
1 parent a932577 commit 213df23

File tree

5 files changed

+170
-184
lines changed

5 files changed

+170
-184
lines changed

lib/isodoc/plateau/presentation_xml_convert.rb

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
module IsoDoc
44
module Plateau
55
class PresentationXMLConvert < IsoDoc::JIS::PresentationXMLConvert
6+
def initialize(options)
7+
@iso = ::IsoDoc::Iso::PresentationXMLConvert.new(options)
8+
super
9+
end
10+
611
def toc_title_insert_pt(docxml)
712
i = preface_init_insert_pt(docxml) or return nil
813
a = i.at(ns("./abstract[last()] | ./clause[@type = 'revhistory']")) and
@@ -70,6 +75,10 @@ def commentary_title_hdr(elem)
7075
elem.previous = ret
7176
end
7277

78+
def ol_depth(node)
79+
@iso.ol_depth(node)
80+
end
81+
7382
include Init
7483
end
7584
end

lib/isodoc/plateau/xref.rb

+13-36
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ class Counter < IsoDoc::XrefGen::Counter
44
end
55

66
class Xref < IsoDoc::JIS::Xref
7+
def initialize(lang, script, klass, i18n, options)
8+
@iso = ::IsoDoc::Iso::Xref.new(lang, script, klass, i18n, options)
9+
super
10+
end
11+
712
def clause_order_main(_docxml)
813
[
914
{
@@ -39,42 +44,6 @@ def middle_asset_names(clause, container: false)
3944
end
4045
end
4146

42-
def section_name_anchors(clause, num, level)
43-
super
44-
if level >= 4 && level <= 6
45-
label, xref = section_name_anchors_deep(num, level)
46-
@anchors[clause["id"]][:label] = label
47-
@anchors[clause["id"]][:xref] = l10n(xref)
48-
end
49-
end
50-
51-
def section_name_anchors_deep(num, level)
52-
numparts = num.split(".")
53-
core = numparts[0..2].join(".")
54-
(4..level).each do |l|
55-
core += " #{section_name_label_deep(numparts[l - 1], l)}"
56-
end
57-
[section_name_label_deep(numparts[-1], level), l10n(core)]
58-
end
59-
60-
def section_name_label_deep(num, level)
61-
case level
62-
when 4 then l10n("(#{num})")
63-
when 5 then l10n("#{num})")
64-
when 6
65-
("" << (num.to_i + 0x245f))
66-
end
67-
end
68-
69-
def annex_name_anchors1(clause, num, level)
70-
super
71-
if level >= 4 && level <= 6
72-
label, xref = section_name_anchors_deep(num, level)
73-
@anchors[clause["id"]][:label] = label
74-
@anchors[clause["id"]][:xref] = l10n(xref)
75-
end
76-
end
77-
7847
def hierarchical_figure_names(clause, num)
7948
c = IsoDoc::XrefGen::Counter.new
8049
j = 0
@@ -102,6 +71,14 @@ def hierarchical_figure_class_names(clause, num)
10271
end
10372
end
10473

74+
def list_item_anchor_names(list, list_anchor, depth, prev_label,
75+
refer_list)
76+
@iso.list_item_anchor_names(list, list_anchor, depth, prev_label, refer_list)
77+
end
78+
79+
def list_item_value(entry, counter, depth, opts)
80+
@iso.list_item_value(entry, counter, depth, opts)
81+
end
10582
end
10683
end
10784
end

spec/isodoc/blocks_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,8 @@
407407
<origin bibitemid="x" type="inline" citeas="Clause 1">4</origin>
408408
]
409409
</p>
410-
<ol id="_" type="alphabetic">
411-
<li id="_" label="a">
410+
<ol id="_" type="alphabet">
411+
<li id="_" label="">
412412
<p id="_">List</p>
413413
</li>
414414
</ol>

spec/isodoc/sections_spec.rb

+102-102
Original file line numberDiff line numberDiff line change
@@ -609,129 +609,129 @@
609609
</iso-standard>
610610
INPUT
611611
presxml = <<~OUTPUT
612-
<iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
613-
<preface>
612+
<iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
613+
<preface>
614614
<clause type="toc" id="_" displayorder="1">
615-
<title depth="1">Contents</title>
615+
<title depth="1">Contents</title>
616616
</clause>
617-
</preface>
618-
<sections>
617+
</preface>
618+
<sections>
619619
<clause id="S1" obligation="normative" displayorder="2">
620-
<title depth="1">
621-
1
622-
<tab/>
623-
Scope
624-
</title>
625-
<clause id="S2" obligation="normative">
626-
<title depth="2">
627-
1.1
620+
<title depth="1">
621+
1
628622
<tab/>
629623
Scope
630-
</title>
631-
<clause id="S3" obligation="normative">
632-
<title depth="3">
633-
1.1.1
634-
<tab/>
635-
Scope
624+
</title>
625+
<clause id="S2" obligation="normative">
626+
<title depth="2">
627+
1.1
628+
<tab/>
629+
Scope
636630
</title>
637-
<clause id="S4" obligation="normative">
638-
<title depth="4">
639-
(1)
640-
<tab/>
641-
Scope
642-
</title>
643-
<clause id="S5" obligation="normative">
644-
<title depth="5">
645-
1)
631+
<clause id="S3" obligation="normative">
632+
<title depth="3">
633+
1.1.1
646634
<tab/>
647635
Scope
648-
</title>
649-
<clause id="S6a" obligation="normative">
650-
<title depth="6">
651-
652-
<tab/>
653-
Scope
654-
</title>
655-
</clause>
656-
<clause id="S6b" obligation="normative">
657-
<title depth="6">
658-
659-
<tab/>
660-
Scope
636+
</title>
637+
<clause id="S4" obligation="normative">
638+
<title depth="4">
639+
1.1.1.1
640+
<tab/>
641+
Scope
661642
</title>
662-
</clause>
663-
<clause id="S6c" obligation="normative">
664-
<title depth="6">
665-
666-
<tab/>
667-
Scope
668-
</title>
669-
</clause>
670-
</clause>
643+
<clause id="S5" obligation="normative">
644+
<title depth="5">
645+
1.1.1.1.1
646+
<tab/>
647+
Scope
648+
</title>
649+
<clause id="S6a" obligation="normative">
650+
<title depth="6">
651+
1.1.1.1.1.1
652+
<tab/>
653+
Scope
654+
</title>
655+
</clause>
656+
<clause id="S6b" obligation="normative">
657+
<title depth="6">
658+
1.1.1.1.1.2
659+
<tab/>
660+
Scope
661+
</title>
662+
</clause>
663+
<clause id="S6c" obligation="normative">
664+
<title depth="6">
665+
1.1.1.1.1.3
666+
<tab/>
667+
Scope
668+
</title>
669+
</clause>
670+
</clause>
671+
</clause>
671672
</clause>
672-
</clause>
673-
</clause>
673+
</clause>
674674
</clause>
675-
</sections>
676-
<annex id="P" inline-header="false" obligation="normative" displayorder="3">
675+
</sections>
676+
<annex id="P" inline-header="false" obligation="normative" displayorder="3">
677677
<title>
678-
Annex A
679-
<br/>
680-
(normative)
681-
<br/>
682-
<strong>Annex</strong>
678+
Annex A
679+
<br/>
680+
(normative)
681+
<br/>
682+
<strong>Annex</strong>
683683
</title>
684684
<clause id="A1" obligation="normative">
685-
<title depth="2">
686-
A.1
687-
<tab/>
688-
Scope
689-
</title>
690-
<clause id="A2" obligation="normative">
691-
<title depth="3">
692-
A.1.1
685+
<title depth="2">
686+
A.1
693687
<tab/>
694688
Scope
695-
</title>
696-
<clause id="A3" obligation="normative">
697-
<title depth="4">
698-
(1)
699-
<tab/>
700-
Scope
689+
</title>
690+
<clause id="A2" obligation="normative">
691+
<title depth="3">
692+
A.1.1
693+
<tab/>
694+
Scope
701695
</title>
702-
<clause id="A4" obligation="normative">
703-
<title depth="5">
704-
1)
705-
<tab/>
706-
Scope
707-
</title>
708-
<clause id="A6a" obligation="normative">
709-
<title depth="6">
710-
696+
<clause id="A3" obligation="normative">
697+
<title depth="4">
698+
A.1.1.1
711699
<tab/>
712700
Scope
713-
</title>
714-
</clause>
715-
<clause id="A6b" obligation="normative">
716-
<title depth="6">
717-
718-
<tab/>
719-
Scope
720-
</title>
721-
</clause>
722-
<clause id="A6c" obligation="normative">
723-
<title depth="6">
724-
725-
<tab/>
726-
Scope
727-
</title>
728-
</clause>
701+
</title>
702+
<clause id="A4" obligation="normative">
703+
<title depth="5">
704+
A.1.1.1.1
705+
<tab/>
706+
Scope
707+
</title>
708+
<clause id="A6a" obligation="normative">
709+
<title depth="6">
710+
A.1.1.1.1.1
711+
<tab/>
712+
Scope
713+
</title>
714+
</clause>
715+
<clause id="A6b" obligation="normative">
716+
<title depth="6">
717+
A.1.1.1.1.2
718+
<tab/>
719+
Scope
720+
</title>
721+
</clause>
722+
<clause id="A6c" obligation="normative">
723+
<title depth="6">
724+
A.1.1.1.1.3
725+
<tab/>
726+
Scope
727+
</title>
728+
</clause>
729+
</clause>
729730
</clause>
730-
</clause>
731-
</clause>
731+
</clause>
732732
</clause>
733-
</annex>
734-
</iso-standard>
733+
</annex>
734+
</iso-standard>
735735
OUTPUT
736736
expect(Xml::C14n.format(strip_guid(IsoDoc::Plateau::PresentationXMLConvert
737737
.new(presxml_options)

0 commit comments

Comments
 (0)