isodoc 0.5.5 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CODE_OF_CONDUCT.md +46 -0
- data/LICENSE +25 -0
- data/README.adoc +1 -1
- data/Rakefile +6 -0
- data/isodoc.gemspec +1 -0
- data/lib/isodoc.rb +4 -95
- data/lib/isodoc/cleanup.rb +14 -10
- data/lib/isodoc/{notes.rb → comments.rb} +0 -73
- data/lib/isodoc/convert.rb +97 -0
- data/lib/isodoc/footnotes.rb +74 -0
- data/lib/isodoc/html.rb +41 -4
- data/lib/isodoc/i18n-en.yaml +1 -0
- data/lib/isodoc/i18n-fr.yaml +1 -0
- data/lib/isodoc/i18n-zh-Hans.yaml +1 -0
- data/lib/isodoc/i18n.rb +1 -0
- data/lib/isodoc/inline.rb +4 -12
- data/lib/isodoc/iso2wordhtml.rb +26 -13
- data/lib/isodoc/metadata.rb +23 -10
- data/lib/isodoc/references.rb +20 -22
- data/lib/isodoc/section.rb +4 -3
- data/lib/isodoc/table.rb +0 -2
- data/lib/isodoc/terms.rb +2 -13
- data/lib/isodoc/utils.rb +24 -3
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/wordconvert/comments.rb +155 -0
- data/lib/isodoc/wordconvert/convert.rb +31 -0
- data/lib/isodoc/wordconvert/footnotes.rb +80 -0
- data/lib/isodoc/wordconvert/wordconvertmodule.rb +212 -0
- data/lib/isodoc/xref_gen.rb +50 -79
- data/lib/isodoc/xref_sect_gen.rb +82 -0
- data/spec/assets/header.html +7 -0
- data/spec/assets/html.css +2 -0
- data/spec/assets/htmlcover.html +4 -0
- data/spec/assets/htmlintro.html +5 -0
- data/spec/assets/i18n.yaml +2 -0
- data/spec/assets/iso.xml +8 -0
- data/spec/assets/rice_image1.png +0 -0
- data/spec/assets/std.css +2 -0
- data/spec/assets/word.css +2 -0
- data/spec/assets/wordcover.html +3 -0
- data/spec/assets/wordintro.html +4 -0
- data/spec/isodoc/blocks_spec.rb +130 -47
- data/spec/isodoc/cleanup_spec.rb +693 -0
- data/spec/isodoc/footnotes_spec.rb +282 -0
- data/spec/isodoc/i18n_spec.rb +662 -0
- data/spec/isodoc/inline_spec.rb +344 -0
- data/spec/isodoc/lists_spec.rb +81 -18
- data/spec/isodoc/metadata_spec.rb +141 -0
- data/spec/isodoc/postproc_spec.rb +444 -0
- data/spec/isodoc/ref_spec.rb +158 -0
- data/spec/isodoc/section_spec.rb +275 -112
- data/spec/isodoc/table_spec.rb +146 -8
- data/spec/isodoc/terms_spec.rb +118 -0
- data/spec/isodoc/xref_spec.rb +490 -114
- metadata +46 -4
- data/lib/isodoc/postprocessing.rb +0 -176
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de4c3e74196d5812243cf431a1d013c2f13ec687
|
4
|
+
data.tar.gz: 731a94da93e07e7494a7b565823f7c1904861996
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0464408db2c12b91837bb66a523e7f149b376ece67044d47a6d92b1a5dc7756bdc8bc13d49e084287ed5c8f6dc5569491ec3b856021e2d22c6831bfee9e2cfe
|
7
|
+
data.tar.gz: c3a5075be9cdb977ddc58787d857d1477c636fc037fe5cde78e2795c03e3450b515681a4751a7b2bb9db22b32c20a604272f6d9e2ed9537cd2bd24aead1ded09
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
## Our Standards
|
8
|
+
|
9
|
+
Examples of behavior that contributes to creating a positive environment include:
|
10
|
+
|
11
|
+
* Using welcoming and inclusive language
|
12
|
+
* Being respectful of differing viewpoints and experiences
|
13
|
+
* Gracefully accepting constructive criticism
|
14
|
+
* Focusing on what is best for the community
|
15
|
+
* Showing empathy towards other community members
|
16
|
+
|
17
|
+
Examples of unacceptable behavior by participants include:
|
18
|
+
|
19
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
20
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
21
|
+
* Public or private harassment
|
22
|
+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
23
|
+
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
24
|
+
|
25
|
+
## Our Responsibilities
|
26
|
+
|
27
|
+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
28
|
+
|
29
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
30
|
+
|
31
|
+
## Scope
|
32
|
+
|
33
|
+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
34
|
+
|
35
|
+
## Enforcement
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at ronald.tse@ribose.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
38
|
+
|
39
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
40
|
+
|
41
|
+
## Attribution
|
42
|
+
|
43
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
44
|
+
|
45
|
+
[homepage]: http://contributor-covenant.org
|
46
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/LICENSE
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
BSD 2-Clause License
|
2
|
+
|
3
|
+
Copyright (c) 2018, Ribose
|
4
|
+
All rights reserved.
|
5
|
+
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
8
|
+
|
9
|
+
* Redistributions of source code must retain the above copyright notice, this
|
10
|
+
list of conditions and the following disclaimer.
|
11
|
+
|
12
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
14
|
+
and/or other materials provided with the distribution.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
17
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
18
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
19
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
20
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
21
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
22
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
23
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
24
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
25
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.adoc
CHANGED
@@ -15,7 +15,7 @@ standardsheet:: Stylesheet specific to Standard
|
|
15
15
|
header:: Header file for Word
|
16
16
|
htmlcoverpage:: Cover page for HTML
|
17
17
|
wordcoverpage:: Cover page for Word
|
18
|
-
|
18
|
+
htmlintropage:: Introductory page for HTML
|
19
19
|
wordintropage:: Introductory page for Word
|
20
20
|
|
21
21
|
e.g.
|
data/Rakefile
ADDED
data/isodoc.gemspec
CHANGED
@@ -38,6 +38,7 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.add_dependency "uuidtools"
|
39
39
|
spec.add_dependency "html2doc"
|
40
40
|
spec.add_dependency "liquid"
|
41
|
+
spec.add_dependency "roman-numerals"
|
41
42
|
|
42
43
|
spec.add_development_dependency "bundler", "~> 1.15"
|
43
44
|
spec.add_development_dependency "byebug", "~> 9.1"
|
data/lib/isodoc.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
module Isodoc
|
2
|
+
|
1
3
|
require_relative "isodoc/version"
|
2
4
|
|
3
5
|
require "nokogiri"
|
@@ -8,100 +10,7 @@ require "base64"
|
|
8
10
|
require "mime/types"
|
9
11
|
require "image_size"
|
10
12
|
require "set"
|
11
|
-
require_relative "isodoc/iso2wordhtml"
|
12
|
-
require_relative "isodoc/cleanup"
|
13
|
-
require_relative "isodoc/postprocessing"
|
14
|
-
require_relative "isodoc/utils"
|
15
|
-
require_relative "isodoc/metadata"
|
16
|
-
require_relative "isodoc/section"
|
17
|
-
require_relative "isodoc/references"
|
18
|
-
require_relative "isodoc/terms"
|
19
|
-
require_relative "isodoc/blocks"
|
20
|
-
require_relative "isodoc/lists"
|
21
|
-
require_relative "isodoc/table"
|
22
|
-
require_relative "isodoc/inline"
|
23
|
-
require_relative "isodoc/notes"
|
24
|
-
require_relative "isodoc/xref_gen"
|
25
|
-
require_relative "isodoc/html"
|
26
|
-
require_relative "isodoc/i18n"
|
27
13
|
require "pp"
|
28
|
-
|
29
|
-
|
30
|
-
class Convert
|
31
|
-
|
32
|
-
# htmlstylesheet: Generic stylesheet for HTML
|
33
|
-
# wordstylesheet: Generic stylesheet for Word
|
34
|
-
# standardsheet: Stylesheet specific to Standard
|
35
|
-
# header: Header file for Word
|
36
|
-
# htmlcoverpage: Cover page for HTML
|
37
|
-
# wordcoverpage: Cover page for Word
|
38
|
-
# htmlintropage: Introductory page for HTML
|
39
|
-
# wordintropage: Introductory page for Word
|
40
|
-
# i18nyaml: YAML file for internationalisation of text
|
41
|
-
# ulstyle: list style in Word CSS for unordered lists
|
42
|
-
# olstyle: list style in Word CSS for ordered lists
|
43
|
-
def initialize(options)
|
44
|
-
@htmlstylesheet = options[:htmlstylesheet]
|
45
|
-
@wordstylesheet = options[:wordstylesheet]
|
46
|
-
@standardstylesheet = options[:standardstylesheet]
|
47
|
-
@header = options[:header]
|
48
|
-
@htmlcoverpage = options[:htmlcoverpage]
|
49
|
-
@wordcoverpage = options[:wordcoverpage]
|
50
|
-
@htmlintropage = options[:htmlintropage]
|
51
|
-
@wordintropage = options[:wordintropage]
|
52
|
-
@i18nyaml = options[:i18nyaml]
|
53
|
-
@ulstyle = options[:ulstyle]
|
54
|
-
@olstyle = options[:olstyle]
|
55
|
-
@termdomain = ""
|
56
|
-
@termexample = false
|
57
|
-
@note = false
|
58
|
-
@sourcecode = false
|
59
|
-
@anchors = {}
|
60
|
-
@meta = {}
|
61
|
-
init_metadata
|
62
|
-
@footnotes = []
|
63
|
-
@comments = []
|
64
|
-
@in_footnote = false
|
65
|
-
@in_comment = false
|
66
|
-
@in_table = false
|
67
|
-
@in_figure = false
|
68
|
-
@seen_footnote = Set.new
|
69
|
-
@c = HTMLEntities.new
|
70
|
-
@openmathdelim = "`"
|
71
|
-
@closemathdelim = "`"
|
72
|
-
@lang = "en"
|
73
|
-
@script = "Latn"
|
74
|
-
end
|
75
|
-
|
76
|
-
def convert1(docxml, filename, dir)
|
77
|
-
noko do |xml|
|
78
|
-
xml.html do |html|
|
79
|
-
html.parent.add_namespace("epub", "http://www.idpf.org/2007/ops")
|
80
|
-
html_header(html, docxml, filename, dir)
|
81
|
-
make_body(html, docxml)
|
82
|
-
end
|
83
|
-
end.join("\n")
|
84
|
-
end
|
85
|
-
|
86
|
-
def convert_init(file, filename, debug)
|
87
|
-
docxml = Nokogiri::XML(file)
|
88
|
-
filename, dir = init_file(filename, debug)
|
89
|
-
docxml.root.default_namespace = ""
|
90
|
-
i18n_init(docxml&.at(ns("//bibdata/language"))&.text || "en",
|
91
|
-
docxml&.at(ns("//bibdata/script"))&.text || "Latn")
|
92
|
-
[docxml, filename, dir]
|
93
|
-
end
|
94
|
-
|
95
|
-
def convert(filename, debug = false)
|
96
|
-
convert_file(File.read(filename), filename, debug)
|
97
|
-
end
|
98
|
-
|
99
|
-
def convert_file(file, filename, debug)
|
100
|
-
@openmathdelim, @closemathdelim = extract_delims(file)
|
101
|
-
docxml, filename, dir = convert_init(file, filename, debug)
|
102
|
-
result = convert1(docxml, filename, dir)
|
103
|
-
return result if debug
|
104
|
-
postprocess(result, filename, dir)
|
105
|
-
end
|
106
|
-
end
|
14
|
+
require "isodoc/convert"
|
15
|
+
require "isodoc/wordconvert/convert"
|
107
16
|
end
|
data/lib/isodoc/cleanup.rb
CHANGED
@@ -19,7 +19,7 @@ module IsoDoc
|
|
19
19
|
docxml.xpath("//div[@class = 'Admonition'][title]").each do |d|
|
20
20
|
title = d.at("./title")
|
21
21
|
n = title.next_element
|
22
|
-
n&.children&.first&.add_previous_sibling(title.text + "—")
|
22
|
+
n&.children&.first&.add_previous_sibling(title.remove.text + "—")
|
23
23
|
end
|
24
24
|
docxml
|
25
25
|
end
|
@@ -39,7 +39,7 @@ module IsoDoc
|
|
39
39
|
|
40
40
|
def figure_aside_process(f, aside, key)
|
41
41
|
# get rid of footnote link, it is in diagram
|
42
|
-
f
|
42
|
+
f&.at("./a[@class='TableFootnoteRef']")&.remove
|
43
43
|
fnref = f.at(".//a[@class='TableFootnoteRef']")
|
44
44
|
dt = key.add_child("<dt></dt>").first
|
45
45
|
dd = key.add_child("<dd></dd>").first
|
@@ -50,15 +50,16 @@ module IsoDoc
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
+
# move footnotes into key, and get rid of footnote reference
|
54
|
+
# since it is in diagram
|
53
55
|
def figure_cleanup(docxml)
|
54
|
-
# move footnotes into key, and get rid of footnote reference
|
55
|
-
# since it is in diagram
|
56
56
|
docxml.xpath(FIGURE_WITH_FOOTNOTES).each do |f|
|
57
57
|
key = figure_get_or_make_dl(f)
|
58
58
|
f.xpath(".//aside").each do |aside|
|
59
59
|
figure_aside_process(f, aside, key)
|
60
60
|
end
|
61
61
|
end
|
62
|
+
docxml
|
62
63
|
end
|
63
64
|
|
64
65
|
def inline_header_cleanup(docxml)
|
@@ -71,6 +72,7 @@ module IsoDoc
|
|
71
72
|
n.children.first.previous = x.remove
|
72
73
|
end
|
73
74
|
end
|
75
|
+
docxml
|
74
76
|
end
|
75
77
|
|
76
78
|
def footnote_cleanup(docxml)
|
@@ -99,8 +101,7 @@ module IsoDoc
|
|
99
101
|
|
100
102
|
def remove_bottom_border(td)
|
101
103
|
td["style"] =
|
102
|
-
td["style"].gsub(/border-bottom:[^;]+;/, "border-bottom:0pt;")
|
103
|
-
gsub(/mso-border-bottom-alt:[^;]+;/, "mso-border-bottom-alt:0pt;")
|
104
|
+
td["style"].gsub(/border-bottom:[^;]+;/, "border-bottom:0pt;")
|
104
105
|
end
|
105
106
|
|
106
107
|
def table_get_or_make_tfoot(t)
|
@@ -120,8 +121,7 @@ module IsoDoc
|
|
120
121
|
t.at(".//tr").xpath("./td | ./th").each do |td|
|
121
122
|
cols += (td["colspan"] ? td["colspan"].to_i : 1)
|
122
123
|
end
|
123
|
-
style = %{border-top:0pt;
|
124
|
-
border-bottom:#{SW} 1.5pt;mso-border-bottom-alt:#{SW} 1.5pt;}
|
124
|
+
style = %{border-top:0pt;border-bottom:#{SW} 1.5pt;}
|
125
125
|
tfoot.add_child("<tr><td colspan='#{cols}' style='#{style}'/></tr>")
|
126
126
|
tfoot.xpath(".//td").last
|
127
127
|
end
|
@@ -142,9 +142,11 @@ module IsoDoc
|
|
142
142
|
def table_cleanup(docxml)
|
143
143
|
table_footnote_cleanup(docxml)
|
144
144
|
table_note_cleanup(docxml)
|
145
|
+
docxml
|
145
146
|
end
|
146
147
|
|
147
|
-
# We assume AsciiMath
|
148
|
+
# We assume AsciiMath is being used in the terms & definitions.
|
149
|
+
# Indices sort after letter but before any following
|
148
150
|
# letter (x, x_m, x_1, xa); we use colon to force that sort order.
|
149
151
|
# Numbers sort *after* letters; we use thorn to force that sort order.
|
150
152
|
def symbol_key(x)
|
@@ -165,10 +167,12 @@ module IsoDoc
|
|
165
167
|
end
|
166
168
|
|
167
169
|
def symbols_cleanup(docxml)
|
168
|
-
dl = docxml.at("//div[@class = 'Symbols']/dl")
|
170
|
+
dl = docxml.at("//div[@class = 'Symbols']/dl")
|
171
|
+
return docxml unless dl
|
169
172
|
dl_out = extract_symbols_list(dl)
|
170
173
|
dl_out.sort! { |a, b| a[:key] <=> b[:key] }
|
171
174
|
dl.replace(dl_out.map { |d| d[:dt].to_s + d[:dd].to_s }.join("\n"))
|
175
|
+
docxml
|
172
176
|
end
|
173
177
|
end
|
174
178
|
end
|
@@ -2,83 +2,10 @@ require "uuidtools"
|
|
2
2
|
|
3
3
|
module IsoDoc
|
4
4
|
class Convert
|
5
|
-
def in_footnote
|
6
|
-
@in_footnote
|
7
|
-
end
|
8
|
-
|
9
5
|
def in_comment
|
10
6
|
@in_comment
|
11
7
|
end
|
12
8
|
|
13
|
-
def footnotes(div)
|
14
|
-
return if @footnotes.empty?
|
15
|
-
@footnotes.each { |fn| div.parent << fn }
|
16
|
-
end
|
17
|
-
|
18
|
-
def make_table_footnote_link(out, fnid, fnref)
|
19
|
-
attrs = { href: "##{fnid}", class: "TableFootnoteRef" }
|
20
|
-
out.a **attrs do |a|
|
21
|
-
a << fnref
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def make_table_footnote_target(out, fnid, fnref)
|
26
|
-
attrs = { id: fnid, class: "TableFootnoteRef" }
|
27
|
-
out.a **attrs do |a|
|
28
|
-
a << fnref
|
29
|
-
insert_tab(a, 1)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def make_table_footnote_text(node, fnid, fnref)
|
34
|
-
attrs = { id: "ftn#{fnid}" }
|
35
|
-
noko do |xml|
|
36
|
-
xml.div **attr_code(attrs) do |div|
|
37
|
-
make_table_footnote_target(div, fnid, fnref)
|
38
|
-
node.children.each { |n| parse(n, div) }
|
39
|
-
end
|
40
|
-
end.join("\n")
|
41
|
-
end
|
42
|
-
|
43
|
-
def make_generic_footnote_text(node, fnid)
|
44
|
-
noko do |xml|
|
45
|
-
xml.aside **{ id: "ftn#{fnid}" } do |div|
|
46
|
-
node.children.each { |n| parse(n, div) }
|
47
|
-
end
|
48
|
-
end.join("\n")
|
49
|
-
end
|
50
|
-
|
51
|
-
def get_table_ancestor_id(node)
|
52
|
-
table = node.ancestors("table") || node.ancestors("figure")
|
53
|
-
return UUIDTools::UUID.random_create.to_s if table.empty?
|
54
|
-
table.last["id"]
|
55
|
-
end
|
56
|
-
|
57
|
-
def table_footnote_parse(node, out)
|
58
|
-
fn = node["reference"]
|
59
|
-
tid = get_table_ancestor_id(node)
|
60
|
-
make_table_footnote_link(out, tid + fn, fn)
|
61
|
-
# do not output footnote text if we have already seen it for this table
|
62
|
-
return if @seen_footnote.include?(tid + fn)
|
63
|
-
@in_footnote = true
|
64
|
-
out.aside { |a| a << make_table_footnote_text(node, tid + fn, fn) }
|
65
|
-
@in_footnote = false
|
66
|
-
@seen_footnote << (tid + fn)
|
67
|
-
end
|
68
|
-
|
69
|
-
def footnote_parse(node, out)
|
70
|
-
return table_footnote_parse(node, out) if @in_table || @in_figure
|
71
|
-
fn = node["reference"]
|
72
|
-
out.a **{ "epub:type": "footnote", href: "#ftn#{fn}" } do |a|
|
73
|
-
a.sup { |sup| sup << fn }
|
74
|
-
end
|
75
|
-
return if @seen_footnote.include?(fn)
|
76
|
-
@in_footnote = true
|
77
|
-
@footnotes << make_generic_footnote_text(node, fn)
|
78
|
-
@in_footnote = false
|
79
|
-
@seen_footnote << fn
|
80
|
-
end
|
81
|
-
|
82
9
|
def comments(div)
|
83
10
|
return if @comments.empty?
|
84
11
|
div.div **{ style: "mso-element:comment-list" } do |div1|
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require "isodoc/iso2wordhtml"
|
2
|
+
require "isodoc/cleanup"
|
3
|
+
require "isodoc/utils"
|
4
|
+
require "isodoc/metadata"
|
5
|
+
require "isodoc/section"
|
6
|
+
require "isodoc/references"
|
7
|
+
require "isodoc/terms"
|
8
|
+
require "isodoc/blocks"
|
9
|
+
require "isodoc/lists"
|
10
|
+
require "isodoc/table"
|
11
|
+
require "isodoc/inline"
|
12
|
+
require "isodoc/footnotes"
|
13
|
+
require "isodoc/comments"
|
14
|
+
require "isodoc/xref_gen"
|
15
|
+
require "isodoc/xref_sect_gen"
|
16
|
+
require "isodoc/html"
|
17
|
+
require "isodoc/i18n"
|
18
|
+
|
19
|
+
module IsoDoc
|
20
|
+
class Convert
|
21
|
+
|
22
|
+
# htmlstylesheet: Generic stylesheet for HTML
|
23
|
+
# wordstylesheet: Generic stylesheet for Word
|
24
|
+
# standardsheet: Stylesheet specific to Standard
|
25
|
+
# header: Header file for Word
|
26
|
+
# htmlcoverpage: Cover page for HTML
|
27
|
+
# wordcoverpage: Cover page for Word
|
28
|
+
# htmlintropage: Introductory page for HTML
|
29
|
+
# wordintropage: Introductory page for Word
|
30
|
+
# i18nyaml: YAML file for internationalisation of text
|
31
|
+
# ulstyle: list style in Word CSS for unordered lists
|
32
|
+
# olstyle: list style in Word CSS for ordered lists
|
33
|
+
def initialize(options)
|
34
|
+
@htmlstylesheet = options[:htmlstylesheet]
|
35
|
+
@wordstylesheet = options[:wordstylesheet]
|
36
|
+
@standardstylesheet = options[:standardstylesheet]
|
37
|
+
@header = options[:header]
|
38
|
+
@htmlcoverpage = options[:htmlcoverpage]
|
39
|
+
@wordcoverpage = options[:wordcoverpage]
|
40
|
+
@htmlintropage = options[:htmlintropage]
|
41
|
+
@wordintropage = options[:wordintropage]
|
42
|
+
@i18nyaml = options[:i18nyaml]
|
43
|
+
@ulstyle = options[:ulstyle]
|
44
|
+
@olstyle = options[:olstyle]
|
45
|
+
@termdomain = ""
|
46
|
+
@termexample = false
|
47
|
+
@note = false
|
48
|
+
@sourcecode = false
|
49
|
+
@anchors = {}
|
50
|
+
@meta = {}
|
51
|
+
init_metadata
|
52
|
+
@footnotes = []
|
53
|
+
@comments = []
|
54
|
+
@in_footnote = false
|
55
|
+
@in_comment = false
|
56
|
+
@in_table = false
|
57
|
+
@in_figure = false
|
58
|
+
@seen_footnote = Set.new
|
59
|
+
@c = HTMLEntities.new
|
60
|
+
@openmathdelim = "`"
|
61
|
+
@closemathdelim = "`"
|
62
|
+
@lang = "en"
|
63
|
+
@script = "Latn"
|
64
|
+
end
|
65
|
+
|
66
|
+
def convert1(docxml, filename, dir)
|
67
|
+
noko do |xml|
|
68
|
+
xml.html do |html|
|
69
|
+
html.parent.add_namespace("epub", "http://www.idpf.org/2007/ops")
|
70
|
+
html_header(html, docxml, filename, dir)
|
71
|
+
make_body(html, docxml)
|
72
|
+
end
|
73
|
+
end.join("\n")
|
74
|
+
end
|
75
|
+
|
76
|
+
def convert_init(file, filename, debug)
|
77
|
+
docxml = Nokogiri::XML(file)
|
78
|
+
filename, dir = init_file(filename, debug)
|
79
|
+
docxml.root.default_namespace = ""
|
80
|
+
i18n_init(docxml&.at(ns("//bibdata/language"))&.text || "en",
|
81
|
+
docxml&.at(ns("//bibdata/script"))&.text || "Latn")
|
82
|
+
[docxml, filename, dir]
|
83
|
+
end
|
84
|
+
|
85
|
+
def convert(filename, debug = false)
|
86
|
+
convert_file(File.read(filename), filename, debug)
|
87
|
+
end
|
88
|
+
|
89
|
+
def convert_file(file, filename, debug)
|
90
|
+
@openmathdelim, @closemathdelim = extract_delims(file)
|
91
|
+
docxml, filename, dir = convert_init(file, filename, debug)
|
92
|
+
result = convert1(docxml, filename, dir)
|
93
|
+
return result if debug
|
94
|
+
postprocess(result, filename, dir)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|