@@ -24,33 +24,63 @@ def listlabel(_list, depth)
24
24
class Xref < IsoDoc ::Iso ::Xref
25
25
attr_accessor :autonumbering_style
26
26
27
- def clause_sep
27
+ def clausesep
28
28
@autonumbering_style == :japanese ? "\u30fb " : "."
29
29
end
30
30
31
- def clause_counter ( num , opts )
31
+ def clause_counter ( num , opts = { } )
32
32
opts [ :numerals ] ||= @autonumbering_style
33
- opts [ :separator ] ||= clause_sep
33
+ opts [ :separator ] ||= clausesep
34
34
super
35
35
end
36
36
37
- def list_counter ( num , opts )
37
+ def list_counter ( num , opts = { } )
38
38
opts [ :numerals ] ||= @autonumbering_style
39
- opts [ :separator ] ||= clause_sep
39
+ opts [ :separator ] ||= clausesep
40
40
IsoDoc ::Jis ::Counter . new ( num , opts )
41
41
end
42
42
43
43
def hierfigsep
44
44
@lang == "ja" ? "の" : super
45
45
end
46
46
47
- def subfigure_label ( subfignum )
47
+ def hierreqtsep
48
+ @lang == "ja" ? "の" : super
49
+ end
50
+
51
+ # KILL
52
+ def subfigure_labelx ( subfignum )
48
53
subfignum . zero? and return ""
49
54
sep = @lang == "ja" ? "の" : " "
50
55
"#{ sep } #{ ( subfignum + 96 ) . chr } )"
51
56
end
52
57
53
- def annex_name_lbl ( clause , num )
58
+ def subfigure_label ( subfignum )
59
+ subfignum . zero? and return
60
+ ( subfignum + 96 ) . chr
61
+ end
62
+
63
+ def subfigure_delim
64
+ ")"
65
+ end
66
+
67
+ # taken from isodoc to override ISO
68
+ def subfigure_anchor ( elem , sublabel , label , klass , container : false )
69
+ figlabel = fig_subfig_label ( label , sublabel )
70
+ @anchors [ elem [ "id" ] ] = anchor_struct (
71
+ figlabel , elem , @labels [ klass ] || klass . capitalize , klass ,
72
+ { unnumb : elem [ "unnumbered" ] , container : }
73
+ )
74
+ if elem [ "unnumbered" ] != "true"
75
+ x = semx ( elem , sublabel )
76
+ @anchors [ elem [ "id" ] ] [ :label ] = x
77
+ @anchors [ elem [ "id" ] ] [ :xref ] = @anchors [ elem . parent [ "id" ] ] [ :xref ] +
78
+ subfigure_separator ( markup : true ) + x + delim_wrap ( subfigure_delim )
79
+ end
80
+ end
81
+
82
+ # KILL
83
+ def annex_name_lblx ( clause , num )
54
84
obl = "(#{ @labels [ 'inform_annex' ] } )"
55
85
clause [ "obligation" ] == "normative" and
56
86
obl = "(#{ @labels [ 'norm_annex' ] } )"
@@ -59,19 +89,16 @@ def annex_name_lbl(clause, num)
59
89
"#{ title } #{ num } <br/>#{ obl } "
60
90
end
61
91
62
- def annex_name_anchors1 ( clause , num , level )
63
- @anchors [ clause [ "id" ] ] =
64
- { xref : num , label : num , level : level ,
65
- subtype : "annex" }
92
+ def annex_name_lbl ( clause , num )
93
+ super . gsub ( %r{</?strong>} , "" )
66
94
end
67
95
68
- def annex_names1 ( clause , num , level )
69
- annex_name_anchors1 ( clause , num , level )
70
- i = clause_counter ( 0 , prefix : num )
71
- clause . xpath ( ns ( SUBCLAUSES ) ) . each do |c |
72
- annex_names1 ( c , i . increment ( c ) . print , level + 1 )
73
- end
74
- end
96
+ def annex_name_anchors1 ( clause , num , level )
97
+ super
98
+ # undo ISO "Clause A.2" in favour of "A.2"
99
+ level == 2 and
100
+ @anchors [ clause [ "id" ] ] [ :xref ] = semx ( clause , num )
101
+ end
75
102
76
103
def clause_order_main ( docxml )
77
104
[
@@ -128,31 +155,34 @@ def back_clauses_anchor_names(xml)
128
155
end
129
156
130
157
def commentary_names ( clause )
158
+ #require "debug" ; binding.b
131
159
preface_name_anchors ( clause , 1 , clause_title ( clause ) )
132
160
clause . xpath ( ns ( SUBCLAUSES ) )
133
161
. each_with_object ( clause_counter ( 0 , { } ) ) do |c , i |
134
- commentary_names1 ( c , clause [ "id" ] , i . increment ( c ) . print , 2 )
162
+ commentary_names1 ( c , clause [ "id" ] , nil , i . increment ( c ) . print , 2 )
135
163
end
136
164
end
137
165
138
- def commentary_names1 ( clause , root , num , level )
139
- commentary_name_anchors ( clause , num , root , level )
166
+ def commentary_names1 ( clause , root , parentnum , num , level )
167
+ lbl = clause_number_semx ( parentnum , clause , num )
168
+ commentary_name_anchors ( clause , lbl , root , level )
140
169
clause . xpath ( ns ( SUBCLAUSES ) )
141
- . each_with_object ( clause_counter ( 0 , prefix : num ) ) do |c , i |
142
- commentary_names1 ( c , root , i . increment ( c ) . print ,
170
+ . each_with_object ( clause_counter ( 0 ) ) do |c , i |
171
+ commentary_names1 ( c , root , lbl , i . increment ( c ) . print ,
143
172
level + 1 )
144
173
end
145
174
end
146
175
147
176
def commentary_name_anchors ( clause , num , root , level )
148
177
@anchors [ clause [ "id" ] ] =
149
- { label : num , xref : l10n ( " #{ @labels [ ' clause' ] } #{ num } " ) ,
178
+ { label : num , xref : labelled_autonum ( @labels [ " clause" ] , num ) ,
150
179
container : root ,
151
180
title : clause_title ( clause ) , level : level , type : "clause" ,
152
181
elem : @labels [ "clause" ] }
153
182
end
154
183
155
- def list_item_anchor_names ( list , list_anchor , depth , prev_label ,
184
+ # KILL ?
185
+ def list_item_anchor_namesx ( list , list_anchor , depth , prev_label ,
156
186
refer_list )
157
187
c = list_counter ( list [ "start" ] ? list [ "start" ] . to_i - 1 : 0 , { } )
158
188
list . xpath ( ns ( "./li" ) ) . each do |li |
@@ -161,10 +191,11 @@ def list_item_anchor_names(list, list_anchor, depth, prev_label,
161
191
{ list_anchor : list_anchor ,
162
192
prev_label : prev_label ,
163
193
refer_list : depth == 1 ? refer_list : nil } )
164
- li [ "id" ] and @anchors [ li [ "id" ] ] =
194
+ li [ "id" ] ||= "_#{ UUIDTools ::UUID . random_create } "
195
+ @anchors [ li [ "id" ] ] =
165
196
{ label : bare_label ,
166
197
bare_xref : "#{ bare_label } )" ,
167
- xref : "#{ label } ) " , type : "listitem" ,
198
+ xref : "#{ label } #{ list_item_delim } " , type : "listitem" ,
168
199
refer_list : refer_list ,
169
200
container : list_anchor [ :container ] }
170
201
( li . xpath ( ns ( ".//ol" ) ) - li . xpath ( ns ( ".//ol//ol" ) ) ) . each do |ol |
@@ -174,16 +205,23 @@ def list_item_anchor_names(list, list_anchor, depth, prev_label,
174
205
end
175
206
end
176
207
208
+ # KILL
209
+ def list_anchor_names ( s )
210
+ super
211
+ #require "debug"; binding.b
212
+ end
213
+
177
214
def list_item_value ( entry , counter , depth , opts )
178
- label1 = counter . increment ( entry ) . listlabel ( entry . parent , depth )
179
215
if depth > 2
180
- base = @c . decode ( opts [ :prev_label ] ) . split ( /\) \s */ ) # List a) 1.1.1
181
- label1 = "#{ base [ -1 ] . sub ( /^の/ , '' ) } #{ clause_sep } #{ label1 } "
182
- [ label1 , list_item_anchor_label ( label1 , opts [ :list_anchor ] ,
183
- base [ 0 ] . sub ( /[\p {Zs})]+$/ , "" ) , opts [ :refer_list ] ) ]
216
+ # require 'debug'; binding.b
217
+ label = counter . increment ( entry ) . listlabel ( entry . parent , depth )
218
+ s = semx ( entry , label )
219
+ base = @c . decode ( opts [ :prev_label ] . gsub ( %r{<[^>]+>} , "" ) ) . split ( /\) \s */ ) # List a) 1.1.1
220
+ label = "#{ base [ -1 ] . sub ( /^の/ , '' ) } #{ clausesep } #{ label } "
221
+ #[label, J=list_item_anchor_label(opts[:prev_label] + delim_wrap(clause_sep) + s, opts[:list_anchor], base[0].sub(/[\p{Zs})]+$/, ""), opts[:refer_list])]
222
+ [ label , opts [ :prev_label ] + delim_wrap ( clausesep ) + s ]
184
223
else
185
- [ label1 , list_item_anchor_label ( label1 , opts [ :list_anchor ] , opts [ :prev_label ] ,
186
- opts [ :refer_list ] ) ]
224
+ super
187
225
end
188
226
end
189
227
end
0 commit comments