Commit 3abddfb 1 parent 6d95d8e commit 3abddfb Copy full SHA for 3abddfb
File tree 4 files changed +138
-38
lines changed
4 files changed +138
-38
lines changed Original file line number Diff line number Diff line change @@ -208,6 +208,39 @@ def title_footnotes(isoxml)
208
208
ret
209
209
end
210
210
211
+ def block ( docxml )
212
+ super
213
+ dl docxml
214
+ end
215
+
216
+ def dl ( xml )
217
+ ( xml . xpath ( ns ( "//dl" ) ) -
218
+ xml . xpath ( ns ( "//table//dl | //figure//dl | //formula//dl" ) ) )
219
+ . each do |d |
220
+ dl1 ( d )
221
+ end
222
+ end
223
+
224
+ def dl1 ( dlist )
225
+ ret = dl2tbody ( dlist )
226
+ n = dlist . at ( ns ( "./name" ) ) and ret = "#{ n . remove . to_xml } #{ ret } "
227
+ dlist . name = "table"
228
+ dlist [ "class" ] = "dl"
229
+ dlist . children . first . previous = ret
230
+ end
231
+
232
+ def dl2tbody ( dlist )
233
+ ret = ""
234
+ dlist . elements . select { |n | %w{ dt dd } . include? n . name }
235
+ . each_slice ( 2 ) do |dt , dd |
236
+ ret += "<tr><th width='20%'>#{ dt . children . to_xml } </th>" \
237
+ "<td width='80%'>#{ dd . children . to_xml } </td></tr>"
238
+ dt . replace ( " " )
239
+ dd . remove
240
+ end
241
+ "<tbody>#{ ret } </tbody>"
242
+ end
243
+
211
244
include Init
212
245
end
213
246
end
Original file line number Diff line number Diff line change 30
30
. to be_equivalent_to xmlpp ( output )
31
31
end
32
32
33
+ it "processes dl" do
34
+ input = <<~INPUT
35
+ <itu-standard xmlns="https://www.calconnect.org/standards/itu">
36
+ <preface>
37
+ <clause type="toc" id="_" displayorder="1">
38
+ <title depth="1">Table of Contents</title>
39
+ </clause>
40
+ <foreword displayorder="2">
41
+ <dl id="A"><name>Deflist</name>
42
+ <dt>A</dt><dd>B</dd>
43
+ <dt>C</dt><dd>D</dd>
44
+ <note>hien?</note>
45
+ </dl>
46
+ </foreword></preface>
47
+ </itu-standard>
48
+ INPUT
49
+ output = <<~OUTPUT
50
+ <itu-standard xmlns="https://www.calconnect.org/standards/itu" type="presentation">
51
+ <preface>
52
+ <foreword displayorder="1">
53
+ <table id="A" class="dl">
54
+ <name>Deflist</name>
55
+ <tbody>
56
+ <tr>
57
+ <th width="20%">A</th>
58
+ <td width="80%">B</td>
59
+ </tr>
60
+ <tr>
61
+ <th width="20%">C</th>
62
+ <td width="80%">D</td>
63
+ </tr>
64
+ </tbody>
65
+ <note><name>NOTE</name>hien?</note>
66
+ </table>
67
+ </foreword>
68
+ <clause type="toc" id="_" displayorder="2">
69
+ <title depth="1">Table of Contents</title>
70
+ </clause>
71
+ </preface>
72
+ </itu-standard>
73
+ OUTPUT
74
+ expect ( xmlpp ( strip_guid ( IsoDoc ::ITU ::PresentationXMLConvert
75
+ . new ( presxml_options )
76
+ . convert ( "test" , input , true ) ) ) )
77
+ . to be_equivalent_to xmlpp ( output )
78
+ end
79
+
33
80
it "processes formulae" do
34
81
input = <<~INPUT
35
82
<iso-standard xmlns="http://riboseinc.com/isoxml">
Original file line number Diff line number Diff line change 53
53
</term>
54
54
</terms>
55
55
<definitions id="L" displayorder="12"><title>4.</title>
56
- <dl>
57
- <dt>Symbol</dt>
58
- <dd>Definition</dd>
59
- </dl>
56
+ <table class="dl">
57
+ <tbody>
58
+ <tr>
59
+ <th width="20%">Symbol</th>
60
+ <td width="80%">Definition</td>
61
+ </tr>
62
+ </tbody>
63
+ </table>
60
64
</definitions>
61
65
<clause id="M" inline-header="false" obligation="normative" displayorder="13">
62
66
<title depth="1">5.<tab/>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
131
135
</div>
132
136
<div id="L" class="Symbols">
133
137
<h1>4.</h1>
134
- <dl>
135
- <dt>
136
- <p>Symbol</p>
137
- </dt>
138
- <dd>Definition</dd>
139
- </dl>
138
+ <table class="dl" style="">
139
+ <tbody>
140
+ <tr>
141
+ <th style="font-weight:bold;" scope="row">Symbol</th>
142
+ <td style="">Definition</td>
143
+ </tr>
144
+ </tbody>
145
+ </table>
140
146
</div>
141
147
<div id="M">
142
148
<h1>5.  Clause 4</h1>
236
242
</term>
237
243
</terms>
238
244
<definitions id="L" displayorder="11"><title>4.</title>
239
- <dl>
240
- <dt>Symbol</dt>
241
- <dd>Definition</dd>
242
- </dl>
245
+ <table class="dl">
246
+ <tbody>
247
+ <tr>
248
+ <th width="20%">Symbol</th>
249
+ <td width="80%">Definition</td>
250
+ </tr>
251
+ </tbody>
252
+ </table>
243
253
</definitions>
244
254
<clause id="M" inline-header="false" obligation="normative" displayorder="12">
245
255
<title depth="1">5.<tab/>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
317
327
</div>
318
328
<div id='L' class='Symbols'>
319
329
<h1>4.</h1>
320
- <dl>
321
- <dt>
322
- <p>Symbol</p>
323
- </dt>
324
- <dd>Definition</dd>
325
- </dl>
330
+ <table class="dl" style="">
331
+ <tbody>
332
+ <tr>
333
+ <th style="font-weight:bold;" scope="row">Symbol</th>
334
+ <td style="">Definition</td>
335
+ </tr>
336
+ </tbody>
337
+ </table>
326
338
</div>
327
339
<div id='M'>
328
340
<h1>5. Clause 4</h1>
Original file line number Diff line number Diff line change 280
280
</term>
281
281
</terms>
282
282
<definitions id="L" displayorder="12"><title>4.</title>
283
- <dl>
284
- <dt>Symbol</dt>
285
- <dd>Definition</dd>
286
- </dl>
283
+ <table class="dl">
284
+ <tbody>
285
+ <tr>
286
+ <th width="20%">Symbol</th>
287
+ <td width="80%">Definition</td>
288
+ </tr>
289
+ </tbody>
290
+ </table>
287
291
</definitions>
288
292
<clause id="M" inline-header="false" obligation="normative" displayorder="13">
289
293
<title depth="1">5.<tab/>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
358
362
</div>
359
363
<div id="L" class="Symbols">
360
364
<h1>4.</h1>
361
- <dl>
362
- <dt>
363
- <p>Symbol</p>
364
- </dt>
365
- <dd>Definition</dd>
366
- </dl>
365
+ <table class="dl" style="">
366
+ <tbody>
367
+ <tr>
368
+ <th style="font-weight:bold;" scope="row">Symbol</th>
369
+ <td style="">Definition</td>
370
+ </tr>
371
+ </tbody>
372
+ </table>
367
373
</div>
368
374
<div id="M">
369
375
<h1>5.  Clause 4</h1>
466
472
</div>
467
473
<div id="L" class="Symbols">
468
474
<h1>4.</h1>
469
- <table class="dl">
470
- <tr>
471
- <td valign="top" align="left">
472
- <p align="left" style="margin-left:0pt;text-align:left;">Symbol</p>
473
- </td>
474
- <td valign="top">Definition</td>
475
- </tr>
476
- </table>
475
+ <div align="center" class="table_container">
476
+ <table class="dl" style="mso-table-anchor-horizontal:column;mso-table-overlap:never;">
477
+ <tbody>
478
+ <tr>
479
+ <th valign="top" style="font-weight:bold;page-break-after:auto;">Symbol</th>
480
+ <td valign="top" style="page-break-after:auto;">Definition</td>
481
+ </tr>
482
+ </tbody>
483
+ </table>
484
+ </div>
477
485
</div>
478
486
<div id="M">
479
487
<h1>5.<span style="mso-tab-count:1">  </span>Clause 4</h1>
You can’t perform that action at this time.
0 commit comments