html2doc 1.0.6 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Html2Doc
2
- VERSION = "1.0.6".freeze
2
+ VERSION = "1.1.2".freeze
3
3
  end
@@ -1,270 +1,276 @@
1
1
  require "base64"
2
2
 
3
- def html_input(x)
3
+ def html_input(xml)
4
4
  <<~HTML
5
- <html><head><title>blank</title>
6
- <meta name="Originator" content="Me"/>
7
- </head>
8
- <body>
9
- #{x}
10
- </body></html>
5
+ <html><head><title>blank</title>
6
+ <meta name="Originator" content="Me"/>
7
+ </head>
8
+ <body>
9
+ #{xml}
10
+ </body></html>
11
11
  HTML
12
12
  end
13
13
 
14
- def html_input_no_title(x)
14
+ def html_input_no_title(xml)
15
15
  <<~HTML
16
- <html><head>
17
- <meta name="Originator" content="Me"/>
18
- </head>
19
- <body>
20
- #{x}
21
- </body></html>
16
+ <html><head>
17
+ <meta name="Originator" content="Me"/>
18
+ </head>
19
+ <body>
20
+ #{xml}
21
+ </body></html>
22
22
  HTML
23
23
  end
24
24
 
25
- def html_input_empty_head(x)
25
+ def html_input_empty_head(xml)
26
26
  <<~HTML
27
- <html><head></head>
28
- <body>
29
- #{x}
30
- </body></html>
27
+ <html><head></head>
28
+ <body>
29
+ #{xml}
30
+ </body></html>
31
31
  HTML
32
32
  end
33
33
 
34
- WORD_HDR = <<~HDR
35
- MIME-Version: 1.0
36
- Content-Type: multipart/related; boundary="----=_NextPart_"
37
-
38
- ------=_NextPart_
39
- Content-Location: file:///C:/Doc/test.htm
40
- Content-Type: text/html; charset="utf-8"
41
-
42
- <?xml version="1.0"?>
43
- <html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]>
44
- <xml>
45
- <w:WordDocument>
46
- <w:View>Print</w:View>
47
- <w:Zoom>100</w:Zoom>
48
- <w:DoNotOptimizeForBrowser/>
49
- </w:WordDocument>
50
- </xml>
51
- <![endif]-->
52
- <meta http-equiv=Content-Type content="text/html; charset=utf-8"/>
53
-
54
- <link rel=File-List href="test_files/filelist.xml"/>
55
- <title>blank</title><style><![CDATA[
56
- <!--
34
+ WORD_HDR = <<~HDR.freeze
35
+ MIME-Version: 1.0
36
+ Content-Type: multipart/related; boundary="----=_NextPart_"
37
+
38
+ ------=_NextPart_
39
+ Content-ID: <test.htm>
40
+ Content-Disposition: inline; filename="test.htm"
41
+ Content-Type: text/html; charset="utf-8"
42
+
43
+ <?xml version="1.0"?>
44
+ <html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]>
45
+ <xml>
46
+ <w:WordDocument>
47
+ <w:View>Print</w:View>
48
+ <w:Zoom>100</w:Zoom>
49
+ <w:DoNotOptimizeForBrowser/>
50
+ </w:WordDocument>
51
+ </xml>
52
+ <![endif]-->
53
+ <meta http-equiv=Content-Type content="text/html; charset=utf-8"/>
54
+
55
+ <link rel=File-List href="cid:filelist.xml"/>
56
+ <title>blank</title><style><![CDATA[
57
+ <!--
57
58
  HDR
58
59
 
59
- WORD_HDR_END = <<~HDR
60
- -->
61
- ]]></style>
62
- <meta name="Originator" content="Me"/>
63
- </head>
60
+ WORD_HDR_END = <<~HDR.freeze
61
+ -->
62
+ ]]></style>
63
+ <meta name="Originator" content="Me"/>
64
+ </head>
64
65
  HDR
65
66
 
66
- def word_body(x, fn)
67
+ def word_body(xml, footnote)
67
68
  <<~BODY
68
- <body>
69
- #{x}
70
- #{fn}</body></html>
69
+ <body>
70
+ #{xml}
71
+ #{footnote}</body></html>
71
72
  BODY
72
73
  end
73
74
 
74
- WORD_FTR1 = <<~FTR
75
+ WORD_FTR1 = <<~FTR.freeze
75
76
  ------=_NextPart_
76
- Content-Location: file:///C:/Doc/test_files/filelist.xml
77
- Content-Transfer-Encoding: base64
78
- Content-Type: #{Html2Doc::mime_type('filelist.xml')}
77
+ Content-ID: <filelist.xml>
78
+ Content-Disposition: inline; filename="filelist.xml"
79
+ Content-Transfer-Encoding: base64
80
+ Content-Type: #{Html2Doc::mime_type('filelist.xml')}
79
81
 
80
- PHhtbCB4bWxuczpvPSJ1cm46c2NoZW1hcy1taWNyb3NvZnQtY29tOm9mZmljZTpvZmZpY2UiPgog
81
- ICAgICAgIDxvOk1haW5GaWxlIEhSZWY9Ii4uL3Rlc3QuaHRtIi8+ICA8bzpGaWxlIEhSZWY9ImZp
82
- bGVsaXN0LnhtbCIvPgo8L3htbD4K
82
+ PHhtbCB4bWxuczpvPSJ1cm46c2NoZW1hcy1taWNyb3NvZnQtY29tOm9mZmljZTpvZmZpY2UiPgog
83
+ ICAgICAgIDxvOk1haW5GaWxlIEhSZWY9Ii4uL3Rlc3QuaHRtIi8+ICA8bzpGaWxlIEhSZWY9ImZp
84
+ bGVsaXN0LnhtbCIvPgo8L3htbD4K
83
85
 
84
- ------=_NextPart_--
86
+ ------=_NextPart_--
85
87
  FTR
86
88
 
87
- WORD_FTR2 = <<~FTR
89
+ WORD_FTR2 = <<~FTR.freeze
90
+ ------=_NextPart_
91
+ Content-ID: <filelist.xml>
92
+ Content-Disposition: inline; filename="filelist.xml"
93
+ Content-Transfer-Encoding: base64
94
+ Content-Type: #{Html2Doc::mime_type('filelist.xml')}
95
+ PHhtbCB4bWxuczpvPSJ1cm46c2NoZW1hcy1taWNyb3NvZnQtY29tOm9mZmljZTpvZmZpY2UiPgog
96
+ ICAgICAgIDxvOk1haW5GaWxlIEhSZWY9Ii4uL3Rlc3QuaHRtIi8+ICA8bzpGaWxlIEhSZWY9ImZp
97
+ bGVsaXN0LnhtbCIvPgogIDxvOkZpbGUgSFJlZj0iaGVhZGVyLmh0bWwiLz4KPC94bWw+Cg==
88
98
  ------=_NextPart_
89
- Content-Location: file:///C:/Doc/test_files/filelist.xml
90
- Content-Transfer-Encoding: base64
91
- Content-Type: #{Html2Doc::mime_type('filelist.xml')}
92
- PHhtbCB4bWxuczpvPSJ1cm46c2NoZW1hcy1taWNyb3NvZnQtY29tOm9mZmljZTpvZmZpY2UiPgog
93
- ICAgICAgIDxvOk1haW5GaWxlIEhSZWY9Ii4uL3Rlc3QuaHRtIi8+ICA8bzpGaWxlIEhSZWY9ImZp
94
- bGVsaXN0LnhtbCIvPgogIDxvOkZpbGUgSFJlZj0iaGVhZGVyLmh0bWwiLz4KPC94bWw+Cg==
95
- ------=_NextPart_
96
99
  FTR
97
100
 
98
- WORD_FTR3 = <<~FTR
99
- ------=_NextPart_
100
- Content-Location: file:///C:/Doc/test_files/filelist.xml
101
- Content-Transfer-Encoding: base64
102
- Content-Type: #{Html2Doc::mime_type('filelist.xml')}
103
-
104
- PHhtbCB4bWxuczpvPSJ1cm46c2NoZW1hcy1taWNyb3NvZnQtY29tOm9mZmljZTpvZmZpY2UiPgog
105
- ICAgICAgIDxvOk1haW5GaWxlIEhSZWY9Ii4uL3Rlc3QuaHRtIi8+ICA8bzpGaWxlIEhSZWY9IjFh
106
- YzIwNjVmLTAzZjAtNGM3YS1iOWE2LTkyZTgyMDU5MWJmMC5wbmciLz4KICA8bzpGaWxlIEhSZWY9
107
- ImZpbGVsaXN0LnhtbCIvPgo8L3htbD4K
108
- ------=_NextPart_
109
- Content-Location: file:///C:/Doc/test_files/cb7b0d19-891e-4634-815a-570d019d454c.png
110
- Content-Transfer-Encoding: base64
111
- Content-Type: image/png
112
- ------=_NextPart_--
101
+ WORD_FTR3 = <<~FTR.freeze
102
+ ------=_NextPart_
103
+ Content-ID: <filelist.xml>
104
+ Content-Disposition: inline; filename="filelist.xml"
105
+ Content-Transfer-Encoding: base64
106
+ Content-Type: #{Html2Doc::mime_type('filelist.xml')}
107
+
108
+ PHhtbCB4bWxuczpvPSJ1cm46c2NoZW1hcy1taWNyb3NvZnQtY29tOm9mZmljZTpvZmZpY2UiPgog
109
+ ICAgICAgIDxvOk1haW5GaWxlIEhSZWY9Ii4uL3Rlc3QuaHRtIi8+ICA8bzpGaWxlIEhSZWY9IjFh
110
+ YzIwNjVmLTAzZjAtNGM3YS1iOWE2LTkyZTgyMDU5MWJmMC5wbmciLz4KICA8bzpGaWxlIEhSZWY9
111
+ ImZpbGVsaXN0LnhtbCIvPgo8L3htbD4K
112
+ ------=_NextPart_
113
+ Content-ID: <cb7b0d19-891e-4634-815a-570d019d454c.png>
114
+ Content-Disposition: inline; filename="cb7b0d19-891e-4634-815a-570d019d454c.png"
115
+ Content-Transfer-Encoding: base64
116
+ Content-Type: image/png
117
+ ------=_NextPart_--
113
118
  FTR
114
119
 
115
- HEADERHTML = <<~FTR
116
- <html xmlns:v="urn:schemas-microsoft-com:vml"
117
- xmlns:o="urn:schemas-microsoft-com:office:office"
118
- xmlns:w="urn:schemas-microsoft-com:office:word"
119
- xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
120
- xmlns:mv="http://macVmlSchemaUri" xmlns="http://www.w3.org/TR/REC-html40">
121
- <head>
122
- <meta name=Title content="">
123
- <meta name=Keywords content="">
124
- <meta http-equiv=Content-Type content="text/html; charset=utf-8">
125
- <meta name=ProgId content=Word.Document>
126
- <meta name=Generator content="Microsoft Word 15">
127
- <meta name=Originator content="Microsoft Word 15">
128
- <link id=Main-File rel=Main-File href="FILENAME.html">
129
- <!--[if gte mso 9]><xml>
130
- <o:shapedefaults v:ext="edit" spidmax="2049"/>
131
- </xml><![endif]-->
132
- </head>
133
- <body lang=EN link=blue vlink="#954F72">
134
- <div style='mso-element:footnote-separator' id=fs>
135
- <p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
136
- normal'><span lang=EN-GB><span style='mso-special-character:footnote-separator'><![if !supportFootnotes]>
137
- <hr align=left size=1 width="33%">
138
- <![endif]></span></span></p>
139
- </div>
140
- <div style='mso-element:footnote-continuation-separator' id=fcs>
141
- <p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
142
- normal'><span lang=EN-GB><span style='mso-special-character:footnote-continuation-separator'><![if !supportFootnotes]>
143
- <hr align=left size=1>
144
- <![endif]></span></span></p>
145
- </div>
146
- <div style='mso-element:endnote-separator' id=es>
147
- <p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
148
- normal'><span lang=EN-GB><span style='mso-special-character:footnote-separator'><![if !supportFootnotes]>
149
- <hr align=left size=1 width="33%">
150
- <![endif]></span></span></p>
151
- </div>
152
- <div style='mso-element:endnote-continuation-separator' id=ecs>
153
- <p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
154
- normal'><span lang=EN-GB><span style='mso-special-character:footnote-continuation-separator'><![if !supportFootnotes]>
155
- <hr align=left size=1>
156
- <![endif]></span></span></p>
157
- </div>
158
- <div style='mso-element:header' id=eh1>
159
- <p class=MsoHeader align=left style='text-align:left;line-height:12.0pt;
160
- mso-line-height-rule:exactly'><span lang=EN-GB>ISO/IEC&#x26;nbsp;CD 17301-1:2016(E)</span></p>
161
- </div>
162
- <div style='mso-element:header' id=h1>
163
- <p class=MsoHeader style='margin-bottom:18.0pt'><span lang=EN-GB
164
- style='font-size:10.0pt;mso-bidi-font-size:11.0pt;font-weight:normal'>&#xa9;
165
- ISO/IEC&#x26;nbsp;2016&#x26;nbsp;&#x2013; All rights reserved</span><span lang=EN-GB
166
- style='font-weight:normal'><o:p></o:p></span></p>
167
- </div>
168
- <div style='mso-element:footer' id=ef1>
169
- <p class=MsoFooter style='margin-top:12.0pt;line-height:12.0pt;mso-line-height-rule:
170
- exactly'><!--[if supportFields]><b style='mso-bidi-font-weight:normal'><span
171
- lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
172
- style='mso-element:field-begin'></span><span
173
- style='mso-spacerun:yes'>&#xa0;</span>PAGE<span style='mso-spacerun:yes'>&#xa0;&#xa0;
174
- </span>\\* MERGEFORMAT <span style='mso-element:field-separator'></span></span></b><![endif]--><b
175
- style='mso-bidi-font-weight:normal'><span lang=EN-GB style='font-size:10.0pt;
176
- mso-bidi-font-size:11.0pt'><span style='mso-no-proof:yes'>2</span></span></b><!--[if supportFields]><b
177
- style='mso-bidi-font-weight:normal'><span lang=EN-GB style='font-size:10.0pt;
178
- mso-bidi-font-size:11.0pt'><span style='mso-element:field-end'></span></span></b><![endif]--><span
179
- lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
180
- style='mso-tab-count:1'>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span>&#xa9;
181
- ISO/IEC&#x26;nbsp;2016&#x26;nbsp;&#x2013; All rights reserved<o:p></o:p></span></p>
182
- </div>
183
- <div style='mso-element:header' id=eh2>
184
- <p class=MsoHeader align=left style='text-align:left;line-height:12.0pt;
185
- mso-line-height-rule:exactly'><span lang=EN-GB>ISO/IEC&#x26;nbsp;CD 17301-1:2016(E)</span></p>
186
- </div>
187
- <div style='mso-element:header' id=h2>
188
- <p class=MsoHeader align=right style='text-align:right;line-height:12.0pt;
189
- mso-line-height-rule:exactly'><span lang=EN-GB>ISO/IEC&#x26;nbsp;CD 17301-1:2016(E)</span></p>
190
- </div>
191
- <div style='mso-element:footer' id=ef2>
192
- <p class=MsoFooter style='line-height:12.0pt;mso-line-height-rule:exactly'><!--[if supportFields]><span
193
- lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
194
- style='mso-element:field-begin'></span><span
195
- style='mso-spacerun:yes'>&#xa0;</span>PAGE<span style='mso-spacerun:yes'>&#xa0;&#xa0;
196
- </span>\\* MERGEFORMAT <span style='mso-element:field-separator'></span></span><![endif]--><span
197
- lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
198
- style='mso-no-proof:yes'>ii</span></span><!--[if supportFields]><span
199
- lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
200
- style='mso-element:field-end'></span></span><![endif]--><span lang=EN-GB
201
- style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span style='mso-tab-count:
202
- 1'>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span>&#xa9;
203
- ISO/IEC&#x26;nbsp;2016&#x26;nbsp;&#x2013; All rights reserved<o:p></o:p></span></p>
204
- </div>
205
- <div style='mso-element:footer' id=f2>
206
- <p class=MsoFooter style='line-height:12.0pt'><span lang=EN-GB
207
- style='font-size:10.0pt;mso-bidi-font-size:11.0pt'>&#xa9; ISO/IEC&#x26;nbsp;2016&#x26;nbsp;&#x2013; All
208
- rights reserved<span style='mso-tab-count:1'>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span></span><!--[if supportFields]><span
209
- lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
210
- style='mso-element:field-begin'></span> PAGE<span style='mso-spacerun:yes'>&#xa0;&#xa0;
211
- </span>\\* MERGEFORMAT <span style='mso-element:field-separator'></span></span><![endif]--><span
212
- lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
213
- style='mso-no-proof:yes'>iii</span></span><!--[if supportFields]><span
214
- lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
215
- style='mso-element:field-end'></span></span><![endif]--><span lang=EN-GB
216
- style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><o:p></o:p></span></p>
217
- </div>
218
- <div style='mso-element:footer' id=ef3>
219
- <p class=MsoFooter style='margin-top:12.0pt;line-height:12.0pt;mso-line-height-rule:
220
- exactly'><!--[if supportFields]><b style='mso-bidi-font-weight:normal'><span
221
- lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
222
- style='mso-element:field-begin'></span><span
223
- style='mso-spacerun:yes'>&#xa0;</span>PAGE<span style='mso-spacerun:yes'>&#xa0;&#xa0;
224
- </span>\\* MERGEFORMAT <span style='mso-element:field-separator'></span></span></b><![endif]--><b
225
- style='mso-bidi-font-weight:normal'><span lang=EN-GB style='font-size:10.0pt;
226
- mso-bidi-font-size:11.0pt'><span style='mso-no-proof:yes'>2</span></span></b><!--[if supportFields]><b
227
- style='mso-bidi-font-weight:normal'><span lang=EN-GB style='font-size:10.0pt;
228
- mso-bidi-font-size:11.0pt'><span style='mso-element:field-end'></span></span></b><![endif]--><span
229
- lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
230
- style='mso-tab-count:1'>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span>&#xa9;
231
- ISO/IEC&#x26;nbsp;2016&#x26;nbsp;&#x2013; All rights reserved<o:p></o:p></span></p>
232
- </div>
233
- <div style='mso-element:footer' id=f3>
234
- <p class=MsoFooter style='line-height:12.0pt'><span lang=EN-GB
235
- style='font-size:10.0pt;mso-bidi-font-size:11.0pt'>&#xa9; ISO/IEC&#x26;nbsp;2016&#x26;nbsp;&#x2013; All
236
- rights reserved<span style='mso-tab-count:1'>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span></span><!--[if supportFields]><b
237
- style='mso-bidi-font-weight:normal'><span lang=EN-GB style='font-size:10.0pt;
238
- mso-bidi-font-size:11.0pt'><span style='mso-element:field-begin'></span>
239
- PAGE<span style='mso-spacerun:yes'>&#xa0;&#xa0; </span>\\* MERGEFORMAT <span
240
- style='mso-element:field-separator'></span></span></b><![endif]--><b
241
- style='mso-bidi-font-weight:normal'><span lang=EN-GB style='font-size:10.0pt;
242
- mso-bidi-font-size:11.0pt'><span style='mso-no-proof:yes'>3</span></span></b><!--[if supportFields]><b
243
- style='mso-bidi-font-weight:normal'><span lang=EN-GB style='font-size:10.0pt;
244
- mso-bidi-font-size:11.0pt'><span style='mso-element:field-end'></span></span></b><![endif]--><span
245
- lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><o:p></o:p></span></p>
246
- </div>
247
- </body>
248
- </html>
120
+ HEADERHTML = <<~FTR.freeze
121
+ <html xmlns:v="urn:schemas-microsoft-com:vml"
122
+ xmlns:o="urn:schemas-microsoft-com:office:office"
123
+ xmlns:w="urn:schemas-microsoft-com:office:word"
124
+ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
125
+ xmlns:mv="http://macVmlSchemaUri" xmlns="http://www.w3.org/TR/REC-html40">
126
+ <head>
127
+ <meta name=Title content="">
128
+ <meta name=Keywords content="">
129
+ <meta http-equiv=Content-Type content="text/html; charset=utf-8">
130
+ <meta name=ProgId content=Word.Document>
131
+ <meta name=Generator content="Microsoft Word 15">
132
+ <meta name=Originator content="Microsoft Word 15">
133
+ <link id=Main-File rel=Main-File href="FILENAME.html">
134
+ <!--[if gte mso 9]><xml>
135
+ <o:shapedefaults v:ext="edit" spidmax="2049"/>
136
+ </xml><![endif]-->
137
+ </head>
138
+ <body lang=EN link=blue vlink="#954F72">
139
+ <div style='mso-element:footnote-separator' id=fs>
140
+ <p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
141
+ normal'><span lang=EN-GB><span style='mso-special-character:footnote-separator'><![if !supportFootnotes]>
142
+ <hr align=left size=1 width="33%">
143
+ <![endif]></span></span></p>
144
+ </div>
145
+ <div style='mso-element:footnote-continuation-separator' id=fcs>
146
+ <p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
147
+ normal'><span lang=EN-GB><span style='mso-special-character:footnote-continuation-separator'><![if !supportFootnotes]>
148
+ <hr align=left size=1>
149
+ <![endif]></span></span></p>
150
+ </div>
151
+ <div style='mso-element:endnote-separator' id=es>
152
+ <p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
153
+ normal'><span lang=EN-GB><span style='mso-special-character:footnote-separator'><![if !supportFootnotes]>
154
+ <hr align=left size=1 width="33%">
155
+ <![endif]></span></span></p>
156
+ </div>
157
+ <div style='mso-element:endnote-continuation-separator' id=ecs>
158
+ <p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:
159
+ normal'><span lang=EN-GB><span style='mso-special-character:footnote-continuation-separator'><![if !supportFootnotes]>
160
+ <hr align=left size=1>
161
+ <![endif]></span></span></p>
162
+ </div>
163
+ <div style='mso-element:header' id=eh1>
164
+ <p class=MsoHeader align=left style='text-align:left;line-height:12.0pt;
165
+ mso-line-height-rule:exactly'><span lang=EN-GB>ISO/IEC&#x26;nbsp;CD 17301-1:2016(E)</span></p>
166
+ </div>
167
+ <div style='mso-element:header' id=h1>
168
+ <p class=MsoHeader style='margin-bottom:18.0pt'><span lang=EN-GB
169
+ style='font-size:10.0pt;mso-bidi-font-size:11.0pt;font-weight:normal'>&#xa9;
170
+ ISO/IEC&#x26;nbsp;2016&#x26;nbsp;&#x2013; All rights reserved</span><span lang=EN-GB
171
+ style='font-weight:normal'><o:p></o:p></span></p>
172
+ </div>
173
+ <div style='mso-element:footer' id=ef1>
174
+ <p class=MsoFooter style='margin-top:12.0pt;line-height:12.0pt;mso-line-height-rule:
175
+ exactly'><!--[if supportFields]><b style='mso-bidi-font-weight:normal'><span
176
+ lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
177
+ style='mso-element:field-begin'></span><span
178
+ style='mso-spacerun:yes'>&#xa0;</span>PAGE<span style='mso-spacerun:yes'>&#xa0;&#xa0;
179
+ </span>\\* MERGEFORMAT <span style='mso-element:field-separator'></span></span></b><![endif]--><b
180
+ style='mso-bidi-font-weight:normal'><span lang=EN-GB style='font-size:10.0pt;
181
+ mso-bidi-font-size:11.0pt'><span style='mso-no-proof:yes'>2</span></span></b><!--[if supportFields]><b
182
+ style='mso-bidi-font-weight:normal'><span lang=EN-GB style='font-size:10.0pt;
183
+ mso-bidi-font-size:11.0pt'><span style='mso-element:field-end'></span></span></b><![endif]--><span
184
+ lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
185
+ style='mso-tab-count:1'>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span>&#xa9;
186
+ ISO/IEC&#x26;nbsp;2016&#x26;nbsp;&#x2013; All rights reserved<o:p></o:p></span></p>
187
+ </div>
188
+ <div style='mso-element:header' id=eh2>
189
+ <p class=MsoHeader align=left style='text-align:left;line-height:12.0pt;
190
+ mso-line-height-rule:exactly'><span lang=EN-GB>ISO/IEC&#x26;nbsp;CD 17301-1:2016(E)</span></p>
191
+ </div>
192
+ <div style='mso-element:header' id=h2>
193
+ <p class=MsoHeader align=right style='text-align:right;line-height:12.0pt;
194
+ mso-line-height-rule:exactly'><span lang=EN-GB>ISO/IEC&#x26;nbsp;CD 17301-1:2016(E)</span></p>
195
+ </div>
196
+ <div style='mso-element:footer' id=ef2>
197
+ <p class=MsoFooter style='line-height:12.0pt;mso-line-height-rule:exactly'><!--[if supportFields]><span
198
+ lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
199
+ style='mso-element:field-begin'></span><span
200
+ style='mso-spacerun:yes'>&#xa0;</span>PAGE<span style='mso-spacerun:yes'>&#xa0;&#xa0;
201
+ </span>\\* MERGEFORMAT <span style='mso-element:field-separator'></span></span><![endif]--><span
202
+ lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
203
+ style='mso-no-proof:yes'>ii</span></span><!--[if supportFields]><span
204
+ lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
205
+ style='mso-element:field-end'></span></span><![endif]--><span lang=EN-GB
206
+ style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span style='mso-tab-count:
207
+ 1'>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span>&#xa9;
208
+ ISO/IEC&#x26;nbsp;2016&#x26;nbsp;&#x2013; All rights reserved<o:p></o:p></span></p>
209
+ </div>
210
+ <div style='mso-element:footer' id=f2>
211
+ <p class=MsoFooter style='line-height:12.0pt'><span lang=EN-GB
212
+ style='font-size:10.0pt;mso-bidi-font-size:11.0pt'>&#xa9; ISO/IEC&#x26;nbsp;2016&#x26;nbsp;&#x2013; All
213
+ rights reserved<span style='mso-tab-count:1'>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span></span><!--[if supportFields]><span
214
+ lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
215
+ style='mso-element:field-begin'></span> PAGE<span style='mso-spacerun:yes'>&#xa0;&#xa0;
216
+ </span>\\* MERGEFORMAT <span style='mso-element:field-separator'></span></span><![endif]--><span
217
+ lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
218
+ style='mso-no-proof:yes'>iii</span></span><!--[if supportFields]><span
219
+ lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
220
+ style='mso-element:field-end'></span></span><![endif]--><span lang=EN-GB
221
+ style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><o:p></o:p></span></p>
222
+ </div>
223
+ <div style='mso-element:footer' id=ef3>
224
+ <p class=MsoFooter style='margin-top:12.0pt;line-height:12.0pt;mso-line-height-rule:
225
+ exactly'><!--[if supportFields]><b style='mso-bidi-font-weight:normal'><span
226
+ lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
227
+ style='mso-element:field-begin'></span><span
228
+ style='mso-spacerun:yes'>&#xa0;</span>PAGE<span style='mso-spacerun:yes'>&#xa0;&#xa0;
229
+ </span>\\* MERGEFORMAT <span style='mso-element:field-separator'></span></span></b><![endif]--><b
230
+ style='mso-bidi-font-weight:normal'><span lang=EN-GB style='font-size:10.0pt;
231
+ mso-bidi-font-size:11.0pt'><span style='mso-no-proof:yes'>2</span></span></b><!--[if supportFields]><b
232
+ style='mso-bidi-font-weight:normal'><span lang=EN-GB style='font-size:10.0pt;
233
+ mso-bidi-font-size:11.0pt'><span style='mso-element:field-end'></span></span></b><![endif]--><span
234
+ lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><span
235
+ style='mso-tab-count:1'>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span>&#xa9;
236
+ ISO/IEC&#x26;nbsp;2016&#x26;nbsp;&#x2013; All rights reserved<o:p></o:p></span></p>
237
+ </div>
238
+ <div style='mso-element:footer' id=f3>
239
+ <p class=MsoFooter style='line-height:12.0pt'><span lang=EN-GB
240
+ style='font-size:10.0pt;mso-bidi-font-size:11.0pt'>&#xa9; ISO/IEC&#x26;nbsp;2016&#x26;nbsp;&#x2013; All
241
+ rights reserved<span style='mso-tab-count:1'>&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0; </span></span><!--[if supportFields]><b
242
+ style='mso-bidi-font-weight:normal'><span lang=EN-GB style='font-size:10.0pt;
243
+ mso-bidi-font-size:11.0pt'><span style='mso-element:field-begin'></span>
244
+ PAGE<span style='mso-spacerun:yes'>&#xa0;&#xa0; </span>\\* MERGEFORMAT <span
245
+ style='mso-element:field-separator'></span></span></b><![endif]--><b
246
+ style='mso-bidi-font-weight:normal'><span lang=EN-GB style='font-size:10.0pt;
247
+ mso-bidi-font-size:11.0pt'><span style='mso-no-proof:yes'>3</span></span></b><!--[if supportFields]><b
248
+ style='mso-bidi-font-weight:normal'><span lang=EN-GB style='font-size:10.0pt;
249
+ mso-bidi-font-size:11.0pt'><span style='mso-element:field-end'></span></span></b><![endif]--><span
250
+ lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><o:p></o:p></span></p>
251
+ </div>
252
+ </body>
253
+ </html>
249
254
  FTR
250
255
 
251
- ASCII_MATH='<m:nary><m:naryPr><m:chr m:val="&#x2211;"></m:chr><m:limLoc m:val="undOvr"></m:limLoc><m:grow m:val="on"></m:grow><m:subHide m:val="off"></m:subHide><m:supHide m:val="off"></m:supHide></m:naryPr><m:sub><m:r><m:t>i=1</m:t></m:r></m:sub><m:sup><m:r><m:t>n</m:t></m:r></m:sup><m:e><m:sSup><m:e><m:r><m:t>i</m:t></m:r></m:e><m:sup><m:r><m:t>3</m:t></m:r></m:sup></m:sSup></m:e></m:nary><m:r><m:t>=</m:t></m:r><m:sSup><m:e><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:f><m:fPr><m:type m:val="bar"></m:type></m:fPr><m:num><m:r><m:t>n</m:t></m:r><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:r><m:t>n+1</m:t></m:r></m:e></m:d></m:num><m:den><m:r><m:t>2</m:t></m:r></m:den></m:f></m:e></m:d></m:e><m:sup><m:r><m:t>2</m:t></m:r></m:sup></m:sSup>'
256
+ ASCII_MATH = '<m:nary><m:naryPr><m:chr m:val="&#x2211;"></m:chr><m:limLoc m:val="undOvr"></m:limLoc><m:grow m:val="on"></m:grow><m:subHide m:val="off"></m:subHide><m:supHide m:val="off"></m:supHide></m:naryPr><m:sub><m:r><m:t>i=1</m:t></m:r></m:sub><m:sup><m:r><m:t>n</m:t></m:r></m:sup><m:e><m:sSup><m:e><m:r><m:t>i</m:t></m:r></m:e><m:sup><m:r><m:t>3</m:t></m:r></m:sup></m:sSup></m:e></m:nary><m:r><m:t>=</m:t></m:r><m:sSup><m:e><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:f><m:fPr><m:type m:val="bar"></m:type></m:fPr><m:num><m:r><m:t>n</m:t></m:r><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:r><m:t>n+1</m:t></m:r></m:e></m:d></m:num><m:den><m:r><m:t>2</m:t></m:r></m:den></m:f></m:e></m:d></m:e><m:sup><m:r><m:t>2</m:t></m:r></m:sup></m:sSup>'.freeze
252
257
 
253
- DEFAULT_STYLESHEET = File.read("lib/html2doc/wordstyle.css", encoding: "utf-8").freeze
258
+ DEFAULT_STYLESHEET = File.read("lib/html2doc/wordstyle.css",
259
+ encoding: "utf-8").freeze
254
260
 
255
- def guid_clean(x)
256
- x.gsub(/NextPart_[0-9a-f.]+/, "NextPart_")
261
+ def guid_clean(xml)
262
+ xml.gsub(/NextPart_[0-9a-f.]+/, "NextPart_")
257
263
  end
258
264
 
259
- def image_clean(x)
260
- x.gsub(%r{[0-9a-f-]+\.png}, "image.png").
261
- gsub(%r{[0-9a-f-]+\.gif}, "image.gif").
262
- gsub(%r{[0-9a-f-]+\.(jpeg|jpg)}, "image.jpg").
263
- gsub(%r{------=_NextPart_\s+Content-Location: file:///C:/Doc/test_files/image\.(png|gif).*?\s-----=_NextPart_}m, "------=_NextPart_").
264
- gsub(%r{Content-Type: image/(png|gif|jpeg)[^-]*------=_NextPart_-?-?}m, "").
265
- gsub(%r{ICAgICAg[^-]*-----}m, "-----").
266
- gsub(%r{\s*</img>\s*}m, "</img>").
267
- gsub(%r{</body>\s*</html>}m, "</body></html>")
265
+ def image_clean(xml)
266
+ xml.gsub(%r{[0-9a-f-]+\.png}, "image.png")
267
+ .gsub(%r{[0-9a-f-]+\.gif}, "image.gif")
268
+ .gsub(%r{[0-9a-f-]+\.(jpeg|jpg)}, "image.jpg")
269
+ .gsub(%r{------=_NextPart_\s+Content-Location: file:///C:/Doc/test_files/image\.(png|gif).*?\s-----=_NextPart_}m, "------=_NextPart_")
270
+ .gsub(%r{Content-Type: image/(png|gif|jpeg)[^-]*------=_NextPart_-?-?}m, "")
271
+ .gsub(%r{ICAgICAg[^-]*-----}m, "-----")
272
+ .gsub(%r{\s*</img>\s*}m, "</img>")
273
+ .gsub(%r{</body>\s*</html>}m, "</body></html>")
268
274
  end
269
275
 
270
276
  RSpec.describe Html2Doc do
@@ -274,11 +280,11 @@ RSpec.describe Html2Doc do
274
280
 
275
281
  it "processes a blank document" do
276
282
  Html2Doc.process(html_input(""), filename: "test")
277
- expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
278
- to match_fuzzy(<<~OUTPUT)
279
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
280
- #{word_body("", '<div style="mso-element:footnote-list"/>')} #{WORD_FTR1}
281
- OUTPUT
283
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8")))
284
+ .to match_fuzzy(<<~OUTPUT)
285
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
286
+ #{word_body('', '<div style="mso-element:footnote-list"/>')} #{WORD_FTR1}
287
+ OUTPUT
282
288
  end
283
289
 
284
290
  it "removes any temp files" do
@@ -290,206 +296,243 @@ RSpec.describe Html2Doc do
290
296
  end
291
297
 
292
298
  it "processes a stylesheet in an HTML document with a title" do
293
- Html2Doc.process(html_input(""), filename: "test", stylesheet: "lib/html2doc/wordstyle.css")
294
- expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
295
- to match_fuzzy(<<~OUTPUT)
296
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
297
- #{word_body("", '<div style="mso-element:footnote-list"/>')} #{WORD_FTR1}
298
- OUTPUT
299
+ Html2Doc.process(html_input(""),
300
+ filename: "test", stylesheet: "lib/html2doc/wordstyle.css")
301
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8")))
302
+ .to match_fuzzy(<<~OUTPUT)
303
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
304
+ #{word_body('', '<div style="mso-element:footnote-list"/>')} #{WORD_FTR1}
305
+ OUTPUT
299
306
  end
300
307
 
301
308
  it "processes a stylesheet in an HTML document without a title" do
302
- Html2Doc.process(html_input_no_title(""), filename: "test", stylesheet: "lib/html2doc/wordstyle.css")
303
- expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
304
- to match_fuzzy(<<~OUTPUT)
305
- #{WORD_HDR.sub("<title>blank</title>", "")}
306
- #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
307
- #{word_body("", '<div style="mso-element:footnote-list"/>')} #{WORD_FTR1}
308
- OUTPUT
309
+ Html2Doc.process(html_input_no_title(""),
310
+ filename: "test", stylesheet: "lib/html2doc/wordstyle.css")
311
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8")))
312
+ .to match_fuzzy(<<~OUTPUT)
313
+ #{WORD_HDR.sub('<title>blank</title>', '')}
314
+ #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
315
+ #{word_body('', '<div style="mso-element:footnote-list"/>')} #{WORD_FTR1}
316
+ OUTPUT
309
317
  end
310
318
 
311
319
  it "processes a stylesheet in an HTML document with an empty head" do
312
- Html2Doc.process(html_input_empty_head(""), filename: "test", stylesheet: "lib/html2doc/wordstyle.css")
313
- expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
314
- to match_fuzzy(<<~OUTPUT)
315
- #{WORD_HDR.sub("<title>blank</title>", "")}
316
- #{DEFAULT_STYLESHEET}
317
- #{WORD_HDR_END.sub('<meta name="Originator" content="Me"/>'+"\n", "").sub("</style>\n</head>", "</style></head>")}
318
- #{word_body("", '<div style="mso-element:footnote-list"/>')} #{WORD_FTR1}
319
- OUTPUT
320
+ Html2Doc.process(html_input_empty_head(""),
321
+ filename: "test", stylesheet: "lib/html2doc/wordstyle.css")
322
+ word_hdr_end = WORD_HDR_END
323
+ .sub(%(<meta name="Originator" content="Me"/>\n), "")
324
+ .sub("</style>\n</head>", "</style></head>")
325
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8")))
326
+ .to match_fuzzy(<<~OUTPUT)
327
+ #{WORD_HDR.sub('<title>blank</title>', '')}
328
+ #{DEFAULT_STYLESHEET}
329
+ #{word_hdr_end}
330
+ #{word_body('', '<div style="mso-element:footnote-list"/>')} #{WORD_FTR1}
331
+ OUTPUT
320
332
  end
321
333
 
322
334
  it "processes a header" do
323
- Html2Doc.process(html_input(""), filename: "test", header_file: "spec/header.html")
335
+ Html2Doc.process(html_input(""),
336
+ filename: "test", header_file: "spec/header.html")
324
337
  html = guid_clean(File.read("test.doc", encoding: "utf-8"))
325
- hdr = Base64.decode64(html.sub(%r{^.*Content-Location: file:///C:/Doc/test_files/header.html}, "").
326
- sub(%r{^.*Content-Type: text/html charset="utf-8"}m, "").
327
- sub(%r{------=_NextPart_--.*$}m, "")).force_encoding("UTF-8")
328
- #expect(hdr.gsub(/\xa0/, " ")).to match_fuzzy(HEADERHTML)
329
- expect(HTMLEntities.new.encode(hdr, :hexadecimal).
330
- gsub(/\&#x3c;/, "<").gsub(/\&#x3e;/, ">").gsub(/\&#x27;/, "'").gsub(/\&#x22;/, '"').
331
- gsub(/\&#xd;/, "&#xa;").gsub(/\&#xa;/, "\n")).to match_fuzzy(HEADERHTML)
332
- expect(html.sub(%r{Content-Location: file:///C:/Doc/test_files/header.html.*$}m, "")).
333
- to match_fuzzy(<<~OUTPUT)
334
- #{WORD_HDR} #{DEFAULT_STYLESHEET.gsub(/FILENAME/, "test")}
335
- #{WORD_HDR_END} #{word_body("", '<div style="mso-element:footnote-list"/>')} #{WORD_FTR2}
336
- OUTPUT
338
+ hdr = Base64.decode64(
339
+ html
340
+ .sub(%r{^.*Content-Location: file:///C:/Doc/test_files/header.html}, "")
341
+ .sub(%r{^.*Content-Type: text/html charset="utf-8"}m, "")
342
+ .sub(%r{------=_NextPart_--.*$}m, ""),
343
+ ).force_encoding("UTF-8")
344
+ # expect(hdr.gsub(/\xa0/, " ")).to match_fuzzy(HEADERHTML)
345
+ expect(HTMLEntities.new.encode(hdr, :hexadecimal)
346
+ .gsub(/&#x3c;/, "<").gsub(/&#x3e;/, ">")
347
+ .gsub(/&#x27;/, "'").gsub(/&#x22;/, '"')
348
+ .gsub(/&#xd;/, "&#xa;").gsub(/&#xa;/, "\n"))
349
+ .to match_fuzzy(HEADERHTML)
350
+ expect(html.sub(%r{Content-ID: <header.html>.*$}m, ""))
351
+ .to match_fuzzy(<<~OUTPUT)
352
+ #{WORD_HDR} #{DEFAULT_STYLESHEET.gsub(/url\("[^"]+"\)/, 'url(cid:header.html)')}
353
+ #{WORD_HDR_END} #{word_body('', '<div style="mso-element:footnote-list"/>')} #{WORD_FTR2}
354
+ OUTPUT
337
355
  end
338
356
 
339
357
  it "processes a header with an image" do
340
- Html2Doc.process(html_input(""), filename: "test", header_file: "spec/header_img.html")
358
+ Html2Doc.process(html_input(""),
359
+ filename: "test", header_file: "spec/header_img.html")
341
360
  doc = guid_clean(File.read("test.doc", encoding: "utf-8"))
342
361
  expect(doc).to match(%r{Content-Type: image/png})
343
- expect(doc).to match(%r{file:///C:/Doc/test_files/[^.]+\.png})
362
+ expect(doc).to match(%r{iVBORw0KGgoAAAANSUhEUgAAA5cAAAN7CAYAAADRE24cAAAgAElEQVR4XuydB5gUxdaGC65gTogB})
344
363
  end
345
364
 
346
365
  it "processes a header with an image with absolute path" do
347
366
  doc = File.read("spec/header_img.html", encoding: "utf-8")
348
367
  File.open("spec/header_img1.html", "w:UTF-8") do |f|
349
- f.write doc.sub(%r{spec/19160-6.png}, File.expand_path(File.join(File.dirname(__FILE__), "19160-6.png")))
368
+ f.write(
369
+ doc.sub(%r{spec/19160-6.png},
370
+ File.expand_path(File.join(File.dirname(__FILE__), "19160-6.png"))),
371
+ )
350
372
  end
351
- Html2Doc.process(html_input(""), filename: "test", header_file: "spec/header_img1.html")
373
+ Html2Doc.process(html_input(""),
374
+ filename: "test", header_file: "spec/header_img1.html")
352
375
  doc = guid_clean(File.read("test.doc", encoding: "utf-8"))
353
376
  expect(doc).to match(%r{Content-Type: image/png})
354
- expect(doc).to match(%r{file:///C:/Doc/test_files/[^.]+\.png})
377
+ expect(doc).to match(%r{iVBORw0KGgoAAAANSUhEUgAAA5cAAAN7CAYAAADRE24cAAAgAElEQVR4XuydB5gUxdaGC65gTogB})
355
378
  end
356
379
 
357
-
358
380
  it "processes a populated document" do
359
381
  simple_body = "<h1>Hello word!</h1>
360
382
  <div>This is a very simple document</div>"
361
383
  Html2Doc.process(html_input(simple_body), filename: "test")
362
- expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
363
- to match_fuzzy(<<~OUTPUT)
364
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
365
- #{word_body(simple_body, '<div style="mso-element:footnote-list"/>')}
366
- #{WORD_FTR1}
367
- OUTPUT
384
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8")))
385
+ .to match_fuzzy(<<~OUTPUT)
386
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
387
+ #{word_body(simple_body, '<div style="mso-element:footnote-list"/>')}
388
+ #{WORD_FTR1}
389
+ OUTPUT
368
390
  end
369
391
 
370
392
  it "processes AsciiMath" do
371
- Html2Doc.process(html_input(%[<div>{{sum_(i=1)^n i^3=((n(n+1))/2)^2 text("integer"))}}</div>]), filename: "test", asciimathdelims: ["{{", "}}"])
372
- expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
373
- to match_fuzzy(<<~OUTPUT)
374
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
375
- #{word_body(%{
376
- <div><m:oMath>
377
- <m:nary><m:naryPr><m:chr m:val="&#x2211;"></m:chr><m:limLoc m:val="undOvr"></m:limLoc><m:grow m:val="on"></m:grow><m:subHide m:val="off"></m:subHide><m:supHide m:val="off"></m:supHide></m:naryPr><m:sub><m:r><m:t>i=1</m:t></m:r></m:sub><m:sup><m:r><m:t>n</m:t></m:r></m:sup><m:e><m:sSup><m:e><m:r><m:t>i</m:t></m:r></m:e><m:sup><m:r><m:t>3</m:t></m:r></m:sup></m:sSup></m:e></m:nary><span style="font-style:normal;"><m:r><m:rPr><m:sty m:val="p"></m:sty></m:rPr><m:t>=</m:t></m:r></span><m:sSup><m:e><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:f><m:fPr><m:type m:val="bar"></m:type></m:fPr><m:num><m:r><m:t>n</m:t></m:r><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:r><m:t>n+1</m:t></m:r></m:e></m:d></m:num><m:den><m:r><m:t>2</m:t></m:r></m:den></m:f></m:e></m:d></m:e><m:sup><m:r><m:t>2</m:t></m:r></m:sup></m:sSup><m:r><m:rPr><m:nor></m:nor></m:rPr><m:t>"integer"</m:t></m:r><span style="font-style:normal;"><m:r><m:rPr><m:sty m:val="p"></m:sty></m:rPr><m:t>)</m:t></m:r></span>
378
- </m:oMath>
379
- </div>}, '<div style="mso-element:footnote-list"/>')}
380
- #{WORD_FTR1}
381
- OUTPUT
382
- end
383
-
384
- it "processes mstyle" do
385
- Html2Doc.process(html_input(%[<div>{{bb (-log_2 (p_u)) bb "BB" bbb "BBB" cc "CC" bcc "BCC" tt "TT" fr "FR" bfr "BFR" sf "SF" bsf "BSFα" sfi "SFI" sfbi "SFBIα" bii "BII" ii "II"}}</div>]), filename: "test", asciimathdelims: ["{{", "}}"])
386
- expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
387
- to match_fuzzy(<<~OUTPUT)
388
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
389
- #{word_body(%{
390
- <div><m:oMath>
391
- <span style="font-style:normal;font-weight:bold;"><m:r><m:rPr><m:sty m:val="b"></m:sty></m:rPr><m:t>&#x2212;</m:t></m:r></span><m:sSub><m:e><span style="font-style:normal;font-weight:bold;"><m:r><m:rPr><m:sty m:val="b"></m:sty></m:rPr><m:t>log</m:t></m:r></span></m:e><m:sub><span style="font-style:normal;font-weight:bold;"><m:r><m:rPr><m:sty m:val="b"></m:sty></m:rPr><m:t>2</m:t></m:r></span></m:sub></m:sSub><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:sSub><m:e><span style="font-style:normal;font-weight:bold;"><m:r><m:rPr><m:sty m:val="b"></m:sty></m:rPr><m:t>p</m:t></m:r></span></m:e><m:sub><span style="font-style:normal;font-weight:bold;"><m:r><m:rPr><m:sty m:val="b"></m:sty></m:rPr><m:t>u</m:t></m:r></span></m:sub></m:sSub></m:e></m:d><span style="font-style:normal;font-weight:bold;"><m:r><m:rPr><m:nor></m:nor><m:sty m:val="b"></m:sty></m:rPr><m:t>BB</m:t></m:r></span><m:r><m:rPr><m:nor></m:nor><m:scr m:val="double-struck"></m:scr><m:sty m:val="p"></m:sty></m:rPr><m:t>&#x1D539;&#x1D539;&#x1D539;</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="script"></m:scr></m:rPr><m:t>&#x1D49E;&#x1D49E;</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="script"></m:scr><m:sty m:val="b"></m:sty></m:rPr><m:t>&#x1D4D1;&#x1D4D2;&#x1D4D2;</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="monospace"></m:scr><m:sty m:val="p"></m:sty></m:rPr><m:t>&#x1D683;&#x1D683;</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="fraktur"></m:scr><m:sty m:val="p"></m:sty></m:rPr><m:t>&#x1D509;&#x211C;</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="fraktur"></m:scr><m:sty m:val="b"></m:sty></m:rPr><m:t>&#x1D56D;&#x1D571;&#x1D57D;</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="sans-serif"></m:scr><m:sty m:val="p"></m:sty></m:rPr><m:t>&#x1D5B2;&#x1D5A5;</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="sans-serif"></m:scr><m:sty m:val="b"></m:sty></m:rPr><m:t>&#x1D5D5;&#x1D5E6;&#x1D5D9;&#x1D770;</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="sans-serif"></m:scr></m:rPr><m:t>&#x1D5B2;&#x1D5A5;&#x1D5A8;</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="sans-serif"></m:scr><m:sty m:val="bi"></m:sty></m:rPr><m:t>&#x1D64E;&#x1D641;&#x1D63D;&#x1D644;&#x1D7AA;</m:t></m:r><span class="nostem" style="font-weight:bold;"><em></em><m:r><m:rPr><m:nor></m:nor><m:sty m:val="bi"></m:sty></m:rPr><m:t>BII</m:t></m:r></span><span class="nostem"><em></em><m:r><m:rPr><m:nor></m:nor><m:sty m:val="i"></m:sty></m:rPr><m:t>II</m:t></m:r></span>
392
- </m:oMath>
393
- </div>}, '<div style="mso-element:footnote-list"/>')}
394
- #{WORD_FTR1}
395
- OUTPUT
393
+ Html2Doc.process(html_input(%[<div>{{sum_(i=1)^n i^3=((n(n+1))/2)^2 text("integer"))}}</div>]),
394
+ filename: "test", asciimathdelims: ["{{", "}}"])
395
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8")))
396
+ .to match_fuzzy(<<~OUTPUT)
397
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
398
+ #{word_body(%{
399
+ <div><m:oMath>
400
+ <m:nary><m:naryPr><m:chr m:val="&#x2211;"></m:chr><m:limLoc m:val="undOvr"></m:limLoc><m:grow m:val="on"></m:grow><m:subHide m:val="off"></m:subHide><m:supHide m:val="off"></m:supHide></m:naryPr><m:sub><m:r><m:t>i=1</m:t></m:r></m:sub><m:sup><m:r><m:t>n</m:t></m:r></m:sup><m:e><m:sSup><m:e><m:r><m:t>i</m:t></m:r></m:e><m:sup><m:r><m:t>3</m:t></m:r></m:sup></m:sSup></m:e></m:nary><span style="font-style:normal;"><m:r><m:rPr><m:sty m:val="p"></m:sty></m:rPr><m:t>=</m:t></m:r></span><m:sSup><m:e><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:f><m:fPr><m:type m:val="bar"></m:type></m:fPr><m:num><m:r><m:t>n</m:t></m:r><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:r><m:t>n+1</m:t></m:r></m:e></m:d></m:num><m:den><m:r><m:t>2</m:t></m:r></m:den></m:f></m:e></m:d></m:e><m:sup><m:r><m:t>2</m:t></m:r></m:sup></m:sSup><m:r><m:rPr><m:nor></m:nor></m:rPr><m:t>"integer"</m:t></m:r><span style="font-style:normal;"><m:r><m:rPr><m:sty m:val="p"></m:sty></m:rPr><m:t>)</m:t></m:r></span>
401
+ </m:oMath>
402
+ </div>}, '<div style="mso-element:footnote-list"/>')}
403
+ #{WORD_FTR1}
404
+ OUTPUT
405
+ end
406
+
407
+ it "processes mstyle" do
408
+ Html2Doc.process(html_input(%[<div>{{bb (-log_2 (p_u)) bb "BB" bbb "BBB" cc "CC" bcc "BCC" tt "TT" fr "FR" bfr "BFR" sf "SF" bsf "BSFα" sfi "SFI" sfbi "SFBIα" bii "BII" ii "II"}}</div>]),
409
+ filename: "test", asciimathdelims: ["{{", "}}"])
410
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8")))
411
+ .to match_fuzzy(<<~OUTPUT)
412
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
413
+ #{word_body(%{
414
+ <div><m:oMath>
415
+ <span style="font-style:normal;font-weight:bold;"><m:r><m:rPr><m:sty m:val="b"></m:sty></m:rPr><m:t>&#x2212;</m:t></m:r></span><m:sSub><m:e><span style="font-style:normal;font-weight:bold;"><m:r><m:rPr><m:sty m:val="b"></m:sty></m:rPr><m:t>log</m:t></m:r></span></m:e><m:sub><span style="font-style:normal;font-weight:bold;"><m:r><m:rPr><m:sty m:val="b"></m:sty></m:rPr><m:t>2</m:t></m:r></span></m:sub></m:sSub><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:sSub><m:e><span style="font-style:normal;font-weight:bold;"><m:r><m:rPr><m:sty m:val="b"></m:sty></m:rPr><m:t>p</m:t></m:r></span></m:e><m:sub><span style="font-style:normal;font-weight:bold;"><m:r><m:rPr><m:sty m:val="b"></m:sty></m:rPr><m:t>u</m:t></m:r></span></m:sub></m:sSub></m:e></m:d><span style="font-style:normal;font-weight:bold;"><m:r><m:rPr><m:nor></m:nor><m:sty m:val="b"></m:sty></m:rPr><m:t>BB</m:t></m:r></span><m:r><m:rPr><m:nor></m:nor><m:scr m:val="double-struck"></m:scr><m:sty m:val="p"></m:sty></m:rPr><m:t>&#x1D539;&#x1D539;&#x1D539;</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="script"></m:scr></m:rPr><m:t>&#x1D49E;&#x1D49E;</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="script"></m:scr><m:sty m:val="b"></m:sty></m:rPr><m:t>&#x1D4D1;&#x1D4D2;&#x1D4D2;</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="monospace"></m:scr><m:sty m:val="p"></m:sty></m:rPr><m:t>&#x1D683;&#x1D683;</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="fraktur"></m:scr><m:sty m:val="p"></m:sty></m:rPr><m:t>&#x1D509;&#x211C;</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="fraktur"></m:scr><m:sty m:val="b"></m:sty></m:rPr><m:t>&#x1D56D;&#x1D571;&#x1D57D;</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="sans-serif"></m:scr><m:sty m:val="p"></m:sty></m:rPr><m:t>&#x1D5B2;&#x1D5A5;</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="sans-serif"></m:scr><m:sty m:val="b"></m:sty></m:rPr><m:t>&#x1D5D5;&#x1D5E6;&#x1D5D9;&#x1D770;</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="sans-serif"></m:scr></m:rPr><m:t>&#x1D5B2;&#x1D5A5;&#x1D5A8;</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="sans-serif"></m:scr><m:sty m:val="bi"></m:sty></m:rPr><m:t>&#x1D64E;&#x1D641;&#x1D63D;&#x1D644;&#x1D7AA;</m:t></m:r><span class="nostem" style="font-weight:bold;"><em></em><m:r><m:rPr><m:nor></m:nor><m:sty m:val="bi"></m:sty></m:rPr><m:t>BII</m:t></m:r></span><span class="nostem"><em></em><m:r><m:rPr><m:nor></m:nor><m:sty m:val="i"></m:sty></m:rPr><m:t>II</m:t></m:r></span>
416
+ </m:oMath>
417
+ </div>}, '<div style="mso-element:footnote-list"/>')}
418
+ #{WORD_FTR1}
419
+ OUTPUT
396
420
  end
397
421
 
398
422
  it "processes spaces in AsciiMath" do
399
- Html2Doc.process(html_input(%[<div>{{text " integer ")}}</div>]), filename: "test", asciimathdelims: ["{{", "}}"])
400
- expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
401
- to match_fuzzy(<<~OUTPUT)
402
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
403
- #{word_body('
404
- <div><m:oMath>
405
- <m:r><m:t>text</m:t></m:r><m:r><m:rPr><m:nor></m:nor></m:rPr><m:t>&#xA0;integer&#xA0;</m:t></m:r><span style="font-style:normal;"><m:r><m:rPr><m:sty m:val="p"></m:sty></m:rPr><m:t>)</m:t></m:r></span>
406
- </m:oMath>
407
- </div>', '<div style="mso-element:footnote-list"/>')}
408
- #{WORD_FTR1}
409
- OUTPUT
423
+ Html2Doc.process(html_input(%[<div>{{text " integer ")}}</div>]),
424
+ filename: "test", asciimathdelims: ["{{", "}}"])
425
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8")))
426
+ .to match_fuzzy(<<~OUTPUT)
427
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
428
+ #{word_body('
429
+ <div><m:oMath>
430
+ <m:r><m:t>text</m:t></m:r><m:r><m:rPr><m:nor></m:nor></m:rPr><m:t>&#xA0;integer&#xA0;</m:t></m:r><span style="font-style:normal;"><m:r><m:rPr><m:sty m:val="p"></m:sty></m:rPr><m:t>)</m:t></m:r></span>
431
+ </m:oMath>
432
+ </div>', '<div style="mso-element:footnote-list"/>')}
433
+ #{WORD_FTR1}
434
+ OUTPUT
410
435
  end
411
436
 
412
437
  it "processes spaces in MathML mtext" do
413
438
  Html2Doc.process(html_input("<div><math xmlns='http://www.w3.org/1998/Math/MathML'>
414
439
  <mrow><mi>H</mi><mtext> original </mtext><mi>J</mi></mrow>
415
- </math></div>"), filename: "test", asciimathdelims: ["{{", "}}"])
416
- expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
417
- to match_fuzzy(<<~OUTPUT)
418
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
419
- #{word_body('<div><m:oMath>
420
- <m:r><m:t>H</m:t></m:r><m:r><m:rPr><m:nor></m:nor></m:rPr><m:t>&#xA0;original&#xA0;</m:t></m:r><m:r><m:t>J</m:t></m:r>
421
- </m:oMath>
422
- </div>', '<div style="mso-element:footnote-list"/>')}
423
- #{WORD_FTR1}
424
- OUTPUT
440
+ </math></div>"),
441
+ filename: "test", asciimathdelims: ["{{", "}}"])
442
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8")))
443
+ .to match_fuzzy(<<~OUTPUT)
444
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
445
+ #{word_body('<div><m:oMath>
446
+ <m:r><m:t>H</m:t></m:r><m:r><m:rPr><m:nor></m:nor></m:rPr><m:t>&#xA0;original&#xA0;</m:t></m:r><m:r><m:t>J</m:t></m:r>
447
+ </m:oMath>
448
+ </div>', '<div style="mso-element:footnote-list"/>')}
449
+ #{WORD_FTR1}
450
+ OUTPUT
425
451
  end
426
452
 
427
453
  it "unwraps accent in MathML" do
428
454
  Html2Doc.process(html_input("<div><math xmlns='http://www.w3.org/1998/Math/MathML'>
429
455
  <mover accent='true'><mrow><mi>p</mi></mrow><mrow><mo>^</mo></mrow></mover>
430
456
  </math></div>"), filename: "test", asciimathdelims: ["{{", "}}"])
431
- expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
432
- to match_fuzzy(<<~OUTPUT)
433
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
434
- #{word_body('<div><m:oMath>
435
- <m:acc><m:accPr><m:chr m:val="^"></m:chr></m:accPr><m:e><m:r><m:t>p</m:t></m:r></m:e></m:acc>
436
- </m:oMath>
437
- </div>', '<div style="mso-element:footnote-list"/>')}
438
- #{WORD_FTR1}
439
- OUTPUT
457
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8")))
458
+ .to match_fuzzy(<<~OUTPUT)
459
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
460
+ #{word_body('<div><m:oMath>
461
+ <m:acc><m:accPr><m:chr m:val="^"></m:chr></m:accPr><m:e><m:r><m:t>p</m:t></m:r></m:e></m:acc>
462
+ </m:oMath>
463
+ </div>', '<div style="mso-element:footnote-list"/>')}
464
+ #{WORD_FTR1}
465
+ OUTPUT
440
466
  end
441
467
 
442
468
  it "left-aligns AsciiMath" do
443
- Html2Doc.process(html_input("<div style='text-align:left;'>{{sum_(i=1)^n i^3=((n(n+1))/2)^2}}</div>"), filename: "test", asciimathdelims: ["{{", "}}"])
444
- expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
445
- to match_fuzzy(<<~OUTPUT)
446
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
447
- #{word_body(%{
448
- <div style="text-align:left;"><m:oMathPara><m:oMathParaPr><m:jc m:val="left"/></m:oMathParaPr><m:oMath>
449
- <m:nary><m:naryPr><m:chr m:val="&#x2211;"></m:chr><m:limLoc m:val="undOvr"></m:limLoc><m:grow m:val="on"></m:grow><m:subHide m:val="off"></m:subHide><m:supHide m:val="off"></m:supHide></m:naryPr><m:sub><m:r><m:t>i=1</m:t></m:r></m:sub><m:sup><m:r><m:t>n</m:t></m:r></m:sup><m:e><m:sSup><m:e><m:r><m:t>i</m:t></m:r></m:e><m:sup><m:r><m:t>3</m:t></m:r></m:sup></m:sSup></m:e></m:nary><span style="font-style:normal;"><m:r><m:rPr><m:sty m:val="p"></m:sty></m:rPr><m:t>=</m:t></m:r></span><m:sSup><m:e><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:f><m:fPr><m:type m:val="bar"></m:type></m:fPr><m:num><m:r><m:t>n</m:t></m:r><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:r><m:t>n+1</m:t></m:r></m:e></m:d></m:num><m:den><m:r><m:t>2</m:t></m:r></m:den></m:f></m:e></m:d></m:e><m:sup><m:r><m:t>2</m:t></m:r></m:sup></m:sSup>
450
- </m:oMath>
451
- </m:oMathPara></div>}, '<div style="mso-element:footnote-list"/>')}
452
- #{WORD_FTR1}
453
- OUTPUT
469
+ Html2Doc.process(html_input("<div style='text-align:left;'>{{sum_(i=1)^n i^3=((n(n+1))/2)^2}}</div>"),
470
+ filename: "test", asciimathdelims: ["{{", "}}"])
471
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8")))
472
+ .to match_fuzzy(<<~OUTPUT)
473
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
474
+ #{word_body(%{
475
+ <div style="text-align:left;"><m:oMathPara><m:oMathParaPr><m:jc m:val="left"/></m:oMathParaPr><m:oMath>
476
+ <m:nary><m:naryPr><m:chr m:val="&#x2211;"></m:chr><m:limLoc m:val="undOvr"></m:limLoc><m:grow m:val="on"></m:grow><m:subHide m:val="off"></m:subHide><m:supHide m:val="off"></m:supHide></m:naryPr><m:sub><m:r><m:t>i=1</m:t></m:r></m:sub><m:sup><m:r><m:t>n</m:t></m:r></m:sup><m:e><m:sSup><m:e><m:r><m:t>i</m:t></m:r></m:e><m:sup><m:r><m:t>3</m:t></m:r></m:sup></m:sSup></m:e></m:nary><span style="font-style:normal;"><m:r><m:rPr><m:sty m:val="p"></m:sty></m:rPr><m:t>=</m:t></m:r></span><m:sSup><m:e><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:f><m:fPr><m:type m:val="bar"></m:type></m:fPr><m:num><m:r><m:t>n</m:t></m:r><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:r><m:t>n+1</m:t></m:r></m:e></m:d></m:num><m:den><m:r><m:t>2</m:t></m:r></m:den></m:f></m:e></m:d></m:e><m:sup><m:r><m:t>2</m:t></m:r></m:sup></m:sSup>
477
+ </m:oMath>
478
+ </m:oMathPara></div>}, '<div style="mso-element:footnote-list"/>')}
479
+ #{WORD_FTR1}
480
+ OUTPUT
454
481
  end
455
482
 
456
483
  it "right-aligns AsciiMath" do
457
- Html2Doc.process(html_input("<div style='text-align:right;'>{{sum_(i=1)^n i^3=((n(n+1))/2)^2}}</div>"), filename: "test", asciimathdelims: ["{{", "}}"])
458
- expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
459
- to match_fuzzy(<<~OUTPUT)
460
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
461
- #{word_body(%{
462
- <div style="text-align:right;"><m:oMathPara><m:oMathParaPr><m:jc m:val="right"/></m:oMathParaPr><m:oMath>
463
- <m:nary><m:naryPr><m:chr m:val="&#x2211;"></m:chr><m:limLoc m:val="undOvr"></m:limLoc><m:grow m:val="on"></m:grow><m:subHide m:val="off"></m:subHide><m:supHide m:val="off"></m:supHide></m:naryPr><m:sub><m:r><m:t>i=1</m:t></m:r></m:sub><m:sup><m:r><m:t>n</m:t></m:r></m:sup><m:e><m:sSup><m:e><m:r><m:t>i</m:t></m:r></m:e><m:sup><m:r><m:t>3</m:t></m:r></m:sup></m:sSup></m:e></m:nary><span style="font-style:normal;"><m:r><m:rPr><m:sty m:val="p"></m:sty></m:rPr><m:t>=</m:t></m:r></span><m:sSup><m:e><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:f><m:fPr><m:type m:val="bar"></m:type></m:fPr><m:num><m:r><m:t>n</m:t></m:r><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:r><m:t>n+1</m:t></m:r></m:e></m:d></m:num><m:den><m:r><m:t>2</m:t></m:r></m:den></m:f></m:e></m:d></m:e><m:sup><m:r><m:t>2</m:t></m:r></m:sup></m:sSup>
464
- </m:oMath>
465
- </m:oMathPara></div>}, '<div style="mso-element:footnote-list"/>')}
466
- #{WORD_FTR1}
467
- OUTPUT
484
+ Html2Doc.process(html_input("<div style='text-align:right;'>{{sum_(i=1)^n i^3=((n(n+1))/2)^2}}</div>"),
485
+ filename: "test", asciimathdelims: ["{{", "}}"])
486
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8")))
487
+ .to match_fuzzy(<<~OUTPUT)
488
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
489
+ #{word_body(%{
490
+ <div style="text-align:right;"><m:oMathPara><m:oMathParaPr><m:jc m:val="right"/></m:oMathParaPr><m:oMath>
491
+ <m:nary><m:naryPr><m:chr m:val="&#x2211;"></m:chr><m:limLoc m:val="undOvr"></m:limLoc><m:grow m:val="on"></m:grow><m:subHide m:val="off"></m:subHide><m:supHide m:val="off"></m:supHide></m:naryPr><m:sub><m:r><m:t>i=1</m:t></m:r></m:sub><m:sup><m:r><m:t>n</m:t></m:r></m:sup><m:e><m:sSup><m:e><m:r><m:t>i</m:t></m:r></m:e><m:sup><m:r><m:t>3</m:t></m:r></m:sup></m:sSup></m:e></m:nary><span style="font-style:normal;"><m:r><m:rPr><m:sty m:val="p"></m:sty></m:rPr><m:t>=</m:t></m:r></span><m:sSup><m:e><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:f><m:fPr><m:type m:val="bar"></m:type></m:fPr><m:num><m:r><m:t>n</m:t></m:r><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:r><m:t>n+1</m:t></m:r></m:e></m:d></m:num><m:den><m:r><m:t>2</m:t></m:r></m:den></m:f></m:e></m:d></m:e><m:sup><m:r><m:t>2</m:t></m:r></m:sup></m:sSup>
492
+ </m:oMath>
493
+ </m:oMathPara></div>}, '<div style="mso-element:footnote-list"/>')}
494
+ #{WORD_FTR1}
495
+ OUTPUT
496
+ end
497
+
498
+ it "raises error in processing of broken AsciiMath" do
499
+ begin
500
+ expect do
501
+ Html2Doc.process(html_input(%[<div style='text-align:right;'>{{u_c = 6.6"unitsml(kHz)}}</div>]),
502
+ filename: "test", asciimathdelims: ["{{", "}}"])
503
+ end.to output('parsing: u_c = 6.6"unitsml(kHz)').to_stderr
504
+ rescue StandardError
505
+ end
506
+ expect do
507
+ Html2Doc.process(html_input(%[<div style='text-align:right;'>{{u_c = 6.6"unitsml(kHz)}}</div>]),
508
+ filename: "test", asciimathdelims: ["{{", "}}"])
509
+ end.to raise_error(StandardError)
468
510
  end
469
511
 
470
512
  it "wraps msup after munderover in MathML" do
471
513
  Html2Doc.process(html_input("<div><math xmlns='http://www.w3.org/1998/Math/MathML'>
472
- <munderover><mo>&#x2211;</mo><mrow><mi>i</mi><mo>=</mo><mn>0</mn></mrow><mrow><mi>n</mi></mrow></munderover><msup><mn>2</mn><mrow><mi>i</mi></mrow></msup></math></div>"), filename: "test", asciimathdelims: ["{{", "}}"])
473
- expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
474
- to match_fuzzy(<<~OUTPUT)
475
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
476
- #{word_body('<div><m:oMath>
477
- <m:nary><m:naryPr><m:chr m:val="&#x2211;"></m:chr><m:limLoc m:val="undOvr"></m:limLoc><m:grow m:val="on"></m:grow><m:subHide m:val="off"></m:subHide><m:supHide m:val="off"></m:supHide></m:naryPr><m:sub><m:r><m:t>i=0</m:t></m:r></m:sub><m:sup><m:r><m:t>n</m:t></m:r></m:sup><m:e><m:sSup><m:e><m:r><m:t>2</m:t></m:r></m:e><m:sup><m:r><m:t>i</m:t></m:r></m:sup></m:sSup></m:e></m:nary></m:oMath>
478
- </div>', '<div style="mso-element:footnote-list"/>')}
479
- #{WORD_FTR1}
480
- OUTPUT
514
+ <munderover><mo>&#x2211;</mo><mrow><mi>i</mi><mo>=</mo><mn>0</mn></mrow><mrow><mi>n</mi></mrow></munderover><msup><mn>2</mn><mrow><mi>i</mi></mrow></msup></math></div>"),
515
+ filename: "test", asciimathdelims: ["{{", "}}"])
516
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8")))
517
+ .to match_fuzzy(<<~OUTPUT)
518
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
519
+ #{word_body('<div><m:oMath>
520
+ <m:nary><m:naryPr><m:chr m:val="&#x2211;"></m:chr><m:limLoc m:val="undOvr"></m:limLoc><m:grow m:val="on"></m:grow><m:subHide m:val="off"></m:subHide><m:supHide m:val="off"></m:supHide></m:naryPr><m:sub><m:r><m:t>i=0</m:t></m:r></m:sub><m:sup><m:r><m:t>n</m:t></m:r></m:sup><m:e><m:sSup><m:e><m:r><m:t>2</m:t></m:r></m:e><m:sup><m:r><m:t>i</m:t></m:r></m:sup></m:sSup></m:e></m:nary></m:oMath>
521
+ </div>', '<div style="mso-element:footnote-list"/>')}
522
+ #{WORD_FTR1}
523
+ OUTPUT
481
524
  end
482
525
 
483
526
  it "processes tabs" do
484
527
  simple_body = "<h1>Hello word!</h1>
485
528
  <div>This is a very &tab; simple document</div>"
486
529
  Html2Doc.process(html_input(simple_body), filename: "test")
487
- expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
488
- to match_fuzzy(<<~OUTPUT)
489
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
490
- #{word_body(simple_body.gsub(/\&tab;/, %[<span style="mso-tab-count:1">&#xA0; </span>]), '<div style="mso-element:footnote-list"/>')}
491
- #{WORD_FTR1}
492
- OUTPUT
530
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8")))
531
+ .to match_fuzzy(<<~OUTPUT)
532
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
533
+ #{word_body(simple_body.gsub(/&tab;/, %[<span style="mso-tab-count:1">&#xA0; </span>]), '<div style="mso-element:footnote-list"/>')}
534
+ #{WORD_FTR1}
535
+ OUTPUT
493
536
  end
494
537
 
495
538
  it "makes unstyled paragraphs be MsoNormal" do
@@ -497,12 +540,12 @@ RSpec.describe Html2Doc do
497
540
  <p>This is a very simple document</p>
498
541
  <p class="x">This style stays</p>'
499
542
  Html2Doc.process(html_input(simple_body), filename: "test")
500
- expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
501
- to match_fuzzy(<<~OUTPUT)
502
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
503
- #{word_body(simple_body.gsub(/<p>/, %[<p class="MsoNormal">]), '<div style="mso-element:footnote-list"/>')}
504
- #{WORD_FTR1}
505
- OUTPUT
543
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8")))
544
+ .to match_fuzzy(<<~OUTPUT)
545
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
546
+ #{word_body(simple_body.gsub(/<p>/, %[<p class="MsoNormal">]), '<div style="mso-element:footnote-list"/>')}
547
+ #{WORD_FTR1}
548
+ OUTPUT
506
549
  end
507
550
 
508
551
  it "makes unstyled list entries be MsoNormal" do
@@ -512,12 +555,12 @@ RSpec.describe Html2Doc do
512
555
  <li class="x">This style stays</li>
513
556
  </ul>'
514
557
  Html2Doc.process(html_input(simple_body), filename: "test")
515
- expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
516
- to match_fuzzy(<<~OUTPUT)
517
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
518
- #{word_body(simple_body.gsub(/<li>/, %[<li class="MsoNormal">]), '<div style="mso-element:footnote-list"/>')}
519
- #{WORD_FTR1}
520
- OUTPUT
558
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8")))
559
+ .to match_fuzzy(<<~OUTPUT)
560
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
561
+ #{word_body(simple_body.gsub(/<li>/, %[<li class="MsoNormal">]), '<div style="mso-element:footnote-list"/>')}
562
+ #{WORD_FTR1}
563
+ OUTPUT
521
564
  end
522
565
 
523
566
  it "resizes images for height, in a file in a subdirectory" do
@@ -526,9 +569,9 @@ RSpec.describe Html2Doc do
526
569
  testdoc = File.read("spec/test.doc", encoding: "utf-8")
527
570
  expect(testdoc).to match(%r{Content-Type: image/png})
528
571
  expect(image_clean(guid_clean(testdoc))).to match_fuzzy(<<~OUTPUT)
529
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
530
- #{image_clean(word_body('<img src="test_files/cb7b0d19-891e-4634-815a-570d019d454c.png" width="400" height="388"></img>', '<div style="mso-element:footnote-list"/>'))}
531
- #{image_clean(WORD_FTR3)}
572
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
573
+ #{image_clean(word_body('<img src="cid:cb7b0d19-891e-4634-815a-570d019d454c.png" width="400" height="388"></img>', '<div style="mso-element:footnote-list"/>'))}
574
+ #{image_clean(WORD_FTR3)}
532
575
  OUTPUT
533
576
  end
534
577
 
@@ -538,9 +581,9 @@ RSpec.describe Html2Doc do
538
581
  testdoc = File.read("test.doc", encoding: "utf-8")
539
582
  expect(testdoc).to match(%r{Content-Type: image/gif})
540
583
  expect(image_clean(guid_clean(testdoc))).to match_fuzzy(<<~OUTPUT)
541
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
542
- #{image_clean(word_body('<img src="test_files/cb7b0d19-891e-4634-815a-570d019d454c.gif" width="400" height="118"></img>', '<div style="mso-element:footnote-list"/>'))}
543
- #{image_clean(WORD_FTR3).gsub(/image\.png/, "image.gif")}
584
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
585
+ #{image_clean(word_body('<img src="cid:cb7b0d19-891e-4634-815a-570d019d454c.gif" width="400" height="118"></img>', '<div style="mso-element:footnote-list"/>'))}
586
+ #{image_clean(WORD_FTR3).gsub(/image\.png/, 'image.gif')}
544
587
  OUTPUT
545
588
  end
546
589
 
@@ -550,41 +593,51 @@ RSpec.describe Html2Doc do
550
593
  testdoc = File.read("test.doc", encoding: "utf-8")
551
594
  expect(testdoc).to match(%r{Content-Type: image/jpeg})
552
595
  expect(image_clean(guid_clean(testdoc))).to match_fuzzy(<<~OUTPUT)
553
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
554
- #{image_clean(word_body('<img src="test_files/cb7b0d19-891e-4634-815a-570d019d454c.jpg" width="208" height="680"></img>', '<div style="mso-element:footnote-list"/>'))}
555
- #{image_clean(WORD_FTR3).gsub(/image\.png/, "image.jpg")}
596
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
597
+ #{image_clean(word_body('<img src="cid:cb7b0d19-891e-4634-815a-570d019d454c.jpg" width="208" height="680"></img>', '<div style="mso-element:footnote-list"/>'))}
598
+ #{image_clean(WORD_FTR3).gsub(/image\.png/, 'image.jpg')}
556
599
  OUTPUT
557
600
  end
558
601
 
559
602
  it "resizes images with missing or auto sizes" do
560
603
  image = { "src" => "spec/19160-8.jpg" }
561
- expect(Html2Doc.image_resize(image, "spec/19160-8.jpg", 100, 100)).to eq [30, 100]
604
+ expect(Html2Doc.image_resize(image, "spec/19160-8.jpg", 100, 100))
605
+ .to eq [30, 100]
562
606
  image["width"] = "20"
563
- expect(Html2Doc.image_resize(image, "spec/19160-8.jpg", 100, 100)).to eq [20, 65]
607
+ expect(Html2Doc.image_resize(image, "spec/19160-8.jpg", 100, 100))
608
+ .to eq [20, 65]
564
609
  image.delete("width")
565
610
  image["height"] = "50"
566
- expect(Html2Doc.image_resize(image, "spec/19160-8.jpg", 100, 100)).to eq [15, 50]
611
+ expect(Html2Doc.image_resize(image, "spec/19160-8.jpg", 100, 100))
612
+ .to eq [15, 50]
567
613
  image.delete("height")
568
614
  image["width"] = "500"
569
- expect(Html2Doc.image_resize(image, "spec/19160-8.jpg", 100, 100)).to eq [30, 100]
615
+ expect(Html2Doc.image_resize(image, "spec/19160-8.jpg", 100, 100))
616
+ .to eq [30, 100]
570
617
  image.delete("width")
571
618
  image["height"] = "500"
572
- expect(Html2Doc.image_resize(image, "spec/19160-8.jpg", 100, 100)).to eq [30, 100]
619
+ expect(Html2Doc.image_resize(image, "spec/19160-8.jpg", 100, 100))
620
+ .to eq [30, 100]
573
621
  image["width"] = "20"
574
622
  image["height"] = "auto"
575
- expect(Html2Doc.image_resize(image, "spec/19160-8.jpg", 100, 100)).to eq [20, 65]
623
+ expect(Html2Doc.image_resize(image, "spec/19160-8.jpg", 100, 100))
624
+ .to eq [20, 65]
576
625
  image["width"] = "auto"
577
626
  image["height"] = "50"
578
- expect(Html2Doc.image_resize(image, "spec/19160-8.jpg", 100, 100)).to eq [15, 50]
627
+ expect(Html2Doc.image_resize(image, "spec/19160-8.jpg", 100, 100))
628
+ .to eq [15, 50]
579
629
  image["width"] = "500"
580
630
  image["height"] = "auto"
581
- expect(Html2Doc.image_resize(image, "spec/19160-8.jpg", 100, 100)).to eq [30, 100]
631
+ expect(Html2Doc.image_resize(image, "spec/19160-8.jpg", 100, 100))
632
+ .to eq [30, 100]
582
633
  image["width"] = "auto"
583
634
  image["height"] = "500"
584
- expect(Html2Doc.image_resize(image, "spec/19160-8.jpg", 100, 100)).to eq [30, 100]
635
+ expect(Html2Doc.image_resize(image, "spec/19160-8.jpg", 100, 100))
636
+ .to eq [30, 100]
585
637
  image["width"] = "auto"
586
638
  image["height"] = "auto"
587
- expect(Html2Doc.image_resize(image, "spec/19160-8.jpg", 100, 100)).to eq [30, 100]
639
+ expect(Html2Doc.image_resize(image, "spec/19160-8.jpg", 100, 100))
640
+ .to eq [30, 100]
588
641
  end
589
642
 
590
643
  it "does not move images if they are external URLs" do
@@ -592,49 +645,48 @@ RSpec.describe Html2Doc do
592
645
  Html2Doc.process(html_input(simple_body), filename: "test")
593
646
  testdoc = File.read("test.doc", encoding: "utf-8")
594
647
  expect(image_clean(guid_clean(testdoc))).to match_fuzzy(<<~OUTPUT)
595
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
596
- #{image_clean(word_body('<img src="https://example.com/19160-6.png"></img>', '<div style="mso-element:footnote-list"/>'))}
597
- #{image_clean(WORD_FTR1)}
648
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
649
+ #{image_clean(word_body('<img src="https://example.com/19160-6.png"></img>', '<div style="mso-element:footnote-list"/>'))}
650
+ #{image_clean(WORD_FTR1)}
598
651
  OUTPUT
599
652
  end
600
653
 
601
654
  it "deals with absolute image locations" do
602
- simple_body = %{<img src="#{File.expand_path(File.dirname(__FILE__))}/19160-6.png">}
655
+ simple_body = %{<img src="#{__dir__}/19160-6.png">}
603
656
  Html2Doc.process(html_input(simple_body), filename: "spec/test")
604
657
  testdoc = File.read("spec/test.doc", encoding: "utf-8")
605
658
  expect(testdoc).to match(%r{Content-Type: image/png})
606
659
  expect(image_clean(guid_clean(testdoc))).to match_fuzzy(<<~OUTPUT)
607
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
608
- #{image_clean(word_body('<img src="test_files/cb7b0d19-891e-4634-815a-570d019d454c.png" width="400" height="388"></img>', '<div style="mso-element:footnote-list"/>'))}
609
- #{image_clean(WORD_FTR3)}
660
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
661
+ #{image_clean(word_body('<img src="cid:cb7b0d19-891e-4634-815a-570d019d454c.png" width="400" height="388"></img>', '<div style="mso-element:footnote-list"/>'))}
662
+ #{image_clean(WORD_FTR3)}
610
663
  OUTPUT
611
664
  end
612
665
 
613
- =begin
614
- it "warns about SVG" do
615
- simple_body = '<img src="https://example.com/19160-6.svg">'
616
- expect{ Html2Doc.process(html_input(simple_body), filename: "test") }.to output("https://example.com/19160-6.svg: SVG not supported\n").to_stderr
617
- end
618
- =end
666
+ # it "warns about SVG" do
667
+ # simple_body = '<img src="https://example.com/19160-6.svg">'
668
+ # expect{ Html2Doc.process(html_input(simple_body), filename: "test") }
669
+ # .to output("https://example.com/19160-6.svg: SVG not supported\n").to_stderr
670
+ # end
619
671
 
620
672
  it "processes epub:type footnotes" do
621
- simple_body = '<div>This is a very simple
673
+ simple_body = '<div>This is a very simple
622
674
  document<a epub:type="footnote" href="#a1">1</a> allegedly<a epub:type="footnote" href="#a2">2</a></div>
623
675
  <aside id="a1">Footnote</aside>
624
676
  <aside id="a2">Other Footnote</aside>'
625
677
  Html2Doc.process(html_input(simple_body), filename: "test")
626
- expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
627
- to match_fuzzy(<<~OUTPUT)
628
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
629
- #{word_body('<div>This is a very simple
630
- document<a epub:type="footnote" href="#_ftn1" style="mso-footnote-id:ftn1" name="_ftnref1" title="" id="_ftnref1"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a> allegedly<a epub:type="footnote" href="#_ftn2" style="mso-footnote-id:ftn2" name="_ftnref2" title="" id="_ftnref2"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a></div>',
631
- '<div style="mso-element:footnote-list"><div style="mso-element:footnote" id="ftn1">
632
- <p id="" class="MsoFootnoteText"><a style="mso-footnote-id:ftn1" href="#_ftn1" name="_ftnref1" title="" id="_ftnref1"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a>Footnote</p></div>
633
- <div style="mso-element:footnote" id="ftn2">
634
- <p id="" class="MsoFootnoteText"><a style="mso-footnote-id:ftn2" href="#_ftn2" name="_ftnref2" title="" id="_ftnref2"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a>Other Footnote</p></div>
635
- </div>')}
636
- #{WORD_FTR1}
637
- OUTPUT
678
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8")))
679
+ .to match_fuzzy(<<~OUTPUT)
680
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
681
+ #{word_body('<div>This is a very simple
682
+ document<a epub:type="footnote" href="#_ftn1" style="mso-footnote-id:ftn1" name="_ftnref1" title="" id="_ftnref1"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a> allegedly<a epub:type="footnote" href="#_ftn2" style="mso-footnote-id:ftn2" name="_ftnref2" title="" id="_ftnref2"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a></div>',
683
+ '<div style="mso-element:footnote-list"><div style="mso-element:footnote" id="ftn1">
684
+ <p id="" class="MsoFootnoteText"><a style="mso-footnote-id:ftn1" href="#_ftn1" name="_ftnref1" title="" id="_ftnref1"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a>Footnote</p></div>
685
+ <div style="mso-element:footnote" id="ftn2">
686
+ <p id="" class="MsoFootnoteText"><a style="mso-footnote-id:ftn2" href="#_ftn2" name="_ftnref2" title="" id="_ftnref2"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a>Other Footnote</p></div>
687
+ </div>')}
688
+ #{WORD_FTR1}
689
+ OUTPUT
638
690
  end
639
691
 
640
692
  it "processes class footnotes" do
@@ -643,38 +695,38 @@ RSpec.describe Html2Doc do
643
695
  <aside id="a1">Footnote</aside>
644
696
  <aside id="a2">Other Footnote</aside>'
645
697
  Html2Doc.process(html_input(simple_body), filename: "test")
646
- expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
647
- to match_fuzzy(<<~OUTPUT)
648
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
649
- #{word_body('<div>This is a very simple
650
- document<a class="footnote" href="#_ftn1" style="mso-footnote-id:ftn1" name="_ftnref1" title="" id="_ftnref1"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a> allegedly<a class="footnote" href="#_ftn2" style="mso-footnote-id:ftn2" name="_ftnref2" title="" id="_ftnref2"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a></div>',
651
- '<div style="mso-element:footnote-list"><div style="mso-element:footnote" id="ftn1">
652
- <p id="" class="MsoFootnoteText"><a style="mso-footnote-id:ftn1" href="#_ftn1" name="_ftnref1" title="" id="_ftnref1"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a>Footnote</p></div>
653
- <div style="mso-element:footnote" id="ftn2">
654
- <p id="" class="MsoFootnoteText"><a style="mso-footnote-id:ftn2" href="#_ftn2" name="_ftnref2" title="" id="_ftnref2"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a>Other Footnote</p></div>
655
- </div>')}
656
- #{WORD_FTR1}
657
- OUTPUT
698
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8")))
699
+ .to match_fuzzy(<<~OUTPUT)
700
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
701
+ #{word_body('<div>This is a very simple
702
+ document<a class="footnote" href="#_ftn1" style="mso-footnote-id:ftn1" name="_ftnref1" title="" id="_ftnref1"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a> allegedly<a class="footnote" href="#_ftn2" style="mso-footnote-id:ftn2" name="_ftnref2" title="" id="_ftnref2"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a></div>',
703
+ '<div style="mso-element:footnote-list"><div style="mso-element:footnote" id="ftn1">
704
+ <p id="" class="MsoFootnoteText"><a style="mso-footnote-id:ftn1" href="#_ftn1" name="_ftnref1" title="" id="_ftnref1"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a>Footnote</p></div>
705
+ <div style="mso-element:footnote" id="ftn2">
706
+ <p id="" class="MsoFootnoteText"><a style="mso-footnote-id:ftn2" href="#_ftn2" name="_ftnref2" title="" id="_ftnref2"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a>Other Footnote</p></div>
707
+ </div>')}
708
+ #{WORD_FTR1}
709
+ OUTPUT
658
710
  end
659
711
 
660
712
  it "processes footnotes with text wrapping the footnote reference" do
661
- simple_body = '<div>This is a very simple
713
+ simple_body = '<div>This is a very simple
662
714
  document<a class="footnote" href="#a1">(<span class="MsoFootnoteReference">1</span>)</a> allegedly<a class="footnote" href="#a2">2</a></div>
663
715
  <aside id="a1">Footnote</aside>
664
716
  <aside id="a2">Other Footnote</aside>'
665
717
  Html2Doc.process(html_input(simple_body), filename: "test")
666
- expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
667
- to match_fuzzy(<<~OUTPUT)
668
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
669
- #{word_body('<div>This is a very simple
670
- document<a class="footnote" href="#_ftn1" style="mso-footnote-id:ftn1" name="_ftnref1" title="" id="_ftnref1"><span class="MsoFootnoteReference">(</span><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span><span class="MsoFootnoteReference">)</span></a> allegedly<a class="footnote" href="#_ftn2" style="mso-footnote-id:ftn2" name="_ftnref2" title="" id="_ftnref2"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a></div>',
671
- '<div style="mso-element:footnote-list"><div style="mso-element:footnote" id="ftn1">
672
- <p id="" class="MsoFootnoteText"><a style="mso-footnote-id:ftn1" href="#_ftn1" name="_ftnref1" title="" id="_ftnref1"><span class="MsoFootnoteReference">(</span><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span><span class="MsoFootnoteReference">)</span></a>Footnote</p></div>
673
- <div style="mso-element:footnote" id="ftn2">
674
- <p id="" class="MsoFootnoteText"><a style="mso-footnote-id:ftn2" href="#_ftn2" name="_ftnref2" title="" id="_ftnref2"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a>Other Footnote</p></div>
675
- </div>')}
676
- #{WORD_FTR1}
677
- OUTPUT
718
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8")))
719
+ .to match_fuzzy(<<~OUTPUT)
720
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
721
+ #{word_body('<div>This is a very simple
722
+ document<a class="footnote" href="#_ftn1" style="mso-footnote-id:ftn1" name="_ftnref1" title="" id="_ftnref1"><span class="MsoFootnoteReference">(</span><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span><span class="MsoFootnoteReference">)</span></a> allegedly<a class="footnote" href="#_ftn2" style="mso-footnote-id:ftn2" name="_ftnref2" title="" id="_ftnref2"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a></div>',
723
+ '<div style="mso-element:footnote-list"><div style="mso-element:footnote" id="ftn1">
724
+ <p id="" class="MsoFootnoteText"><a style="mso-footnote-id:ftn1" href="#_ftn1" name="_ftnref1" title="" id="_ftnref1"><span class="MsoFootnoteReference">(</span><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span><span class="MsoFootnoteReference">)</span></a>Footnote</p></div>
725
+ <div style="mso-element:footnote" id="ftn2">
726
+ <p id="" class="MsoFootnoteText"><a style="mso-footnote-id:ftn2" href="#_ftn2" name="_ftnref2" title="" id="_ftnref2"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a>Other Footnote</p></div>
727
+ </div>')}
728
+ #{WORD_FTR1}
729
+ OUTPUT
678
730
  end
679
731
 
680
732
  it "extracts paragraphs from footnotes" do
@@ -683,18 +735,18 @@ RSpec.describe Html2Doc do
683
735
  <aside id="a1"><p>Footnote</p></aside>
684
736
  <div id="a2"><p>Other Footnote</p></div>'
685
737
  Html2Doc.process(html_input(simple_body), filename: "test")
686
- expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
687
- to match_fuzzy(<<~OUTPUT)
688
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
689
- #{word_body('<div>This is a very simple
690
- document<a class="footnote" href="#_ftn1" style="mso-footnote-id:ftn1" name="_ftnref1" title="" id="_ftnref1"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a> allegedly<a class="footnote" href="#_ftn2" style="mso-footnote-id:ftn2" name="_ftnref2" title="" id="_ftnref2"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a></div>',
691
- '<div style="mso-element:footnote-list"><div style="mso-element:footnote" id="ftn1">
692
- <p class="MsoFootnoteText"><a style="mso-footnote-id:ftn1" href="#_ftn1" name="_ftnref1" title="" id="_ftnref1"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a>Footnote</p></div>
693
- <div style="mso-element:footnote" id="ftn2">
694
- <p class="MsoFootnoteText"><a style="mso-footnote-id:ftn2" href="#_ftn2" name="_ftnref2" title="" id="_ftnref2"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a>Other Footnote</p></div>
695
- </div>')}
696
- #{WORD_FTR1}
697
- OUTPUT
738
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8")))
739
+ .to match_fuzzy(<<~OUTPUT)
740
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
741
+ #{word_body('<div>This is a very simple
742
+ document<a class="footnote" href="#_ftn1" style="mso-footnote-id:ftn1" name="_ftnref1" title="" id="_ftnref1"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a> allegedly<a class="footnote" href="#_ftn2" style="mso-footnote-id:ftn2" name="_ftnref2" title="" id="_ftnref2"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a></div>',
743
+ '<div style="mso-element:footnote-list"><div style="mso-element:footnote" id="ftn1">
744
+ <p class="MsoFootnoteText"><a style="mso-footnote-id:ftn1" href="#_ftn1" name="_ftnref1" title="" id="_ftnref1"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a>Footnote</p></div>
745
+ <div style="mso-element:footnote" id="ftn2">
746
+ <p class="MsoFootnoteText"><a style="mso-footnote-id:ftn2" href="#_ftn2" name="_ftnref2" title="" id="_ftnref2"><span class="MsoFootnoteReference"><span style="mso-special-character:footnote"></span></span></a>Other Footnote</p></div>
747
+ </div>')}
748
+ #{WORD_FTR1}
749
+ OUTPUT
698
750
  end
699
751
 
700
752
  it "labels lists with list styles" do
@@ -702,38 +754,39 @@ RSpec.describe Html2Doc do
702
754
  <div><ul id="0">
703
755
  <li><div><p><ol id="1"><li><ul id="2"><li><p><ol id="3"><li><ol id="4"><li>A</li><li><p>B</p><p>B2</p></li><li>C</li></ol></li></ol></p></li></ul></li></ol></p></div></li><div><ul id="5"><li>C</li></ul></div>
704
756
  BODY
705
- Html2Doc.process(html_input(simple_body), filename: "test", liststyles: {ul: "l1", ol: "l2"})
706
- expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
707
- to match_fuzzy(<<~OUTPUT)
708
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
709
- #{word_body('<div>
710
- <p style="mso-list:l1 level1 lfo1;" class="MsoListParagraphCxSpFirst"><div><p class="MsoNormal"><p style="mso-list:l2 level2 lfo1;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l2 level4 lfo1;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l2 level5 lfo1;" class="MsoListParagraphCxSpFirst">A</p><p style="mso-list:l2 level5 lfo1;" class="MsoListParagraphCxSpMiddle">B<p class="MsoListParagraphCxSpMiddle">B2</p></p><p style="mso-list:l2 level5 lfo1;" class="MsoListParagraphCxSpLast">C</p></p></p></p></div></p><div><p style="mso-list:l1 level1 lfo2;" class="MsoListParagraphCxSpFirst">C</p></div>
711
- </div>',
712
- '<div style="mso-element:footnote-list"/>')}
713
- #{WORD_FTR1}
714
- OUTPUT
757
+ Html2Doc.process(html_input(simple_body),
758
+ filename: "test", liststyles: { ul: "l1", ol: "l2" })
759
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8")))
760
+ .to match_fuzzy(<<~OUTPUT)
761
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
762
+ #{word_body('<div>
763
+ <p style="mso-list:l1 level1 lfo1;" class="MsoListParagraphCxSpFirst"><div><p class="MsoNormal"><p style="mso-list:l2 level2 lfo1;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l2 level4 lfo1;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l2 level5 lfo1;" class="MsoListParagraphCxSpFirst">A</p><p style="mso-list:l2 level5 lfo1;" class="MsoListParagraphCxSpMiddle">B<p class="MsoListParagraphCxSpMiddle">B2</p></p><p style="mso-list:l2 level5 lfo1;" class="MsoListParagraphCxSpLast">C</p></p></p></p></div></p><div><p style="mso-list:l1 level1 lfo2;" class="MsoListParagraphCxSpFirst">C</p></div>
764
+ </div>',
765
+ '<div style="mso-element:footnote-list"/>')}
766
+ #{WORD_FTR1}
767
+ OUTPUT
715
768
  end
716
769
 
717
-
718
770
  it "restarts numbering of lists with list styles" do
719
771
  simple_body = <<~BODY
720
772
  <div>
721
773
  <ol id="1"><li><div><p><ol id="2"><li><ul id="3"><li><p><ol id="4"><li><ol id="5"><li>A</li></ol></li></ol></p></li></ul></li></ol></p></div></li></ol>
722
774
  <ol id="6"><li><div><p><ol id="7"><li><ul id="8"><li><p><ol id="9"><li><ol id="10"><li>A</li></ol></li></ol></p></li></ul></li></ol></p></div></li></ol></div>
723
775
  BODY
724
- Html2Doc.process(html_input(simple_body), filename: "test", liststyles: {ul: "l1", ol: "l2"})
725
- expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
726
- to match_fuzzy(<<~OUTPUT)
727
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
728
- #{word_body('<div>
729
- <p style="mso-list:l2 level1 lfo1;" class="MsoListParagraphCxSpFirst"><div><p class="MsoNormal"><p style="mso-list:l2 level2 lfo1;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l2 level4 lfo1;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l2 level5 lfo1;" class="MsoListParagraphCxSpFirst">A</p></p></p></p></div></p>
730
- <p style="mso-list:l2 level1 lfo2;" class="MsoListParagraphCxSpFirst"><div><p class="MsoNormal"><p style="mso-list:l2 level2 lfo2;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l2 level4 lfo2;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l2 level5 lfo2;" class="MsoListParagraphCxSpFirst">A</p></p></p></p></div></p></div>',
731
- '<div style="mso-element:footnote-list"/>')}
732
- #{WORD_FTR1}
733
- OUTPUT
734
- end
735
-
736
- it "labels lists with multiple list styles" do
776
+ Html2Doc.process(html_input(simple_body),
777
+ filename: "test", liststyles: { ul: "l1", ol: "l2" })
778
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8")))
779
+ .to match_fuzzy(<<~OUTPUT)
780
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
781
+ #{word_body('<div>
782
+ <p style="mso-list:l2 level1 lfo1;" class="MsoListParagraphCxSpFirst"><div><p class="MsoNormal"><p style="mso-list:l2 level2 lfo1;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l2 level4 lfo1;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l2 level5 lfo1;" class="MsoListParagraphCxSpFirst">A</p></p></p></p></div></p>
783
+ <p style="mso-list:l2 level1 lfo2;" class="MsoListParagraphCxSpFirst"><div><p class="MsoNormal"><p style="mso-list:l2 level2 lfo2;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l2 level4 lfo2;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l2 level5 lfo2;" class="MsoListParagraphCxSpFirst">A</p></p></p></p></div></p></div>',
784
+ '<div style="mso-element:footnote-list"/>')}
785
+ #{WORD_FTR1}
786
+ OUTPUT
787
+ end
788
+
789
+ it "labels lists with multiple list styles" do
737
790
  simple_body = <<~BODY
738
791
  <div><ul class="steps" id="0">
739
792
  <li><div><p><ol id="1"><li><ul id="2"><li><p><ol id="3"><li><ol id="4"><li>A</li><li><p>B</p><p>B2</p></li><li>C</li></ol></li></ol></p></li></ul></li></ol></p></div></li></ul></div>
@@ -742,19 +795,21 @@ RSpec.describe Html2Doc do
742
795
  <div><ul class="other" id="10">
743
796
  <li><div><p><ol id="11"><li><ul id="12"><li><p><ol id="13"><li><ol id="14"><li>A</li><li><p>B</p><p>B2</p></li><li>C</li></ol></li></ol></p></li></ul></li></ol></p></div></li></ul></div>
744
797
  BODY
745
- Html2Doc.process(html_input(simple_body), filename: "test", liststyles: {ul: "l1", ol: "l2", steps: "l3"})
746
- expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
747
- to match_fuzzy(<<~OUTPUT)
748
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
749
- #{word_body('<div>
750
- <p style="mso-list:l3 level1 lfo2;" class="MsoListParagraphCxSpFirst"><div><p class="MsoNormal"><p style="mso-list:l3 level2 lfo2;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l3 level4 lfo2;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l3 level5 lfo2;" class="MsoListParagraphCxSpFirst">A</p><p style="mso-list:l3 level5 lfo2;" class="MsoListParagraphCxSpMiddle">B<p class="MsoListParagraphCxSpMiddle">B2</p></p><p style="mso-list:l3 level5 lfo2;" class="MsoListParagraphCxSpLast">C</p></p></p></p></div></p></div>
751
- <div>
752
- <p style="mso-list:l1 level1 lfo1;" class="MsoListParagraphCxSpFirst"><div><p class="MsoNormal"><p style="mso-list:l2 level2 lfo1;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l2 level4 lfo1;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l2 level5 lfo1;" class="MsoListParagraphCxSpFirst">A</p><p style="mso-list:l2 level5 lfo1;" class="MsoListParagraphCxSpMiddle">B<p class="MsoListParagraphCxSpMiddle">B2</p></p><p style="mso-list:l2 level5 lfo1;" class="MsoListParagraphCxSpLast">C</p></p></p></p></div></p></div>
753
- <div>
754
- <p style="mso-list:l1 level1 lfo3;" class="MsoListParagraphCxSpFirst"><div><p class="MsoNormal"><p style="mso-list:l2 level2 lfo3;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l2 level4 lfo3;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l2 level5 lfo3;" class="MsoListParagraphCxSpFirst">A</p><p style="mso-list:l2 level5 lfo3;" class="MsoListParagraphCxSpMiddle">B<p class="MsoListParagraphCxSpMiddle">B2</p></p><p style="mso-list:l2 level5 lfo3;" class="MsoListParagraphCxSpLast">C</p></p></p></p></div></p></div>',
755
- '<div style="mso-element:footnote-list"/>')}
756
- #{WORD_FTR1}
757
- OUTPUT
798
+ Html2Doc.process(html_input(simple_body),
799
+ filename: "test",
800
+ liststyles: { ul: "l1", ol: "l2", steps: "l3" })
801
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8")))
802
+ .to match_fuzzy(<<~OUTPUT)
803
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
804
+ #{word_body('<div>
805
+ <p style="mso-list:l3 level1 lfo2;" class="MsoListParagraphCxSpFirst"><div><p class="MsoNormal"><p style="mso-list:l3 level2 lfo2;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l3 level4 lfo2;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l3 level5 lfo2;" class="MsoListParagraphCxSpFirst">A</p><p style="mso-list:l3 level5 lfo2;" class="MsoListParagraphCxSpMiddle">B<p class="MsoListParagraphCxSpMiddle">B2</p></p><p style="mso-list:l3 level5 lfo2;" class="MsoListParagraphCxSpLast">C</p></p></p></p></div></p></div>
806
+ <div>
807
+ <p style="mso-list:l1 level1 lfo1;" class="MsoListParagraphCxSpFirst"><div><p class="MsoNormal"><p style="mso-list:l2 level2 lfo1;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l2 level4 lfo1;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l2 level5 lfo1;" class="MsoListParagraphCxSpFirst">A</p><p style="mso-list:l2 level5 lfo1;" class="MsoListParagraphCxSpMiddle">B<p class="MsoListParagraphCxSpMiddle">B2</p></p><p style="mso-list:l2 level5 lfo1;" class="MsoListParagraphCxSpLast">C</p></p></p></p></div></p></div>
808
+ <div>
809
+ <p style="mso-list:l1 level1 lfo3;" class="MsoListParagraphCxSpFirst"><div><p class="MsoNormal"><p style="mso-list:l2 level2 lfo3;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l2 level4 lfo3;" class="MsoListParagraphCxSpFirst"><p style="mso-list:l2 level5 lfo3;" class="MsoListParagraphCxSpFirst">A</p><p style="mso-list:l2 level5 lfo3;" class="MsoListParagraphCxSpMiddle">B<p class="MsoListParagraphCxSpMiddle">B2</p></p><p style="mso-list:l2 level5 lfo3;" class="MsoListParagraphCxSpLast">C</p></p></p></p></div></p></div>',
810
+ '<div style="mso-element:footnote-list"/>')}
811
+ #{WORD_FTR1}
812
+ OUTPUT
758
813
  end
759
814
 
760
815
  it "replaces id attributes with explicit a@name bookmarks" do
@@ -764,27 +819,30 @@ RSpec.describe Html2Doc do
764
819
  <p id="b"/>
765
820
  </div>
766
821
  BODY
767
- Html2Doc.process(html_input(simple_body), filename: "test", liststyles: {ul: "l1", ol: "l2"})
768
- expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
769
- to match_fuzzy(<<~OUTPUT)
770
- #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
771
- #{word_body('<div>
772
- <p class="MsoNormal"><a name="a" id="a"></a>Hello</p>
773
- <p class="MsoNormal"><a name="b" id="b"></a></p>
774
- </div>',
775
- '<div style="mso-element:footnote-list"/>')}
776
- #{WORD_FTR1}
777
- OUTPUT
822
+ Html2Doc.process(html_input(simple_body),
823
+ filename: "test", liststyles: { ul: "l1", ol: "l2" })
824
+ expect(guid_clean(File.read("test.doc", encoding: "utf-8")))
825
+ .to match_fuzzy(<<~OUTPUT)
826
+ #{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
827
+ #{word_body('<div>
828
+ <p class="MsoNormal"><a name="a" id="a"></a>Hello</p>
829
+ <p class="MsoNormal"><a name="b" id="b"></a></p>
830
+ </div>',
831
+ '<div style="mso-element:footnote-list"/>')}
832
+ #{WORD_FTR1}
833
+ OUTPUT
778
834
  end
779
835
 
780
836
  it "test image base64 image encoding" do
781
837
  simple_body = '<img src="19160-6.png">'
782
- Html2Doc.process(html_input(simple_body), filename: "spec/test", debug: true)
838
+ Html2Doc.process(html_input(simple_body),
839
+ filename: "spec/test", debug: true)
783
840
  testdoc = File.read("spec/test.doc", encoding: "utf-8")
784
841
  base64_image = testdoc[/image\/png\n\n(.*?)\n\n----/m, 1].gsub!("\n", "")
785
- base64_image_basename = testdoc[%r{Content-Location: file:///C:/Doc/test_files/([0-9a-z\-]+)\.png}m, 1]
842
+ base64_image_basename = testdoc[%r{Content-ID: <([0-9a-z\-]+)\.png}m, 1]
786
843
  doc_bin_image = Base64.strict_decode64(base64_image)
787
- file_bin_image = IO.read("spec/test_files/#{base64_image_basename}.png", mode: "rb")
844
+ file_bin_image = IO
845
+ .read("spec/test_files/#{base64_image_basename}.png", mode: "rb")
788
846
  expect(doc_bin_image).to eq file_bin_image
789
847
  FileUtils.rm_rf %w[spec/test_files spec/test.doc spec/test.htm]
790
848
  end