html2doc 1.0.4 → 1.1.0
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/.github/workflows/rake.yml +42 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +6 -2
- data/README.adoc +1 -3
- data/html2doc.gemspec +4 -3
- data/lib/html2doc/base.rb +15 -6
- data/lib/html2doc/math.rb +86 -6
- data/lib/html2doc/mime.rb +19 -10
- data/lib/html2doc/mml2omml.xsl +35 -7
- data/lib/html2doc/version.rb +1 -1
- data/spec/html2doc_spec.rb +63 -21
- metadata +26 -16
- data/.github/workflows/macos.yml +0 -38
- data/.github/workflows/ubuntu.yml +0 -56
- data/.github/workflows/windows.yml +0 -40
- data/.rubocop.ribose.yml +0 -65
- data/.rubocop.tb.yml +0 -650
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1d55301cebf98f75ddfd8966237d19c39bae1c9c8b4b01a39f124ca5da8e588
|
4
|
+
data.tar.gz: a84cd4d87e2cf1c9f107300c883b6b6b85496e2067e76d7f0a282feecf6550c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ef21ec975f624420db8ee706ab1997ab7941bb7e9f75bfaecdde056346a08f73842cd151ad6f5c7a9711a0616ccc61177bd24f17693f8c31c6db70e7aa78088
|
7
|
+
data.tar.gz: c204dfcb3f27a24f86908195d47287c74daaaa41d02de5f28fbb99167b17895f7b46e27971ae533c18874f09ed2d32d4205c6dcd9c6ee6b9e045a9dc06656bfa
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
3
|
+
name: rake
|
4
|
+
|
5
|
+
on:
|
6
|
+
push:
|
7
|
+
branches: [ master, main ]
|
8
|
+
tags: [ v* ]
|
9
|
+
pull_request:
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
rake:
|
13
|
+
name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
|
14
|
+
runs-on: ${{ matrix.os }}
|
15
|
+
continue-on-error: ${{ matrix.experimental }}
|
16
|
+
strategy:
|
17
|
+
fail-fast: false
|
18
|
+
matrix:
|
19
|
+
ruby: [ '2.7', '2.6', '2.5', '2.4' ]
|
20
|
+
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
21
|
+
experimental: [ false ]
|
22
|
+
include:
|
23
|
+
- ruby: '3.0'
|
24
|
+
os: 'ubuntu-latest'
|
25
|
+
experimental: true
|
26
|
+
- ruby: '3.0'
|
27
|
+
os: 'windows-latest'
|
28
|
+
experimental: true
|
29
|
+
- ruby: '3.0'
|
30
|
+
os: 'macos-latest'
|
31
|
+
experimental: true
|
32
|
+
steps:
|
33
|
+
- uses: actions/checkout@v2
|
34
|
+
with:
|
35
|
+
submodules: true
|
36
|
+
|
37
|
+
- uses: ruby/setup-ruby@v1
|
38
|
+
with:
|
39
|
+
ruby-version: ${{ matrix.ruby }}
|
40
|
+
bundler-cache: true
|
41
|
+
|
42
|
+
- run: bundle exec rake
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
# This project follows the Ribose OSS style guide.
|
2
2
|
# https://github.com/riboseinc/oss-guides
|
3
3
|
# All project-specific additions and overrides should be specified in this file.
|
4
|
-
|
5
4
|
inherit_from:
|
6
5
|
- https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
|
6
|
+
|
7
|
+
# local repo-specific modifications
|
8
|
+
|
7
9
|
AllCops:
|
8
|
-
|
10
|
+
DisplayCopNames: false
|
11
|
+
StyleGuideCopsOnly: false
|
12
|
+
TargetRubyVersion: 2.4
|
9
13
|
Rails:
|
10
14
|
Enabled: true
|
data/README.adoc
CHANGED
@@ -3,9 +3,7 @@
|
|
3
3
|
https://github.com/metanorma/html2doc/workflows/main/badge.svg
|
4
4
|
|
5
5
|
image:https://img.shields.io/gem/v/html2doc.svg["Gem Version", link="https://rubygems.org/gems/html2doc"]
|
6
|
-
image:https://github.com/metanorma/html2doc/workflows/
|
7
|
-
image:https://github.com/metanorma/html2doc/workflows/macos/badge.svg["OSX Build Status", link="https://github.com/metanorma/html2doc/actions?query=workflow%3Amacos"]
|
8
|
-
image:https://github.com/metanorma/html2doc/workflows/windows/badge.svg["Windows Build Status", link="https://github.com/metanorma/html2doc/actions?query=workflow%3Awindows"]
|
6
|
+
image:https://github.com/metanorma/html2doc/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/html2doc/actions?workflow=rake"]
|
9
7
|
image:https://codeclimate.com/github/metanorma/html2doc/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/html2doc"]
|
10
8
|
image:https://img.shields.io/github/issues-pr-raw/metanorma/html2doc.svg["Pull Requests", link="https://github.com/metanorma/html2doc/pulls"]
|
11
9
|
image:https://img.shields.io/github/commits-since/metanorma/html2doc/latest.svg["Commits since latest",link="https://github.com/metanorma/html2doc/releases"]
|
data/html2doc.gemspec
CHANGED
@@ -28,10 +28,11 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_dependency "htmlentities", "~> 4.3.4"
|
29
29
|
spec.add_dependency "image_size"
|
30
30
|
spec.add_dependency "mime-types"
|
31
|
-
spec.add_dependency "nokogiri", "
|
31
|
+
spec.add_dependency "nokogiri", "~> 1.10.4"
|
32
32
|
spec.add_dependency "thread_safe"
|
33
33
|
spec.add_dependency "uuidtools"
|
34
|
-
spec.add_dependency "asciimath", "~> 2.0.
|
34
|
+
spec.add_dependency "asciimath", "~> 2.0.2"
|
35
|
+
spec.add_dependency "plane1converter", "~> 0.0.1"
|
35
36
|
|
36
37
|
spec.add_development_dependency "byebug", "~> 9.1"
|
37
38
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
@@ -39,7 +40,7 @@ Gem::Specification.new do |spec|
|
|
39
40
|
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
40
41
|
spec.add_development_dependency "rake", "~> 12.0"
|
41
42
|
spec.add_development_dependency "rspec", "~> 3.6"
|
42
|
-
spec.add_development_dependency "rubocop", "
|
43
|
+
spec.add_development_dependency "rubocop", "~> 1.5.2"
|
43
44
|
spec.add_development_dependency "simplecov", "~> 0.15"
|
44
45
|
spec.add_development_dependency "timecop", "~> 0.9"
|
45
46
|
spec.add_development_dependency "rspec-match_fuzzy", "~> 0.1.3"
|
data/lib/html2doc/base.rb
CHANGED
@@ -24,11 +24,19 @@ module Html2Doc
|
|
24
24
|
File.open("#{hash[:dir1]}/header.html", "w:UTF-8") { |f| f.write(doc) }
|
25
25
|
end
|
26
26
|
|
27
|
+
def self.clear_dir(dir)
|
28
|
+
Dir.foreach(dir) do |f|
|
29
|
+
fn = File.join(dir, f)
|
30
|
+
File.delete(fn) if f != '.' && f != '..'
|
31
|
+
end
|
32
|
+
dir
|
33
|
+
end
|
34
|
+
|
27
35
|
def self.create_dir(filename, dir)
|
28
|
-
|
36
|
+
dir and return clear_dir(dir)
|
29
37
|
dir = "#{filename}_files"
|
30
38
|
Dir.mkdir(dir) unless File.exists?(dir)
|
31
|
-
dir
|
39
|
+
clear_dir(dir)
|
32
40
|
end
|
33
41
|
|
34
42
|
def self.process_html(result, hash)
|
@@ -123,18 +131,19 @@ module Html2Doc
|
|
123
131
|
docxml.xpath("//*[local-name() = 'head']").each do |h|
|
124
132
|
h.children.first.add_previous_sibling <<~XML
|
125
133
|
#{PRINT_VIEW}
|
126
|
-
<link rel="File-List" href="
|
134
|
+
<link rel="File-List" href="cid:filelist.xml"/>
|
127
135
|
XML
|
128
136
|
end
|
129
137
|
end
|
130
138
|
|
131
139
|
def self.filename_substitute(stylesheet, header_filename, filename)
|
132
140
|
if header_filename.nil?
|
133
|
-
stylesheet
|
141
|
+
stylesheet
|
134
142
|
else
|
135
|
-
stylesheet.gsub
|
143
|
+
stylesheet.gsub(/url\("[^"]+"\)/) do |m|
|
144
|
+
/FILENAME/.match(m) ? "url(cid:header.html)" : m
|
145
|
+
end
|
136
146
|
end
|
137
|
-
stylesheet
|
138
147
|
end
|
139
148
|
|
140
149
|
def self.stylesheet(filename, header_filename, fn)
|
data/lib/html2doc/math.rb
CHANGED
@@ -2,6 +2,7 @@ require "uuidtools"
|
|
2
2
|
require "asciimath"
|
3
3
|
require "htmlentities"
|
4
4
|
require "nokogiri"
|
5
|
+
require "plane1converter"
|
5
6
|
|
6
7
|
module Html2Doc
|
7
8
|
@xsltemplate =
|
@@ -9,9 +10,15 @@ module Html2Doc
|
|
9
10
|
encoding: "utf-8"))
|
10
11
|
|
11
12
|
def self.asciimath_to_mathml1(x)
|
12
|
-
|
13
|
-
AsciiMath.
|
14
|
-
|
13
|
+
begin
|
14
|
+
AsciiMath::MathMLBuilder.new(:msword => true).append_expression(
|
15
|
+
AsciiMath.parse(HTMLEntities.new.decode(x)).ast).to_s.
|
16
|
+
gsub(/<math>/, "<math xmlns='http://www.w3.org/1998/Math/MathML'>")
|
17
|
+
rescue StandardError => e
|
18
|
+
puts "parsing: #{x}"
|
19
|
+
puts e.message
|
20
|
+
raise e
|
21
|
+
end
|
15
22
|
end
|
16
23
|
|
17
24
|
def self.asciimath_to_mathml(doc, delims)
|
@@ -25,20 +32,93 @@ module Html2Doc
|
|
25
32
|
end.join
|
26
33
|
end
|
27
34
|
|
35
|
+
def self.unwrap_accents(doc)
|
36
|
+
doc.xpath("//*[@accent = 'true']").each do |x|
|
37
|
+
x.elements.length > 1 or next
|
38
|
+
x.elements[1].name == "mrow" and
|
39
|
+
x.elements[1].replace(x.elements[1].children)
|
40
|
+
end
|
41
|
+
doc
|
42
|
+
end
|
43
|
+
|
28
44
|
# random fixes to MathML input that OOXML needs to render properly
|
29
45
|
def self.ooxml_cleanup(m, docnamespaces)
|
46
|
+
m = unwrap_accents(mathml_preserve_space(
|
47
|
+
mathml_insert_rows(m, docnamespaces), docnamespaces))
|
48
|
+
m.add_namespace(nil, "http://www.w3.org/1998/Math/MathML")
|
49
|
+
m
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.mathml_insert_rows(m, docnamespaces)
|
30
53
|
m.xpath(%w(msup msub msubsup munder mover munderover).
|
31
54
|
map { |m| ".//xmlns:#{m}" }.join(" | "), docnamespaces).each do |x|
|
32
55
|
next unless x.next_element && x.next_element != "mrow"
|
33
56
|
x.next_element.wrap("<mrow/>")
|
34
57
|
end
|
58
|
+
m
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.mathml_preserve_space(m, docnamespaces)
|
35
62
|
m.xpath(".//xmlns:mtext", docnamespaces).each do |x|
|
36
63
|
x.children = x.children.to_xml.gsub(/^\s/, " ").gsub(/\s$/, " ")
|
37
64
|
end
|
38
|
-
m.add_namespace(nil, "http://www.w3.org/1998/Math/MathML")
|
39
65
|
m
|
40
66
|
end
|
41
67
|
|
68
|
+
def self.unitalic(m)
|
69
|
+
m.xpath(".//xmlns:r[xmlns:rPr[not(xmlns:scr)]/xmlns:sty[@m:val = 'p']]").each do |x|
|
70
|
+
x.wrap("<span style='font-style:normal;'></span>")
|
71
|
+
end
|
72
|
+
m.xpath(".//xmlns:r[xmlns:rPr[not(xmlns:scr)]/xmlns:sty[@m:val = 'bi']]").each do |x|
|
73
|
+
x.wrap("<span class='nostem' style='font-weight:bold;'><em></em></span>")
|
74
|
+
end
|
75
|
+
m.xpath(".//xmlns:r[xmlns:rPr[not(xmlns:scr)]/xmlns:sty[@m:val = 'i']]").each do |x|
|
76
|
+
x.wrap("<span class='nostem'><em></em></span>")
|
77
|
+
end
|
78
|
+
m.xpath(".//xmlns:r[xmlns:rPr[not(xmlns:scr)]/xmlns:sty[@m:val = 'b']]").each do |x|
|
79
|
+
x.wrap("<span style='font-style:normal;font-weight:bold;'></span>")
|
80
|
+
end
|
81
|
+
m.xpath(".//xmlns:r[xmlns:rPr/xmlns:scr[@m:val = 'monospace']]").each do |x|
|
82
|
+
toPlane1(x, :monospace)
|
83
|
+
end
|
84
|
+
m.xpath(".//xmlns:r[xmlns:rPr/xmlns:scr[@m:val = 'double-struck']]").each do |x|
|
85
|
+
toPlane1(x, :doublestruck)
|
86
|
+
end
|
87
|
+
m.xpath(".//xmlns:r[xmlns:rPr[not(xmlns:sty) or xmlns:sty/@m:val = 'p']/xmlns:scr[@m:val = 'script']]").each do |x|
|
88
|
+
toPlane1(x, :script)
|
89
|
+
end
|
90
|
+
m.xpath(".//xmlns:r[xmlns:rPr[xmlns:sty/@m:val = 'b']/xmlns:scr[@m:val = 'script']]").each do |x|
|
91
|
+
toPlane1(x, :scriptbold)
|
92
|
+
end
|
93
|
+
m.xpath(".//xmlns:r[xmlns:rPr[not(xmlns:sty) or xmlns:sty/@m:val = 'p']/xmlns:scr[@m:val = 'fraktur']]").each do |x|
|
94
|
+
toPlane1(x, :fraktur)
|
95
|
+
end
|
96
|
+
m.xpath(".//xmlns:r[xmlns:rPr[xmlns:sty/@m:val = 'b']/xmlns:scr[@m:val = 'fraktur']]").each do |x|
|
97
|
+
toPlane1(x, :frakturbold)
|
98
|
+
end
|
99
|
+
m.xpath(".//xmlns:r[xmlns:rPr[not(xmlns:sty) or xmlns:sty/@m:val = 'p']/xmlns:scr[@m:val = 'sans-serif']]").each do |x|
|
100
|
+
toPlane1(x, :sans)
|
101
|
+
end
|
102
|
+
m.xpath(".//xmlns:r[xmlns:rPr[xmlns:sty/@m:val = 'b']/xmlns:scr[@m:val = 'sans-serif']]").each do |x|
|
103
|
+
toPlane1(x, :sansbold)
|
104
|
+
end
|
105
|
+
m.xpath(".//xmlns:r[xmlns:rPr[xmlns:sty/@m:val = 'i']/xmlns:scr[@m:val = 'sans-serif']]").each do |x|
|
106
|
+
toPlane1(x, :sansitalic)
|
107
|
+
end
|
108
|
+
m.xpath(".//xmlns:r[xmlns:rPr[xmlns:sty/@m:val = 'bi']/xmlns:scr[@m:val = 'sans-serif']]").each do |x|
|
109
|
+
toPlane1(x, :sansbolditalic)
|
110
|
+
end
|
111
|
+
m
|
112
|
+
end
|
113
|
+
|
114
|
+
def self.toPlane1(x, font)
|
115
|
+
x.traverse do |n|
|
116
|
+
next unless n.text?
|
117
|
+
n.replace(Plane1Converter.conv(HTMLEntities.new.decode(n.text), font))
|
118
|
+
end
|
119
|
+
x
|
120
|
+
end
|
121
|
+
|
42
122
|
def self.mathml_to_ooml(docxml)
|
43
123
|
docnamespaces = docxml.collect_namespaces
|
44
124
|
m = docxml.xpath("//*[local-name() = 'math']")
|
@@ -48,10 +128,10 @@ module Html2Doc
|
|
48
128
|
element = ooxml_cleanup(x, docnamespaces)
|
49
129
|
doc = Nokogiri::XML::Document::new()
|
50
130
|
doc.root = element
|
51
|
-
ooxml = (esc_space(@xsltemplate.transform(doc))).to_s.
|
131
|
+
ooxml = (unitalic(esc_space(@xsltemplate.transform(doc)))).to_s.
|
52
132
|
gsub(/<\?[^>]+>\s*/, "").
|
53
133
|
gsub(/ xmlns(:[^=]+)?="[^"]+"/, "").
|
54
|
-
gsub(%r{<(/)?([a-z])}, "<\\1m:\\2")
|
134
|
+
gsub(%r{<(/)?(?!span)(?!em)([a-z])}, "<\\1m:\\2")
|
55
135
|
ooxml = uncenter(x, ooxml)
|
56
136
|
x.swap(ooxml)
|
57
137
|
end
|
data/lib/html2doc/mime.rb
CHANGED
@@ -11,7 +11,8 @@ module Html2Doc
|
|
11
11
|
Content-Type: multipart/related; boundary="#{boundary}"
|
12
12
|
|
13
13
|
--#{boundary}
|
14
|
-
Content-
|
14
|
+
Content-ID: <#{File.basename(filename)}>
|
15
|
+
Content-Disposition: inline; filename="#{File.basename(filename)}"
|
15
16
|
Content-Type: text/html; charset="utf-8"
|
16
17
|
|
17
18
|
#{result}
|
@@ -29,7 +30,8 @@ module Html2Doc
|
|
29
30
|
encoded_file = Base64.strict_encode64(content).gsub(/(.{76})/, "\\1\n")
|
30
31
|
<<~"FILE"
|
31
32
|
--#{boundary}
|
32
|
-
Content-
|
33
|
+
Content-ID: <#{File.basename(item)}>
|
34
|
+
Content-Disposition: inline; filename="#{File.basename(item)}"
|
33
35
|
Content-Transfer-Encoding: base64
|
34
36
|
Content-Type: #{content_type}
|
35
37
|
|
@@ -52,15 +54,22 @@ module Html2Doc
|
|
52
54
|
|
53
55
|
def self.mime_package(result, filename, dir)
|
54
56
|
boundary = mime_boundary
|
55
|
-
mhtml = mime_preamble(boundary, filename, result)
|
56
|
-
mhtml += mime_attachment(boundary, filename, "filelist.xml", dir)
|
57
|
+
mhtml = mime_preamble(boundary, "#{filename}.htm", result)
|
58
|
+
mhtml += mime_attachment(boundary, "#{filename}.htm", "filelist.xml", dir)
|
57
59
|
Dir.foreach(dir) do |item|
|
58
60
|
next if item == "." || item == ".." || /^\./.match(item) ||
|
59
61
|
item == "filelist.xml"
|
60
|
-
mhtml += mime_attachment(boundary, filename, item, dir)
|
62
|
+
mhtml += mime_attachment(boundary, "#{filename}.htm", item, dir)
|
61
63
|
end
|
62
64
|
mhtml += "--#{boundary}--"
|
63
|
-
File.open("#{filename}.doc", "w:UTF-8") { |f| f.write mhtml }
|
65
|
+
File.open("#{filename}.doc", "w:UTF-8") { |f| f.write contentid(mhtml) }
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.contentid(mhtml)
|
69
|
+
mhtml.gsub %r{(<img[^>]*?src=")([^\"']+)(['"])}m do |m|
|
70
|
+
repl = "#{$1}cid:#{File.basename($2)}#{$3}"
|
71
|
+
/^data:|^https?:/.match($2) ? m : repl
|
72
|
+
end
|
64
73
|
end
|
65
74
|
|
66
75
|
# max width for Word document is 400, max height is 680
|
@@ -68,7 +77,7 @@ module Html2Doc
|
|
68
77
|
realSize = ImageSize.path(path).size
|
69
78
|
s = [i["width"].to_i, i["height"].to_i]
|
70
79
|
s = realSize if s[0].zero? && s[1].zero?
|
71
|
-
return [nil, nil] if realSize[0].nil? || realSize[1].nil?
|
80
|
+
return [nil, nil] if realSize.nil? || realSize[0].nil? || realSize[1].nil?
|
72
81
|
s[1] = s[0] * realSize[1] / realSize[0] if s[1].zero? && !s[0].zero?
|
73
82
|
s[0] = s[1] * realSize[0] / realSize[1] if s[0].zero? && !s[1].zero?
|
74
83
|
s = [(s[0] * maxheight / s[1]).ceil, maxheight] if s[1] > maxheight
|
@@ -92,7 +101,7 @@ module Html2Doc
|
|
92
101
|
next unless i.element? && %w(img v:imagedata).include?(i.name)
|
93
102
|
#warnsvg(i["src"])
|
94
103
|
next if /^http/.match i["src"]
|
95
|
-
next if %r{^data:image/[^;]+;base64}.match i["src"]
|
104
|
+
next if %r{^data:(image|application)/[^;]+;base64}.match i["src"]
|
96
105
|
local_filename = %r{^([A-Z]:)?/}.match(i["src"]) ? i["src"] :
|
97
106
|
File.join(localdir, i["src"])
|
98
107
|
new_filename = "#{mkuuid}#{File.extname(i["src"])}"
|
@@ -113,14 +122,14 @@ module Html2Doc
|
|
113
122
|
|
114
123
|
def self.header_image_cleanup1(a, dir, filename, localdir)
|
115
124
|
if a.size == 2 && !(/ src="https?:/.match a[1]) &&
|
116
|
-
!(%r{ src="data:image/[^;]+;base64}.match a[1])
|
125
|
+
!(%r{ src="data:(image|application)/[^;]+;base64}.match a[1])
|
117
126
|
m = / src=['"](?<src>[^"']+)['"]/.match a[1]
|
118
127
|
#warnsvg(m[:src])
|
119
128
|
m2 = /\.(?<suffix>[a-zA-Z_0-9]+)$/.match m[:src]
|
120
129
|
new_filename = "#{mkuuid}.#{m2[:suffix]}"
|
121
130
|
old_filename = %r{^([A-Z]:)?/}.match(m[:src]) ? m[:src] : File.join(localdir, m[:src])
|
122
131
|
FileUtils.cp old_filename, File.join(dir, new_filename)
|
123
|
-
a[1].sub!(%r{ src=['"](?<src>[^"']+)['"]}, " src='
|
132
|
+
a[1].sub!(%r{ src=['"](?<src>[^"']+)['"]}, " src='cid:#{new_filename}'")
|
124
133
|
end
|
125
134
|
a.join
|
126
135
|
end
|
data/lib/html2doc/mml2omml.xsl
CHANGED
@@ -878,9 +878,21 @@
|
|
878
878
|
</xsl:otherwise>
|
879
879
|
</xsl:choose>
|
880
880
|
</xsl:if>
|
881
|
-
|
881
|
+
</xsl:variable>
|
882
|
+
<!-- NN 20200831 https://github.com/metanorma/metanorma-nist/issues/155 Read in ancestor mstyle -->
|
883
|
+
<xsl:variable name="mathvariant2">
|
884
|
+
<xsl:choose>
|
885
|
+
<xsl:when test="$mathvariant=''">
|
886
|
+
<xsl:value-of select="$ndCur/ancestor::mml:mstyle[@mathvariant][1]/@mathvariant"/>
|
887
|
+
</xsl:when>
|
888
|
+
<xsl:otherwise>
|
889
|
+
<xsl:value-of select="$mathvariant"/>
|
890
|
+
</xsl:otherwise>
|
891
|
+
</xsl:choose>
|
892
|
+
</xsl:variable>
|
893
|
+
<!-- END NN -->
|
882
894
|
<xsl:call-template name="CreateMathRPR">
|
883
|
-
<xsl:with-param name="mathvariant" select="$
|
895
|
+
<xsl:with-param name="mathvariant" select="$mathvariant2"/>
|
884
896
|
<xsl:with-param name="fontstyle" select="$fontstyle"/>
|
885
897
|
<xsl:with-param name="fontweight" select="$fontweight"/>
|
886
898
|
<xsl:with-param name="ndCur" select="$ndCur"/>
|
@@ -905,7 +917,7 @@
|
|
905
917
|
<xsl:with-param name="fontweight" select="$fontweight"/>
|
906
918
|
<xsl:with-param name="ndCur" select="$ndCur"/>
|
907
919
|
</xsl:call-template>
|
908
|
-
|
920
|
+
</xsl:variable>
|
909
921
|
<xsl:if test="$fLit=1 or $fNor=1 or ($sFontCur!='italic' and $sFontCur!='')">
|
910
922
|
<rPr>
|
911
923
|
<xsl:if test="$fNor=1">
|
@@ -919,7 +931,7 @@
|
|
919
931
|
<xsl:with-param name="fNor" select="$fNor"/>
|
920
932
|
</xsl:call-template>
|
921
933
|
</rPr>
|
922
|
-
|
934
|
+
</xsl:if>
|
923
935
|
</xsl:template>
|
924
936
|
|
925
937
|
<!-- %%Template: GetFontCur
|
@@ -935,8 +947,10 @@
|
|
935
947
|
</xsl:when>
|
936
948
|
<xsl:when test="not($ndCur)">
|
937
949
|
<xsl:value-of select="'italic'"/>
|
938
|
-
|
939
|
-
|
950
|
+
</xsl:when>
|
951
|
+
<!--<xsl:when test="$ndCur/self::mml:mi and (string-length(normalize-space($ndCur)) <= 1) or $ndCur/self::mml:mn and string(number($ndCur/text()))!='NaN' or $ndCur/self::mml:mo">-->
|
952
|
+
<!-- https://github.com/metanorma/metanorma-nist/issues/155 : DO NOT italicise mml:mo -->
|
953
|
+
<xsl:when test="$ndCur/self::mml:mi and (string-length(normalize-space($ndCur)) <= 1) or $ndCur/self::mml:mn and string(number($ndCur/text()))!='NaN'">
|
940
954
|
|
941
955
|
<!-- The default for the above three cases is fontstyle=italic fontweight=normal.-->
|
942
956
|
<xsl:choose>
|
@@ -1000,6 +1014,12 @@
|
|
1000
1014
|
</sty>
|
1001
1015
|
</xsl:when>
|
1002
1016
|
<xsl:when test="$font='italic'">
|
1017
|
+
<!-- NN 20200901 https://github.com/metanorma/metanorma-itu/issues/173 italic needs to be added explicitly to mtext -->
|
1018
|
+
<xsl:if test="$fNor=1">
|
1019
|
+
<sty>
|
1020
|
+
<xsl:attribute name="m:val">i</xsl:attribute>
|
1021
|
+
</sty>
|
1022
|
+
</xsl:if>
|
1003
1023
|
</xsl:when>
|
1004
1024
|
<xsl:when test="$font='script'">
|
1005
1025
|
<scr>
|
@@ -1067,8 +1087,16 @@
|
|
1067
1087
|
<xsl:attribute name="m:val">bi</xsl:attribute>
|
1068
1088
|
</sty>
|
1069
1089
|
</xsl:when>
|
1070
|
-
<xsl:when test="$font='monospace'"
|
1090
|
+
<xsl:when test="$font='monospace'">
|
1071
1091
|
<!-- We can't do monospace, so leave empty -->
|
1092
|
+
<!-- NN 2020 https://github.com/metanorma/html2doc/issues/47 no, we will -->
|
1093
|
+
<scr>
|
1094
|
+
<xsl:attribute name="m:val">monospace</xsl:attribute>
|
1095
|
+
</scr>
|
1096
|
+
<sty>
|
1097
|
+
<xsl:attribute name="m:val">p</xsl:attribute>
|
1098
|
+
</sty>
|
1099
|
+
</xsl:when>
|
1072
1100
|
<xsl:when test="$font='bold'">
|
1073
1101
|
<sty>
|
1074
1102
|
<xsl:attribute name="m:val">b</xsl:attribute>
|