isodoc 1.6.1 → 1.6.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/.rubocop.yml +0 -2
- data/isodoc.gemspec +1 -1
- data/lib/isodoc-yaml/i18n-ar.yaml +152 -0
- data/lib/isodoc-yaml/i18n-de.yaml +149 -0
- data/lib/isodoc-yaml/i18n-es.yaml +151 -0
- data/lib/isodoc-yaml/i18n-ru.yaml +154 -0
- data/lib/isodoc/common.rb +2 -0
- data/lib/isodoc/convert.rb +1 -1
- data/lib/isodoc/function/blocks.rb +10 -0
- data/lib/isodoc/function/form.rb +51 -0
- data/lib/isodoc/function/inline.rb +1 -0
- data/lib/isodoc/function/references.rb +55 -42
- data/lib/isodoc/function/table.rb +1 -0
- data/lib/isodoc/function/to_word_html.rb +15 -24
- data/lib/isodoc/html_convert.rb +2 -0
- data/lib/isodoc/html_function/form.rb +62 -0
- data/lib/isodoc/i18n.rb +13 -11
- data/lib/isodoc/presentation_function/inline.rb +46 -103
- data/lib/isodoc/presentation_function/math.rb +84 -0
- data/lib/isodoc/presentation_xml_convert.rb +1 -0
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +28 -24
- data/spec/isodoc/form_spec.rb +156 -0
- data/spec/isodoc/inline_spec.rb +958 -928
- data/spec/isodoc/postproc_spec.rb +329 -309
- metadata +12 -4
@@ -0,0 +1,154 @@
|
|
1
|
+
term_def_boilerplate:
|
2
|
+
scope: Сфера применения
|
3
|
+
symbolsabbrev: Символы и сокращенные термины
|
4
|
+
abbrev: Сокращенные термины
|
5
|
+
symbols: Символы
|
6
|
+
table_of_contents: Содержание
|
7
|
+
introduction: Введение
|
8
|
+
foreword: Предисловие
|
9
|
+
abstract: Реферат
|
10
|
+
acknowledgements: Подтверждения
|
11
|
+
termsdef: Термины и определения
|
12
|
+
termsdefsymbolsabbrev: Термины, определения, символы и сокращенные термины
|
13
|
+
termsdefsymbols: Термины, определения и символы
|
14
|
+
termsdefabbrev: Термины, определения и сокращенные термины
|
15
|
+
normref: Нормативные ссылки
|
16
|
+
bibliography: Библиография
|
17
|
+
clause: Пункт
|
18
|
+
annex: Дополнение
|
19
|
+
appendix: Приложение
|
20
|
+
no_terms_boilerplate: |
|
21
|
+
<p>Термины и определения не перечислены в этом документе.</p>
|
22
|
+
internal_terms_boilerplate: |
|
23
|
+
<p>Для целей этого документа
|
24
|
+
применяются следующие термины и определения.</p>
|
25
|
+
norm_with_refs_pref:
|
26
|
+
Следующие документы упоминаются в тексте таким образом,
|
27
|
+
что некоторая часть или все их содержание являются требованиями
|
28
|
+
настоящего документа. Для датированных ссылок применяют только указанное издание.
|
29
|
+
Для недатированных ссылок применяют последнее издание
|
30
|
+
указанного документа (включая любые поправки).
|
31
|
+
norm_empty_pref:
|
32
|
+
Нет нормативных ссылок в этом документе.
|
33
|
+
external_terms_boilerplate: |
|
34
|
+
<p>Для целей этого документа применяются
|
35
|
+
термины и определения, данные в %.</p>
|
36
|
+
internal_external_terms_boilerplate: |
|
37
|
+
<p>Для целей этого документа применяются
|
38
|
+
термины и определения, данные в % и следующие.</p>
|
39
|
+
term_defined_in: "[термин, определенный в %]"
|
40
|
+
note: ПРИМЕЧАНИЕ
|
41
|
+
note_xref: Примечание
|
42
|
+
termnote: Примечание % к определению
|
43
|
+
list: Список
|
44
|
+
figure: Рисунок
|
45
|
+
formula: Формула
|
46
|
+
inequality: Формула
|
47
|
+
table: Таблица
|
48
|
+
requirement: Требование
|
49
|
+
recommendation: Рекомендация
|
50
|
+
permission: Разрешение
|
51
|
+
key: Условные обозначения
|
52
|
+
example: ПРИМЕР
|
53
|
+
example_xref: Пример
|
54
|
+
where: где
|
55
|
+
wholeoftext: Текст полностью
|
56
|
+
draft_label: проект
|
57
|
+
inform_annex: информативное
|
58
|
+
norm_annex: нормативное
|
59
|
+
modified: изменен
|
60
|
+
deprecated: НЕ РЕКОМЕНДУЕТСЯ
|
61
|
+
source: ИСТОЧНИК
|
62
|
+
and: и
|
63
|
+
all_parts: Все части
|
64
|
+
month_january: Январь
|
65
|
+
month_february: Февраль
|
66
|
+
month_march: Март
|
67
|
+
month_april: Апрель
|
68
|
+
month_may: Май
|
69
|
+
month_june: Июнь
|
70
|
+
month_july: Июль
|
71
|
+
month_august: Август
|
72
|
+
month_september: Сентябрь
|
73
|
+
month_october: Октябрь
|
74
|
+
month_november: Ноябрь
|
75
|
+
month_december: Декабрь
|
76
|
+
obligation: Обязательство
|
77
|
+
subject: Тема
|
78
|
+
inherits: Наследует
|
79
|
+
admonition: {
|
80
|
+
danger: Опасность,
|
81
|
+
warning: Предупреждение,
|
82
|
+
caution: Предостережение,
|
83
|
+
important: Важно,
|
84
|
+
safety precautions: Меры безопасности
|
85
|
+
}
|
86
|
+
locality: {
|
87
|
+
section: Раздел,
|
88
|
+
clause: Пункт,
|
89
|
+
part: Часть,
|
90
|
+
paragraph: Абзац,
|
91
|
+
chapter: Глава,
|
92
|
+
page: Стр.,
|
93
|
+
table: Таблица,
|
94
|
+
annex: Дополнение,
|
95
|
+
figure: Рисунок,
|
96
|
+
example: Пример,
|
97
|
+
note: Примечание,
|
98
|
+
formula: Формула
|
99
|
+
}
|
100
|
+
inflection:
|
101
|
+
Пункт:
|
102
|
+
sg: Пункт
|
103
|
+
pl: Пункты
|
104
|
+
Дополнение:
|
105
|
+
sg: Дополнение
|
106
|
+
pl: Дополнения
|
107
|
+
Приложение:
|
108
|
+
sg: Приложение
|
109
|
+
pl: Приложения
|
110
|
+
Примечание:
|
111
|
+
sg: Примечание
|
112
|
+
pl: Примечания
|
113
|
+
"Примечание % к записи":
|
114
|
+
sg: Примечание % к записи
|
115
|
+
pl: Примечания % к записи
|
116
|
+
Список:
|
117
|
+
sg: Список
|
118
|
+
pl: Списки
|
119
|
+
Рисунок:
|
120
|
+
sg: Рисунок
|
121
|
+
pl: Рисунки
|
122
|
+
Формула:
|
123
|
+
sg: Формула
|
124
|
+
pl: Формулы
|
125
|
+
Таблица:
|
126
|
+
sg: Таблица
|
127
|
+
pl: Таблицы
|
128
|
+
Требование:
|
129
|
+
sg: Требование
|
130
|
+
pl: Требования
|
131
|
+
Рекомендация:
|
132
|
+
sg: Рекомендация
|
133
|
+
pl: Рекомендации
|
134
|
+
Разрешение:
|
135
|
+
sg: Разрешение
|
136
|
+
pl: Разрешения
|
137
|
+
Пример:
|
138
|
+
sg: Пример
|
139
|
+
pl: Примеры
|
140
|
+
Часть:
|
141
|
+
sg: Часть
|
142
|
+
pl: Части
|
143
|
+
Раздел:
|
144
|
+
sg: Раздел
|
145
|
+
pl: Разделы
|
146
|
+
Абзац:
|
147
|
+
sg: Абзац
|
148
|
+
pl: Абзацы
|
149
|
+
Глава:
|
150
|
+
sg: Глава
|
151
|
+
pl: Главы
|
152
|
+
"Стр.":
|
153
|
+
sg: Стр.
|
154
|
+
pl: Стр.
|
data/lib/isodoc/common.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require_relative "./function/blocks"
|
2
2
|
require_relative "./function/cleanup"
|
3
|
+
require_relative "./function/form"
|
3
4
|
require_relative "./function/inline"
|
4
5
|
require_relative "./function/lists"
|
5
6
|
require_relative "./function/references"
|
@@ -15,6 +16,7 @@ module IsoDoc
|
|
15
16
|
class Common
|
16
17
|
include Function::Blocks
|
17
18
|
include Function::Cleanup
|
19
|
+
include Function::Form
|
18
20
|
include Function::Inline
|
19
21
|
include Function::Lists
|
20
22
|
include Function::References
|
data/lib/isodoc/convert.rb
CHANGED
@@ -8,7 +8,7 @@ require_relative "css"
|
|
8
8
|
|
9
9
|
module IsoDoc
|
10
10
|
class Convert < ::IsoDoc::Common
|
11
|
-
attr_accessor :options, :i18n, :meta
|
11
|
+
attr_accessor :options, :i18n, :meta, :xrefs
|
12
12
|
|
13
13
|
# htmlstylesheet: Generic stylesheet for HTML
|
14
14
|
# htmlstylesheet_override: Override stylesheet for HTML
|
@@ -4,6 +4,16 @@ module IsoDoc::Function
|
|
4
4
|
module Blocks
|
5
5
|
@annotation = false
|
6
6
|
|
7
|
+
def middle_title(_isoxml, out)
|
8
|
+
out.p(**{ class: "zzSTDTitle1" }) { |p| p << @meta.get[:doctitle] }
|
9
|
+
end
|
10
|
+
|
11
|
+
def middle_admonitions(isoxml, out)
|
12
|
+
isoxml.xpath(ns("//sections/note | //sections/admonition")).each do |x|
|
13
|
+
parse(x, out)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
7
17
|
def figure_name_parse(node, div, name)
|
8
18
|
return if name.nil?
|
9
19
|
div.p **{ class: "FigureTitle", style: "text-align:center;" } do |p|
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module IsoDoc::Function
|
2
|
+
module Form
|
3
|
+
def form_parse(node, out)
|
4
|
+
node.children.each do |n|
|
5
|
+
parse(n, out)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def input_parse(node, out)
|
10
|
+
case node["type"]
|
11
|
+
when "button" then out << "[#{node['value'] || 'BUTTON'}]"
|
12
|
+
when "checkbox" then out << "☐ "
|
13
|
+
when "date" then text_input(out)
|
14
|
+
when "file" then text_input(out)
|
15
|
+
when "password" then text_input(out)
|
16
|
+
when "radio" then out << "◎ "
|
17
|
+
when "submit" # nop
|
18
|
+
when "text" then text_input(out, node["maxlength"])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def text_input(out, length = 10)
|
23
|
+
length ||= 10
|
24
|
+
length = length.to_i
|
25
|
+
length.zero? and length = 10
|
26
|
+
out << "_" * length
|
27
|
+
out << " "
|
28
|
+
end
|
29
|
+
|
30
|
+
def select_parse(node, out)
|
31
|
+
text_input(out, node["size"] || 10)
|
32
|
+
end
|
33
|
+
|
34
|
+
def label_parse(node, out)
|
35
|
+
node.children.each do |n|
|
36
|
+
parse(n, out)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def option_parse(node, out); end
|
41
|
+
|
42
|
+
def textarea_parse(_node, out)
|
43
|
+
out.table **{ border: 1, width: "50%" } do |t|
|
44
|
+
t.tr do |tr|
|
45
|
+
tr.td do |td|
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module IsoDoc::Function
|
2
2
|
module References
|
3
|
-
|
4
3
|
# This is highly specific to ISO, but it's not a bad precedent for
|
5
4
|
# references anyway; keeping here instead of in IsoDoc::Iso for now
|
6
|
-
def docid_l10n(
|
7
|
-
return
|
8
|
-
|
9
|
-
|
5
|
+
def docid_l10n(text)
|
6
|
+
return text if text.nil?
|
7
|
+
|
8
|
+
text.gsub(/All Parts/i, @i18n.all_parts.downcase) if @i18n.all_parts
|
9
|
+
text
|
10
10
|
end
|
11
11
|
|
12
12
|
# TODO generate formatted ref if not present
|
@@ -16,7 +16,7 @@ module IsoDoc::Function
|
|
16
16
|
identifiers = render_identifier(ids)
|
17
17
|
if biblio then ref_entry_code(ref, ordinal, identifiers, ids)
|
18
18
|
else
|
19
|
-
ref <<
|
19
|
+
ref << (identifiers[0] || identifiers[1]).to_s
|
20
20
|
ref << ", #{identifiers[1]}" if identifiers[0] && identifiers[1]
|
21
21
|
end
|
22
22
|
ref << ", " unless biblio && !identifiers[1]
|
@@ -29,7 +29,7 @@ module IsoDoc::Function
|
|
29
29
|
identifiers = render_identifier(bibitem_ref_code(b))
|
30
30
|
if biblio then ref_entry_code(ref, ordinal, identifiers, nil)
|
31
31
|
else
|
32
|
-
ref <<
|
32
|
+
ref << (identifiers[0] || identifiers[1]).to_s
|
33
33
|
ref << ", #{identifiers[1]}" if identifiers[0] && identifiers[1]
|
34
34
|
end
|
35
35
|
date_note_process(b, ref)
|
@@ -40,9 +40,9 @@ module IsoDoc::Function
|
|
40
40
|
|
41
41
|
# if t is just a number, only use that ([1] Non-Standard)
|
42
42
|
# else, use both ordinal, as prefix, and t
|
43
|
-
def ref_entry_code(r, ordinal, t,
|
43
|
+
def ref_entry_code(r, ordinal, t, _id)
|
44
44
|
prefix_bracketed_ref(r, t[0] || "[#{ordinal}]")
|
45
|
-
t[1] and r <<
|
45
|
+
t[1] and r << (t[1]).to_s
|
46
46
|
end
|
47
47
|
|
48
48
|
def pref_ref_code(b)
|
@@ -55,27 +55,36 @@ module IsoDoc::Function
|
|
55
55
|
id = b.at(ns("./docidentifier[@type = 'metanorma']"))
|
56
56
|
id1 = pref_ref_code(b)
|
57
57
|
id2 = b.at(ns("./docidentifier[@type = 'DOI' or @type = 'ISSN' or "\
|
58
|
-
"@type = 'ISBN']"))
|
58
|
+
"@type = 'ISBN']"))
|
59
59
|
return [id, id1, id2] if id || id1 || id2
|
60
|
+
|
60
61
|
id = Nokogiri::XML::Node.new("docidentifier", b.document)
|
61
62
|
id << "(NO ID)"
|
62
63
|
[nil, id, nil]
|
63
64
|
end
|
64
65
|
|
65
|
-
def bracket_if_num(
|
66
|
-
return nil if
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
def bracket_if_num(num)
|
67
|
+
return nil if num.nil?
|
68
|
+
|
69
|
+
num = num.text.sub(/^\[/, "").sub(/\]$/, "")
|
70
|
+
return "[#{num}]" if /^\d+$/.match?(num)
|
71
|
+
|
72
|
+
num
|
70
73
|
end
|
71
74
|
|
72
75
|
def render_identifier(id)
|
73
76
|
[
|
74
77
|
bracket_if_num(id[0]),
|
75
|
-
id[1].nil?
|
76
|
-
|
77
|
-
|
78
|
-
|
78
|
+
if id[1].nil?
|
79
|
+
nil
|
80
|
+
else
|
81
|
+
docid_prefix(id[1]["type"], id[1].text.sub(/^\[/, "").sub(/\]$/, ""))
|
82
|
+
end,
|
83
|
+
if id[2].nil?
|
84
|
+
nil
|
85
|
+
else
|
86
|
+
docid_prefix(id[2]["type"], id[2].text.sub(/^\[/, "").sub(/\]$/, ""))
|
87
|
+
end,
|
79
88
|
]
|
80
89
|
end
|
81
90
|
|
@@ -87,12 +96,14 @@ module IsoDoc::Function
|
|
87
96
|
|
88
97
|
def omit_docid_prefix(prefix)
|
89
98
|
return true if prefix.nil? || prefix.empty?
|
90
|
-
|
99
|
+
|
100
|
+
%w(ISO IEC IEV ITU W3C csd metanorma rfc-anchor).include? prefix
|
91
101
|
end
|
92
102
|
|
93
103
|
def date_note_process(b, ref)
|
94
104
|
date_note = b.at(ns("./note[@type = 'Unpublished-Status']"))
|
95
105
|
return if date_note.nil?
|
106
|
+
|
96
107
|
date_note.children.first.replace("<p>#{date_note.content}</p>")
|
97
108
|
footnote_parse(date_note, ref)
|
98
109
|
end
|
@@ -101,18 +112,17 @@ module IsoDoc::Function
|
|
101
112
|
{ id: b["id"], class: biblio ? "Biblio" : "NormRef" }
|
102
113
|
end
|
103
114
|
|
104
|
-
def iso_title(
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
title
|
115
|
+
def iso_title(bib)
|
116
|
+
bib.at(ns("./title[@language = '#{@lang}' and @type = 'main']")) ||
|
117
|
+
bib.at(ns("./title[@language = '#{@lang}']")) ||
|
118
|
+
bib.at(ns("./title[@type = 'main']")) ||
|
119
|
+
bib.at(ns("./title"))
|
110
120
|
end
|
111
121
|
|
112
122
|
# reference not to be rendered because it is deemed implicit
|
113
123
|
# in the standards environment
|
114
|
-
def implicit_reference(
|
115
|
-
|
124
|
+
def implicit_reference(bib)
|
125
|
+
bib["hidden"] == "true"
|
116
126
|
end
|
117
127
|
|
118
128
|
def prefix_bracketed_ref(ref, text)
|
@@ -120,35 +130,38 @@ module IsoDoc::Function
|
|
120
130
|
insert_tab(ref, 1)
|
121
131
|
end
|
122
132
|
|
123
|
-
def reference_format(
|
124
|
-
if ftitle =
|
133
|
+
def reference_format(bib, r)
|
134
|
+
if ftitle = bib.at(ns("./formattedref"))
|
125
135
|
ftitle&.children&.each { |n| parse(n, r) }
|
126
136
|
else
|
127
|
-
title = iso_title(
|
137
|
+
title = iso_title(bib)
|
128
138
|
r.i do |i|
|
129
139
|
title&.children&.each { |n| parse(n, i) }
|
130
140
|
end
|
131
141
|
end
|
132
142
|
end
|
133
143
|
|
134
|
-
def is_standard(
|
144
|
+
def is_standard(bib)
|
135
145
|
ret = false
|
136
|
-
|
146
|
+
bib.xpath(ns("./docidentifier")).each do |id|
|
137
147
|
next if id["type"].nil? ||
|
138
148
|
%w(metanorma DOI ISSN ISBN).include?(id["type"])
|
149
|
+
|
139
150
|
ret = true
|
140
151
|
end
|
141
152
|
ret
|
142
153
|
end
|
143
154
|
|
144
|
-
def biblio_list(
|
155
|
+
def biblio_list(refs, div, biblio)
|
145
156
|
i = 0
|
146
|
-
|
157
|
+
refs.children.each do |b|
|
147
158
|
if b.name == "bibitem"
|
148
159
|
next if implicit_reference(b)
|
160
|
+
|
149
161
|
i += 1
|
150
|
-
|
151
|
-
|
162
|
+
if is_standard(b) then std_bibitem_entry(div, b, i, biblio)
|
163
|
+
else nonstd_bibitem(div, b, i, biblio)
|
164
|
+
end
|
152
165
|
else
|
153
166
|
parse(b, div) unless %w(title).include? b.name
|
154
167
|
end
|
@@ -174,7 +187,7 @@ module IsoDoc::Function
|
|
174
187
|
num
|
175
188
|
end
|
176
189
|
|
177
|
-
def bibliography_xpath
|
190
|
+
def bibliography_xpath
|
178
191
|
"//bibliography/clause[.//references]"\
|
179
192
|
"[not(.//references[@normative = 'true'])] | "\
|
180
193
|
"//bibliography/references[@normative = 'false']"
|
@@ -184,7 +197,7 @@ module IsoDoc::Function
|
|
184
197
|
f = isoxml.at(ns(bibliography_xpath)) and f["hidden"] != "true" or return
|
185
198
|
page_break(out)
|
186
199
|
out.div do |div|
|
187
|
-
div.h1 **{class: "Section3"} do |h1|
|
200
|
+
div.h1 **{ class: "Section3" } do |h1|
|
188
201
|
f&.at(ns("./title"))&.children&.each { |c2| parse(c2, h1) }
|
189
202
|
end
|
190
203
|
biblio_list(f, div, true)
|
@@ -193,7 +206,6 @@ module IsoDoc::Function
|
|
193
206
|
|
194
207
|
def bibliography_parse(node, out)
|
195
208
|
node["hidden"] != true or return
|
196
|
-
title = node&.at(ns("./title"))&.text || ""
|
197
209
|
out.div do |div|
|
198
210
|
clause_parse_title(node, div, node.at(ns("./title")), out,
|
199
211
|
{ class: "Section3" })
|
@@ -201,11 +213,12 @@ module IsoDoc::Function
|
|
201
213
|
end
|
202
214
|
end
|
203
215
|
|
204
|
-
def format_ref(ref, prefix,
|
216
|
+
def format_ref(ref, prefix, _isopub, _date, _allparts)
|
205
217
|
ref = docid_prefix(prefix, ref)
|
206
218
|
return "[#{ref}]" if ref && /^\d+$/.match(ref) && !prefix &&
|
207
219
|
!/^\[.*\]$/.match(ref)
|
208
|
-
|
220
|
+
|
221
|
+
ref
|
209
222
|
end
|
210
223
|
end
|
211
224
|
end
|