isodoc 2.4.0 → 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/isodoc.gemspec +1 -0
- data/lib/isodoc/base_style/all.css +29 -0
- data/lib/isodoc/base_style/metanorma_word.css +9 -0
- data/lib/isodoc/base_style/metanorma_word.scss +11 -0
- data/lib/isodoc/base_style/reset.css +29 -0
- data/lib/isodoc/base_style/reset.scss +34 -0
- data/lib/isodoc/base_style/rouge.css +39 -0
- data/lib/isodoc/base_style/typography.scss +6 -3
- data/lib/isodoc/convert.rb +7 -4
- data/lib/isodoc/function/blocks.rb +26 -16
- data/lib/isodoc/function/inline.rb +17 -17
- data/lib/isodoc/function/references.rb +38 -52
- data/lib/isodoc/function/table.rb +22 -13
- data/lib/isodoc/function/to_word_html.rb +1 -4
- data/lib/isodoc/function/utils.rb +5 -1
- data/lib/isodoc/html_function/html.rb +13 -34
- data/lib/isodoc/html_function/postprocess.rb +14 -1
- data/lib/isodoc/html_function/postprocess_cover.rb +6 -9
- data/lib/isodoc/metadata.rb +5 -0
- data/lib/isodoc/presentation_function/block.rb +15 -46
- data/lib/isodoc/presentation_function/refs.rb +75 -3
- data/lib/isodoc/presentation_function/sourcecode.rb +114 -0
- data/lib/isodoc/presentation_function/terms.rb +29 -37
- data/lib/isodoc/presentation_function/xrefs.rb +9 -6
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +16 -16
- data/lib/isodoc/word_function/postprocess.rb +47 -43
- data/lib/isodoc/word_function/postprocess_cover.rb +29 -157
- data/lib/isodoc/word_function/postprocess_toc.rb +165 -0
- data/lib/isodoc/word_function/table.rb +25 -13
- data/lib/isodoc/xref/xref_gen.rb +2 -4
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f122ad0105340afb41607b8639eb00b7205328f9bddad0a5a3726e9644c912e
|
4
|
+
data.tar.gz: 04b386a592680a3315ed3d55e7c6716bc177fd628a8d67f520e224b1a4d4de5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fef982e2095471e35cc7235a3bc5712066845fd4302131e9760e8d10da548ec73b40f344816077b915b63d93d32cb5b459507ad2133ac52da257a6230e99353
|
7
|
+
data.tar.gz: cbbaa050b52517cf272d7d0da4d875075e094b3dcda074a89c55945ceedb6c357914f9e9be0cd09e45ac9d6ace9f61f71b8f9d2ccb5c8d3ebb5ba4fd9251e632
|
data/isodoc.gemspec
CHANGED
@@ -43,6 +43,7 @@ Gem::Specification.new do |spec|
|
|
43
43
|
spec.add_dependency "relaton-cli"
|
44
44
|
spec.add_dependency "relaton-render", "~> 0.5.2"
|
45
45
|
spec.add_dependency "roman-numerals"
|
46
|
+
spec.add_dependency "rouge", "~> 4.0"
|
46
47
|
spec.add_dependency "thread_safe"
|
47
48
|
spec.add_dependency "twitter_cldr", ">= 6.6.0"
|
48
49
|
spec.add_dependency "uuidtools"
|
@@ -124,6 +124,35 @@ a.FootnoteRef + a.FootnoteRef:before {
|
|
124
124
|
color: red;
|
125
125
|
text-decoration: line-through; }
|
126
126
|
|
127
|
+
/* code highlighting with line numbers */
|
128
|
+
table.rouge-line-table td.rouge-gutter {
|
129
|
+
-moz-user-select: none;
|
130
|
+
-ms-user-select: none;
|
131
|
+
-webkit-user-select: none;
|
132
|
+
user-select: none;
|
133
|
+
padding-right: 1em; }
|
134
|
+
|
135
|
+
table.rouge-line-table td.rouge-code {
|
136
|
+
-moz-user-select: all;
|
137
|
+
-ms-user-select: all;
|
138
|
+
-webkit-user-select: all;
|
139
|
+
user-select: all; }
|
140
|
+
|
141
|
+
table.rouge-line-table,
|
142
|
+
table.rouge-line-table th,
|
143
|
+
table.rouge-line-table td {
|
144
|
+
width: auto;
|
145
|
+
border: none;
|
146
|
+
margin: 0;
|
147
|
+
padding: 0;
|
148
|
+
font-size: 100%; }
|
149
|
+
|
150
|
+
table.rouge-line-table pre {
|
151
|
+
margin: 0;
|
152
|
+
padding: 0;
|
153
|
+
overflow-x: visible;
|
154
|
+
font-size: 100%; }
|
155
|
+
|
127
156
|
#standard-band {
|
128
157
|
background-color: #0AC442; }
|
129
158
|
|
@@ -45,3 +45,12 @@ span.addition {
|
|
45
45
|
span.deletion {
|
46
46
|
color: red;
|
47
47
|
text-decoration: line-through; }
|
48
|
+
|
49
|
+
table.rouge-line-table {
|
50
|
+
border: none;
|
51
|
+
mso-border-alt: none;
|
52
|
+
mso-border-insideh: none;
|
53
|
+
mso-border-insidev: none; }
|
54
|
+
|
55
|
+
td.rouge-code p.Sourcecode {
|
56
|
+
margin: 0px; }
|
@@ -42,3 +42,14 @@ span.deletion {
|
|
42
42
|
color: red;
|
43
43
|
text-decoration: line-through;
|
44
44
|
}
|
45
|
+
|
46
|
+
table.rouge-line-table {
|
47
|
+
border:none;
|
48
|
+
mso-border-alt:none;
|
49
|
+
mso-border-insideh:none;
|
50
|
+
mso-border-insidev:none;
|
51
|
+
}
|
52
|
+
|
53
|
+
td.rouge-code p.Sourcecode {
|
54
|
+
margin: 0px;
|
55
|
+
}
|
@@ -123,3 +123,32 @@ a.FootnoteRef + a.FootnoteRef:before {
|
|
123
123
|
.deletion {
|
124
124
|
color: red;
|
125
125
|
text-decoration: line-through; }
|
126
|
+
|
127
|
+
/* code highlighting with line numbers */
|
128
|
+
table.rouge-line-table td.rouge-gutter {
|
129
|
+
-moz-user-select: none;
|
130
|
+
-ms-user-select: none;
|
131
|
+
-webkit-user-select: none;
|
132
|
+
user-select: none;
|
133
|
+
padding-right: 1em; }
|
134
|
+
|
135
|
+
table.rouge-line-table td.rouge-code {
|
136
|
+
-moz-user-select: all;
|
137
|
+
-ms-user-select: all;
|
138
|
+
-webkit-user-select: all;
|
139
|
+
user-select: all; }
|
140
|
+
|
141
|
+
table.rouge-line-table,
|
142
|
+
table.rouge-line-table th,
|
143
|
+
table.rouge-line-table td {
|
144
|
+
width: auto;
|
145
|
+
border: none;
|
146
|
+
margin: 0;
|
147
|
+
padding: 0;
|
148
|
+
font-size: 100%; }
|
149
|
+
|
150
|
+
table.rouge-line-table pre {
|
151
|
+
margin: 0;
|
152
|
+
padding: 0;
|
153
|
+
overflow-x: visible;
|
154
|
+
font-size: 100%; }
|
@@ -152,3 +152,37 @@ a.FootnoteRef + a.FootnoteRef:before {
|
|
152
152
|
color: red;
|
153
153
|
text-decoration: line-through;
|
154
154
|
}
|
155
|
+
|
156
|
+
/* code highlighting with line numbers */
|
157
|
+
|
158
|
+
table.rouge-line-table td.rouge-gutter {
|
159
|
+
-moz-user-select: none;
|
160
|
+
-ms-user-select: none;
|
161
|
+
-webkit-user-select: none;
|
162
|
+
user-select: none;
|
163
|
+
padding-right: 1em;
|
164
|
+
}
|
165
|
+
|
166
|
+
table.rouge-line-table td.rouge-code {
|
167
|
+
-moz-user-select: all;
|
168
|
+
-ms-user-select: all;
|
169
|
+
-webkit-user-select: all;
|
170
|
+
user-select: all;
|
171
|
+
}
|
172
|
+
|
173
|
+
table.rouge-line-table,
|
174
|
+
table.rouge-line-table th,
|
175
|
+
table.rouge-line-table td {
|
176
|
+
width: auto;
|
177
|
+
border: none;
|
178
|
+
margin: 0;
|
179
|
+
padding: 0;
|
180
|
+
font-size: 100%;
|
181
|
+
}
|
182
|
+
|
183
|
+
table.rouge-line-table pre {
|
184
|
+
margin: 0;
|
185
|
+
padding: 0;
|
186
|
+
overflow-x: visible;
|
187
|
+
font-size: 100%;
|
188
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
sourcecode table td { padding: 5px; }
|
2
|
+
sourcecode table pre { margin: 0; }
|
3
|
+
sourcecode, sourcecode .w {
|
4
|
+
color: #444444;
|
5
|
+
}
|
6
|
+
sourcecode .cp {
|
7
|
+
color: #CC00A3;
|
8
|
+
}
|
9
|
+
sourcecode .cs {
|
10
|
+
color: #CC00A3;
|
11
|
+
}
|
12
|
+
sourcecode .c, sourcecode .ch, sourcecode .cd, sourcecode .cm, sourcecode .cpf, sourcecode .c1 {
|
13
|
+
color: #FF0000;
|
14
|
+
}
|
15
|
+
sourcecode .kc {
|
16
|
+
color: #C34E00;
|
17
|
+
}
|
18
|
+
sourcecode .kd {
|
19
|
+
color: #0000FF;
|
20
|
+
}
|
21
|
+
sourcecode .kr {
|
22
|
+
color: #007575;
|
23
|
+
}
|
24
|
+
sourcecode .k, sourcecode .kn, sourcecode .kp, sourcecode .kt, sourcecode .kv {
|
25
|
+
color: #0000FF;
|
26
|
+
}
|
27
|
+
sourcecode .s, sourcecode .sb, sourcecode .sc, sourcecode .ld, sourcecode .sd, sourcecode .s2, sourcecode .se, sourcecode .sh, sourcecode .si, sourcecode .sx, sourcecode .sr, sourcecode .s1, sourcecode .ss {
|
28
|
+
color: #009C00;
|
29
|
+
}
|
30
|
+
sourcecode .sa {
|
31
|
+
color: #0000FF;
|
32
|
+
}
|
33
|
+
sourcecode .nb, sourcecode .bp {
|
34
|
+
color: #C34E00;
|
35
|
+
}
|
36
|
+
sourcecode .nt {
|
37
|
+
color: #0000FF;
|
38
|
+
}
|
39
|
+
|
@@ -24,8 +24,11 @@
|
|
24
24
|
background: $colorHighlightBg;
|
25
25
|
box-shadow: 3px 0 0 $colorHighlightBg, -3px 0 0 $colorHighlightBg;
|
26
26
|
}
|
27
|
-
|
28
|
-
|
27
|
+
*::selection {
|
28
|
+
background: $colorHighlightBg;
|
29
|
+
color: $colorHighlightFg;
|
30
|
+
}
|
31
|
+
*::-moz-selection {
|
29
32
|
background: $colorHighlightBg;
|
30
33
|
color: $colorHighlightFg;
|
31
34
|
}
|
@@ -62,6 +65,6 @@
|
|
62
65
|
padding: 1em;
|
63
66
|
}
|
64
67
|
td.header {
|
65
|
-
font-
|
68
|
+
font-weight: 400;
|
66
69
|
}
|
67
70
|
}
|
data/lib/isodoc/convert.rb
CHANGED
@@ -11,7 +11,8 @@ require "mn-requirements"
|
|
11
11
|
|
12
12
|
module IsoDoc
|
13
13
|
class Convert < ::IsoDoc::Common
|
14
|
-
attr_accessor :options, :i18n, :meta, :xrefs, :reqt_models,
|
14
|
+
attr_accessor :options, :i18n, :meta, :xrefs, :reqt_models,
|
15
|
+
:requirements_processor
|
15
16
|
|
16
17
|
# htmlstylesheet: Generic stylesheet for HTML
|
17
18
|
# htmlstylesheet_override: Override stylesheet for HTML
|
@@ -48,6 +49,7 @@ module IsoDoc
|
|
48
49
|
# fonts: fontist fonts to install
|
49
50
|
# fontlicenseagreement: fontist font license agreement
|
50
51
|
# modspecidentifierbase: base prefix for any Modspec identifiers
|
52
|
+
# sourcehighlighter: whether to apply sourcecode highlighting
|
51
53
|
def initialize(options) # rubocop:disable Lint/MissingSuper
|
52
54
|
@options = options_preprocess(options)
|
53
55
|
init_stylesheets(@options)
|
@@ -76,10 +78,11 @@ module IsoDoc
|
|
76
78
|
@suppressheadingnumbers = options[:suppressheadingnumbers]
|
77
79
|
@break_up_urls_in_tables = options[:breakupurlsintables]
|
78
80
|
@sectionsplit = options[:sectionsplit] == "true"
|
79
|
-
@suppressasciimathdup = options[:suppressasciimathdup]
|
81
|
+
@suppressasciimathdup = options[:suppressasciimathdup]
|
80
82
|
@bare = options[:bare]
|
81
83
|
@aligncrosselements = options[:aligncrosselements]
|
82
84
|
@modspecidentifierbase = options[:modspecidentifierbase]
|
85
|
+
@sourcehighlighter = options[:sourcehighlighter]
|
83
86
|
end
|
84
87
|
|
85
88
|
def init_i18n(options)
|
@@ -207,7 +210,7 @@ module IsoDoc
|
|
207
210
|
docxml.root.default_namespace = ""
|
208
211
|
convert_i18n_init(docxml)
|
209
212
|
metadata_init(@lang, @script, @locale, @i18n)
|
210
|
-
xref_init(@lang, @script, self, @i18n, {locale: @locale})
|
213
|
+
xref_init(@lang, @script, self, @i18n, { locale: @locale })
|
211
214
|
[docxml, filename, dir]
|
212
215
|
end
|
213
216
|
|
@@ -235,7 +238,7 @@ module IsoDoc
|
|
235
238
|
end
|
236
239
|
|
237
240
|
def middle_clause(_docxml = nil)
|
238
|
-
"//clause[parent::sections][not(@type = 'scope')]"\
|
241
|
+
"//clause[parent::sections][not(@type = 'scope')]" \
|
239
242
|
"[not(descendant::terms)]"
|
240
243
|
end
|
241
244
|
|
@@ -6,19 +6,19 @@ module IsoDoc
|
|
6
6
|
@annotation = false
|
7
7
|
|
8
8
|
def middle_title(_isoxml, out)
|
9
|
-
out.p(
|
9
|
+
out.p(class: "zzSTDTitle1") { |p| p << @meta.get[:doctitle] }
|
10
10
|
end
|
11
11
|
|
12
12
|
def figure_name_parse(_node, div, name)
|
13
13
|
return if name.nil?
|
14
14
|
|
15
|
-
div.p
|
15
|
+
div.p class: "FigureTitle", style: "text-align:center;" do |p|
|
16
16
|
name.children.each { |n| parse(n, p) }
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
def figure_key(out)
|
21
|
-
out.p
|
21
|
+
out.p style: "page-break-after:avoid;" do |p|
|
22
22
|
p.b { |b| b << @i18n.key }
|
23
23
|
end
|
24
24
|
end
|
@@ -63,7 +63,7 @@ module IsoDoc
|
|
63
63
|
def sourcecode_name_parse(_node, div, name)
|
64
64
|
return if name.nil?
|
65
65
|
|
66
|
-
div.p
|
66
|
+
div.p class: "SourceTitle", style: "text-align:center;" do |p|
|
67
67
|
name.children.each { |n| parse(n, p) }
|
68
68
|
end
|
69
69
|
end
|
@@ -75,13 +75,19 @@ module IsoDoc
|
|
75
75
|
def sourcecode_parse(node, out)
|
76
76
|
name = node.at(ns("./name"))
|
77
77
|
out.p **sourcecode_attrs(node) do |div|
|
78
|
-
|
79
|
-
node.children.each { |n| parse(n, div) unless n.name == "name" }
|
80
|
-
@sourcecode = false
|
78
|
+
sourcecode_parse1(node, div)
|
81
79
|
end
|
82
80
|
sourcecode_name_parse(node, out, name)
|
83
81
|
end
|
84
82
|
|
83
|
+
def sourcecode_parse1(node, div)
|
84
|
+
@sourcecode = "pre"
|
85
|
+
node.at(ns(".//table")) || !node.ancestors("table").empty? and
|
86
|
+
@sourcecode = "table"
|
87
|
+
node.children.each { |n| parse(n, div) unless n.name == "name" }
|
88
|
+
@sourcecode = false
|
89
|
+
end
|
90
|
+
|
85
91
|
def pre_parse(node, out)
|
86
92
|
out.pre node.text, **attr_code(id: node["id"])
|
87
93
|
end
|
@@ -89,18 +95,22 @@ module IsoDoc
|
|
89
95
|
def annotation_parse(node, out)
|
90
96
|
@sourcecode = false
|
91
97
|
@annotation = true
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
+
out.div class: "annotation" do |div|
|
99
|
+
#node.at("./preceding-sibling::*[local-name() = 'annotation']") or
|
100
|
+
# div << "<br/>"
|
101
|
+
callout = node.at(ns("//callout[@target='#{node['id']}']"))
|
102
|
+
div << "<span class='c'><#{callout.text}></span> "
|
103
|
+
div << "<span class='c'>#{node.children&.text&.strip}</span>"
|
104
|
+
node.at("./following-sibling::*[local-name() = 'annotation']") and
|
105
|
+
div << "<br/>"
|
106
|
+
@annotation = false
|
107
|
+
end
|
98
108
|
end
|
99
109
|
|
100
110
|
def formula_where(dlist, out)
|
101
111
|
return unless dlist
|
102
112
|
|
103
|
-
out.p
|
113
|
+
out.p style: "page-break-after:avoid;" do |p|
|
104
114
|
p << @i18n.where
|
105
115
|
end
|
106
116
|
parse(dlist, out)
|
@@ -168,7 +178,7 @@ module IsoDoc
|
|
168
178
|
source = node.at(ns("./source"))
|
169
179
|
return if author.nil? && source.nil?
|
170
180
|
|
171
|
-
out.p
|
181
|
+
out.p class: "QuoteAttribution" do |p|
|
172
182
|
p << "— #{author.text}" if author
|
173
183
|
p << ", " if author && source
|
174
184
|
eref_parse(source, p) if source
|
@@ -198,7 +208,7 @@ module IsoDoc
|
|
198
208
|
end
|
199
209
|
|
200
210
|
def toc_parse(node, out)
|
201
|
-
out.div
|
211
|
+
out.div class: "toc" do |div|
|
202
212
|
node.children.each { |n| parse(n, div) }
|
203
213
|
end
|
204
214
|
end
|
@@ -17,12 +17,12 @@ module IsoDoc
|
|
17
17
|
def location_parse(node, out); end
|
18
18
|
|
19
19
|
def span_parse(node, out)
|
20
|
-
if node["style"]
|
21
|
-
out.span **
|
20
|
+
if node["style"] || node["class"]
|
21
|
+
out.span **attr_code(style: node["style"],
|
22
|
+
class: node["class"]) do |s|
|
22
23
|
node.children.each { |n| parse(n, s) }
|
23
24
|
end
|
24
|
-
else
|
25
|
-
node.children.each { |n| parse(n, out) }
|
25
|
+
else node.children.each { |n| parse(n, out) }
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -42,7 +42,7 @@ module IsoDoc
|
|
42
42
|
else
|
43
43
|
"##{node['target']}"
|
44
44
|
end
|
45
|
-
out.a(
|
45
|
+
out.a(href: target) { |l| no_locality_parse(node, l) }
|
46
46
|
end
|
47
47
|
|
48
48
|
def suffix_url(url)
|
@@ -77,10 +77,10 @@ module IsoDoc
|
|
77
77
|
if href = eref_target(node)
|
78
78
|
if node["type"] == "footnote"
|
79
79
|
out.sup do |s|
|
80
|
-
s.a(
|
80
|
+
s.a(href: href) { |l| no_locality_parse(node, l) }
|
81
81
|
end
|
82
82
|
else
|
83
|
-
out.a(
|
83
|
+
out.a(href: href) { |l| no_locality_parse(node, l) }
|
84
84
|
end
|
85
85
|
else no_locality_parse(node, out)
|
86
86
|
end
|
@@ -109,7 +109,7 @@ module IsoDoc
|
|
109
109
|
when "LaTeX" then latexmath_parse(node)
|
110
110
|
else HTMLEntities.new.encode(node.text)
|
111
111
|
end
|
112
|
-
out.span
|
112
|
+
out.span class: "stem" do |span|
|
113
113
|
span.parent.add_child ooml
|
114
114
|
end
|
115
115
|
end
|
@@ -123,7 +123,7 @@ module IsoDoc
|
|
123
123
|
def asciimath_parse(node)
|
124
124
|
a = node.at(ns("./asciimath"))&.text || node.text
|
125
125
|
|
126
|
-
"#{@openmathdelim}#{HTMLEntities.new.encode(a)}"\
|
126
|
+
"#{@openmathdelim}#{HTMLEntities.new.encode(a)}" \
|
127
127
|
"#{@closemathdelim}"
|
128
128
|
end
|
129
129
|
|
@@ -134,7 +134,7 @@ module IsoDoc
|
|
134
134
|
|
135
135
|
def image_title_parse(out, caption)
|
136
136
|
unless caption.nil?
|
137
|
-
out.p
|
137
|
+
out.p class: "FigureTitle", style: "text-align:center;" do |p|
|
138
138
|
p.b { |b| b << caption.to_s }
|
139
139
|
end
|
140
140
|
end
|
@@ -151,7 +151,7 @@ module IsoDoc
|
|
151
151
|
end
|
152
152
|
|
153
153
|
def smallcap_parse(node, xml)
|
154
|
-
xml.span
|
154
|
+
xml.span style: "font-variant:small-caps;" do |s|
|
155
155
|
node.children.each { |n| parse(n, s) }
|
156
156
|
end
|
157
157
|
end
|
@@ -160,21 +160,21 @@ module IsoDoc
|
|
160
160
|
return if node.nil? || node.text.nil?
|
161
161
|
|
162
162
|
text = node.to_s
|
163
|
-
|
163
|
+
@sourcecode == "pre" and
|
164
164
|
text = text.gsub("\n", "<br/>").gsub("<br/> ", "<br/> ")
|
165
|
-
|
166
|
-
|
165
|
+
@sourcecode and
|
166
|
+
text = text.gsub(/ (?= )/, " ")
|
167
167
|
out << text
|
168
168
|
end
|
169
169
|
|
170
170
|
def add_parse(node, out)
|
171
|
-
out.span
|
171
|
+
out.span class: "addition" do |e|
|
172
172
|
node.children.each { |n| parse(n, e) }
|
173
173
|
end
|
174
174
|
end
|
175
175
|
|
176
176
|
def del_parse(node, out)
|
177
|
-
out.span
|
177
|
+
out.span class: "deletion" do |e|
|
178
178
|
node.children.each { |n| parse(n, e) }
|
179
179
|
end
|
180
180
|
end
|
@@ -182,7 +182,7 @@ module IsoDoc
|
|
182
182
|
def error_parse(node, out)
|
183
183
|
text = node.to_xml.gsub(/</, "<").gsub(/>/, ">")
|
184
184
|
out.para do |p|
|
185
|
-
p.b(
|
185
|
+
p.b(role: "strong") { |e| e << text }
|
186
186
|
end
|
187
187
|
end
|
188
188
|
end
|
@@ -10,60 +10,59 @@ module IsoDoc
|
|
10
10
|
text
|
11
11
|
end
|
12
12
|
|
13
|
-
def nonstd_bibitem(list, bib,
|
13
|
+
def nonstd_bibitem(list, bib, _ordinal, biblio) # %%%
|
14
14
|
list.p **attr_code(iso_bibitem_entry_attrs(bib, biblio)) do |ref|
|
15
|
-
ids = bibitem_ref_code(bib)
|
16
|
-
idents = render_identifier(ids)
|
17
|
-
if biblio then ref_entry_code(ref, ordinal, idents, ids)
|
18
|
-
else
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
ref << "," if idents[:sdo]
|
23
|
-
|
15
|
+
# ids = bibitem_ref_code(bib)
|
16
|
+
# idents = render_identifier(ids)
|
17
|
+
# if biblio then ref_entry_code(ref, ordinal, idents, ids)
|
18
|
+
# else
|
19
|
+
# ref << (idents[:ordinal] || idents[:metanorma] || idents[:sdo]).to_s
|
20
|
+
# ref << ", #{idents[sdo]}" if idents[:ordinal] && idents[:sdo]
|
21
|
+
# end
|
22
|
+
# ref << "," if idents[:sdo]
|
23
|
+
tag = bib.at(ns("./biblio-tag"))
|
24
|
+
tag&.children&.each { |n| parse(n, ref) }
|
24
25
|
reference_format(bib, ref)
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
|
-
def std_bibitem_entry(list, bib,
|
29
|
+
def std_bibitem_entry(list, bib, _ordinal, biblio) # %%%
|
29
30
|
list.p **attr_code(iso_bibitem_entry_attrs(bib, biblio)) do |ref|
|
30
|
-
idents = render_identifier(bibitem_ref_code(bib))
|
31
|
-
if biblio then ref_entry_code(ref, ordinal, idents, nil)
|
32
|
-
else
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
-
date_note_process(bib, ref)
|
38
|
-
ref << "," if idents[:sdo]
|
39
|
-
|
31
|
+
# idents = render_identifier(bibitem_ref_code(bib))
|
32
|
+
# if biblio then ref_entry_code(ref, ordinal, idents, nil)
|
33
|
+
# else
|
34
|
+
# ref << (idents[:ordinal] || idents[:metanorma] || idents[:sdo]).to_s
|
35
|
+
# ref << ", #{idents[:sdo]}" if (idents[:ordinal] ||
|
36
|
+
# idents[:metanorma]) && idents[:sdo]
|
37
|
+
# end
|
38
|
+
# date_note_process(bib, ref)
|
39
|
+
# ref << "," if idents[:sdo]
|
40
|
+
tag = bib.at(ns("./biblio-tag"))
|
41
|
+
tag&.children&.each { |n| parse(n, ref) }
|
40
42
|
reference_format(bib, ref)
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
44
|
-
# if ids is just a number, only use that ([1] Non-Standard)
|
45
|
-
# else, use both ordinal, as prefix, and ids
|
46
|
-
def ref_entry_code(ref, ordinal, ids, _id)
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
46
|
+
# # if ids is just a number, only use that ([1] Non-Standard)
|
47
|
+
# # else, use both ordinal, as prefix, and ids
|
48
|
+
# def ref_entry_code(ref, ordinal, ids, _id) #%%%
|
49
|
+
# prefix_bracketed_ref(ref, ids[:ordinal] || ids[:metanorma] ||
|
50
|
+
# "[#{ordinal}]")
|
51
|
+
# ids[:sdo] and ref << (ids[:sdo]).to_s
|
52
|
+
# end
|
51
53
|
|
52
|
-
|
53
|
-
|
54
|
+
SKIP_DOCID = "@type = 'DOI' or @type = 'metanorma' or @type = 'ISSN' or " \
|
55
|
+
"@type = 'metanorma-ordinal' or @type = 'ISBN'".freeze
|
54
56
|
|
55
|
-
|
57
|
+
def pref_ref_code(bib)
|
58
|
+
bib["suppress_identifier"] == "true" and return nil
|
59
|
+
lang = "[@language = '#{@lang}']"
|
60
|
+
ret = bib.xpath(ns("./docidentifier[@primary = 'true']#{lang}"))
|
56
61
|
ret.empty? and
|
57
62
|
ret = bib.xpath(ns("./docidentifier[@primary = 'true']"))
|
58
63
|
ret.empty? and
|
59
|
-
ret = bib.at(ns(
|
60
|
-
./docidentifier[not(
|
61
|
-
XPATH
|
62
|
-
)) ||
|
63
|
-
bib.at(ns(<<~XPATH,
|
64
|
-
./docidentifier[not(@type = 'DOI' or @type = 'metanorma' or @type = 'metanorma-ordinal' or @type = 'ISSN' or @type = 'ISBN')]
|
65
|
-
XPATH
|
66
|
-
))
|
64
|
+
ret = bib.at(ns("./docidentifier[not(#{SKIP_DOCID})]#{lang}")) ||
|
65
|
+
bib.at(ns("./docidentifier[not(#{SKIP_DOCID})]"))
|
67
66
|
ret
|
68
67
|
end
|
69
68
|
|
@@ -123,14 +122,6 @@ module IsoDoc
|
|
123
122
|
.include? prefix
|
124
123
|
end
|
125
124
|
|
126
|
-
def date_note_process(bib, ref)
|
127
|
-
date_note = bib.at(ns("./note[@type = 'Unpublished-Status']"))
|
128
|
-
return if date_note.nil?
|
129
|
-
|
130
|
-
date_note.children = "<p>#{date_note.content}</p>"
|
131
|
-
footnote_parse(date_note, ref)
|
132
|
-
end
|
133
|
-
|
134
125
|
def iso_bibitem_entry_attrs(bib, biblio)
|
135
126
|
{ id: bib["id"], class: biblio ? "Biblio" : "NormRef" }
|
136
127
|
end
|
@@ -141,11 +132,6 @@ module IsoDoc
|
|
141
132
|
bib["hidden"] == "true"
|
142
133
|
end
|
143
134
|
|
144
|
-
def prefix_bracketed_ref(ref, text)
|
145
|
-
ref << text.to_s
|
146
|
-
insert_tab(ref, 1)
|
147
|
-
end
|
148
|
-
|
149
135
|
def reference_format(bib, out)
|
150
136
|
ftitle = bib.at(ns("./formattedref"))
|
151
137
|
ftitle&.children&.each { |n| parse(n, out) }
|