Class: IsoDoc::Jis::Xref
- Inherits:
-
Iso::Xref
- Object
- Iso::Xref
- IsoDoc::Jis::Xref
- Defined in:
- lib/isodoc/jis/xref.rb
Instance Attribute Summary collapse
-
#autonumbering_style ⇒ Object
Returns the value of attribute autonumbering_style.
Instance Method Summary collapse
- #annex_name_anchors1(clause, num, level) ⇒ Object
- #annex_name_lbl(clause, num) ⇒ Object
-
#annex_name_lblx(clause, num) ⇒ Object
KILL.
- #back_clauses_anchor_names(xml) ⇒ Object
- #clause_counter(num, opts = { }) ⇒ Object
- #clause_order_annex(_docxml) ⇒ Object
- #clause_order_back(_docxml) ⇒ Object
- #clause_order_main(docxml) ⇒ Object
- #clausesep ⇒ Object
- #commentary_name_anchors(clause, num, root, level) ⇒ Object
- #commentary_names(clause) ⇒ Object
- #commentary_names1(clause, root, parentnum, num, level) ⇒ Object
- #hierfigsep ⇒ Object
- #hierreqtsep ⇒ Object
-
#list_anchor_names(s) ⇒ Object
KILL.
- #list_counter(num, opts = { }) ⇒ Object
-
#list_item_anchor_namesx(list, list_anchor, depth, prev_label, refer_list) ⇒ Object
KILL ?.
- #list_item_value(entry, counter, depth, opts) ⇒ Object
- #main_anchor_names(xml) ⇒ Object
- #section_names(clause, num, lvl) ⇒ Object
-
#subfigure_anchor(elem, sublabel, label, klass, container: false) ⇒ Object
taken from isodoc to override ISO.
- #subfigure_delim ⇒ Object
- #subfigure_label(subfignum) ⇒ Object
-
#subfigure_labelx(subfignum) ⇒ Object
KILL.
Instance Attribute Details
#autonumbering_style ⇒ Object
Returns the value of attribute autonumbering_style.
25 26 27 |
# File 'lib/isodoc/jis/xref.rb', line 25 def autonumbering_style @autonumbering_style end |
Instance Method Details
#annex_name_anchors1(clause, num, level) ⇒ Object
96 97 98 99 100 101 |
# File 'lib/isodoc/jis/xref.rb', line 96 def annex_name_anchors1(clause, num, level) super # undo ISO "Clause A.2" in favour of "A.2" level == 2 and @anchors[clause["id"]][:xref] = semx(clause, num) end |
#annex_name_lbl(clause, num) ⇒ Object
92 93 94 |
# File 'lib/isodoc/jis/xref.rb', line 92 def annex_name_lbl(clause, num) super.gsub(%r{</?strong>}, "") end |
#annex_name_lblx(clause, num) ⇒ Object
KILL
83 84 85 86 87 88 89 90 |
# File 'lib/isodoc/jis/xref.rb', line 83 def annex_name_lblx(clause, num) obl = "(#{@labels['inform_annex']})" clause["obligation"] == "normative" and obl = "(#{@labels['norm_annex']})" title = Common::case_with_markup(@labels["annex"], "capital", @script) "#{title} #{num}<br/>#{obl}" end |
#back_clauses_anchor_names(xml) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/isodoc/jis/xref.rb', line 144 def back_clauses_anchor_names(xml) clause_order_back(xml).each do |a| xml.xpath(ns(a[:path])).each do |c| if c["commentary"] == "true" then commentary_names(c) else preface_names(c) end x = Nokogiri::XML::NodeSet.new(c.document, [c]) sequential_asset_names(x, container: true) a[:multi] or break end end end |
#clause_counter(num, opts = { }) ⇒ Object
31 32 33 34 35 |
# File 'lib/isodoc/jis/xref.rb', line 31 def clause_counter(num, opts = { }) opts[:numerals] ||= @autonumbering_style opts[:separator] ||= clausesep super end |
#clause_order_annex(_docxml) ⇒ Object
116 117 118 |
# File 'lib/isodoc/jis/xref.rb', line 116 def clause_order_annex(_docxml) [{ path: "//annex[not(@commentary = 'true')]", multi: true }] end |
#clause_order_back(_docxml) ⇒ Object
120 121 122 123 124 125 126 127 |
# File 'lib/isodoc/jis/xref.rb', line 120 def clause_order_back(_docxml) [ { path: @klass.bibliography_xpath }, { path: "//annex[@commentary = 'true']", multi: true }, { path: "//indexsect", multi: true }, { path: "//colophon/*", multi: true }, ] end |
#clause_order_main(docxml) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/isodoc/jis/xref.rb', line 103 def clause_order_main(docxml) [ { path: "//sections/introduction" }, { path: "//clause[@type = 'scope']" }, { path: @klass.norm_ref_xpath }, { path: "//sections/terms | " \ "//sections/clause[descendant::terms]" }, { path: "//sections/definitions | " \ "//sections/clause[descendant::definitions][not(descendant::terms)]" }, { path: @klass.middle_clause(docxml), multi: true }, ] end |
#clausesep ⇒ Object
27 28 29 |
# File 'lib/isodoc/jis/xref.rb', line 27 def clausesep @autonumbering_style == :japanese ? "\u30fb" : "." end |
#commentary_name_anchors(clause, num, root, level) ⇒ Object
176 177 178 179 180 181 182 |
# File 'lib/isodoc/jis/xref.rb', line 176 def commentary_name_anchors(clause, num, root, level) @anchors[clause["id"]] = { label: num, xref: labelled_autonum(@labels["clause"], num), container: root, title: clause_title(clause), level: level, type: "clause", elem: @labels["clause"] } end |
#commentary_names(clause) ⇒ Object
157 158 159 160 161 162 163 164 |
# File 'lib/isodoc/jis/xref.rb', line 157 def commentary_names(clause) #require "debug" ; binding.b preface_name_anchors(clause, 1, clause_title(clause)) clause.xpath(ns(SUBCLAUSES)) .each_with_object(clause_counter(0, {})) do |c, i| commentary_names1(c, clause["id"], nil, i.increment(c).print, 2) end end |
#commentary_names1(clause, root, parentnum, num, level) ⇒ Object
166 167 168 169 170 171 172 173 174 |
# File 'lib/isodoc/jis/xref.rb', line 166 def commentary_names1(clause, root, parentnum, num, level) lbl = clause_number_semx(parentnum, clause, num) commentary_name_anchors(clause, lbl, root, level) clause.xpath(ns(SUBCLAUSES)) .each_with_object(clause_counter(0)) do |c, i| commentary_names1(c, root, lbl, i.increment(c).print, level + 1) end end |
#hierfigsep ⇒ Object
43 44 45 |
# File 'lib/isodoc/jis/xref.rb', line 43 def hierfigsep @lang == "ja" ? "の" : super end |
#hierreqtsep ⇒ Object
47 48 49 |
# File 'lib/isodoc/jis/xref.rb', line 47 def hierreqtsep @lang == "ja" ? "の" : super end |
#list_anchor_names(s) ⇒ Object
KILL
209 210 211 212 |
# File 'lib/isodoc/jis/xref.rb', line 209 def list_anchor_names(s) super #require "debug"; binding.b end |
#list_counter(num, opts = { }) ⇒ Object
37 38 39 40 41 |
# File 'lib/isodoc/jis/xref.rb', line 37 def list_counter(num, opts = { }) opts[:numerals] ||= @autonumbering_style opts[:separator] ||= clausesep IsoDoc::Jis::Counter.new(num, opts) end |
#list_item_anchor_namesx(list, list_anchor, depth, prev_label, refer_list) ⇒ Object
KILL ?
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/isodoc/jis/xref.rb', line 185 def list_item_anchor_namesx(list, list_anchor, depth, prev_label, refer_list) c = list_counter(list["start"] ? list["start"].to_i - 1 : 0, {}) list.xpath(ns("./li")).each do |li| , label = list_item_value(li, c, depth, { list_anchor: list_anchor, prev_label: prev_label, refer_list: depth == 1 ? refer_list : nil }) li["id"] ||= "_#{UUIDTools::UUID.random_create}" @anchors[li["id"]] = { label: , bare_xref: "#{})", xref: "#{label}#{list_item_delim}", type: "listitem", refer_list: refer_list, container: list_anchor[:container] } (li.xpath(ns(".//ol")) - li.xpath(ns(".//ol//ol"))).each do |ol| list_item_anchor_names(ol, list_anchor, depth + 1, label, refer_list) end end end |
#list_item_value(entry, counter, depth, opts) ⇒ Object
214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/isodoc/jis/xref.rb', line 214 def list_item_value(entry, counter, depth, opts) if depth > 2 # require 'debug'; binding.b label = counter.increment(entry).listlabel(entry.parent, depth) s = semx(entry, label) base = @c.decode(opts[:prev_label].gsub(%r{<[^>]+>}, "")).split(/\)\s*/) # List a) 1.1.1 label = "#{base[-1].sub(/^の/,'')}#{clausesep}#{label}" #[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])] [label, opts[:prev_label] + delim_wrap(clausesep) + s] else super end end |
#main_anchor_names(xml) ⇒ Object
134 135 136 137 138 139 140 141 142 |
# File 'lib/isodoc/jis/xref.rb', line 134 def main_anchor_names(xml) n = Counter.new(0, { numerals: @autonumbering_style }) clause_order_main(xml).each do |a| xml.xpath(ns(a[:path])).each do |c| section_names(c, n, 1) a[:multi] or break end end end |
#section_names(clause, num, lvl) ⇒ Object
129 130 131 132 |
# File 'lib/isodoc/jis/xref.rb', line 129 def section_names(clause, num, lvl) clause&.name == "introduction" and clause["unnumbered"] = "true" super end |
#subfigure_anchor(elem, sublabel, label, klass, container: false) ⇒ Object
taken from isodoc to override ISO
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/isodoc/jis/xref.rb', line 68 def subfigure_anchor(elem, sublabel, label, klass, container: false) figlabel = fig_subfig_label(label, sublabel) @anchors[elem["id"]] = anchor_struct( figlabel, elem, @labels[klass] || klass.capitalize, klass, { unnumb: elem["unnumbered"], container: } ) if elem["unnumbered"] != "true" x = semx(elem, sublabel) @anchors[elem["id"]][:label] = x @anchors[elem["id"]][:xref] = @anchors[elem.parent["id"]][:xref] + subfigure_separator(markup: true) + x + delim_wrap(subfigure_delim) end end |
#subfigure_delim ⇒ Object
63 64 65 |
# File 'lib/isodoc/jis/xref.rb', line 63 def subfigure_delim ")" end |
#subfigure_label(subfignum) ⇒ Object
58 59 60 61 |
# File 'lib/isodoc/jis/xref.rb', line 58 def subfigure_label(subfignum) subfignum.zero? and return (subfignum + 96).chr end |
#subfigure_labelx(subfignum) ⇒ Object
KILL
52 53 54 55 56 |
# File 'lib/isodoc/jis/xref.rb', line 52 def subfigure_labelx(subfignum) subfignum.zero? and return "" sep = @lang == "ja" ? "の" : " " "#{sep}#{(subfignum + 96).chr})" end |