isodoc 2.0.0.1 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3cf2e2e18bcb28744fc2f4cf2525267935dc981281ab4642c7b0e57ea8b68b6d
4
- data.tar.gz: 12f9afbb69bd5e9903dd15ace22e5a3357520dfc8c58e4a316bc8e92a42e34bb
3
+ metadata.gz: 201d6214562a3056d1a1e6d1346a39c91bd73edf2e4bdc8dc5539a0398e6c3ff
4
+ data.tar.gz: 103e2fddde68956154632f9619b6edbe04a1df4087faf6088b69649fcd7e2569
5
5
  SHA512:
6
- metadata.gz: b3996461e5a31740161f1bf08c0305b7e9faa229f263da26deaaf9fd50924c9cb39f2eaffacf4b6e69992a197d81c10b130a82b06d0c630917b3c22b34eca615
7
- data.tar.gz: 7c3a9fe8073d10c915e56f06bf973b6e7dfbd2e6296604598d93b90267496f74ebf5cbb2bcfd970eafafc0c808dc69e9273b0a1e1975a459e32993bfe0f57de6
6
+ metadata.gz: 197e770551602d75f6890ea1258a861a19e8a6f116450889da86107b529373d43c016ef41cb965b3cb01d44ddbaef2bcd7c3cd84b414f9a40cde522055e2b4f5
7
+ data.tar.gz: 0fce2fe86f4facea7ba594a2425c0c66a4c1577ed1bf828d3c7bd61943dad0b314fedb8513ff3fb3d027e45832490cdaa90a607db749d5cbcc5931a704f6acc9
@@ -54,11 +54,12 @@ module IsoDoc
54
54
  end
55
55
  end
56
56
 
57
+ # top level clause names
57
58
  def clause_name(_num, title, div, header_class)
59
+ preceding_floating_titles(title, div)
58
60
  header_class = {} if header_class.nil?
59
61
  div.h1 **attr_code(header_class) do |h1|
60
- if title.is_a?(String)
61
- h1 << title
62
+ if title.is_a?(String) then h1 << title
62
63
  else
63
64
  title&.children&.each { |c2| parse(c2, h1) }
64
65
  clause_parse_subtitle(title, h1)
@@ -68,6 +69,7 @@ module IsoDoc
68
69
  end
69
70
 
70
71
  def annex_name(_annex, name, div)
72
+ preceding_floating_titles(name, div)
71
73
  return if name.nil?
72
74
 
73
75
  div.h1 **{ class: "Annex" } do |t|
@@ -82,6 +84,18 @@ module IsoDoc
82
84
  node.children.each { |c| parse(c, p) }
83
85
  end
84
86
  end
87
+
88
+ def preceding_floating_titles(name, div)
89
+ return if name.nil? || name.is_a?(String)
90
+
91
+ out = name.parent.xpath("./preceding-sibling::*")
92
+ .reverse.each_with_object([]) do |p, m|
93
+ break m unless p.name == "p"
94
+
95
+ m << p
96
+ end or return
97
+ out.each { |c| parse(c, div) }
98
+ end
85
99
  end
86
100
  end
87
101
  end
@@ -26,6 +26,8 @@ module IsoDoc
26
26
  .each do |f|
27
27
  floattitle1(f)
28
28
  end
29
+ # top-level
30
+ docxml.xpath(ns("//sections | //preface")).each { |f| floattitle1(f) }
29
31
  end
30
32
 
31
33
  def floattitle1(elem)
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "2.0.0.1".freeze
2
+ VERSION = "2.0.1".freeze
3
3
  end
@@ -1,6 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
3
  RSpec.describe IsoDoc do
4
+ =begin
4
5
  it "processes prefatory blocks" do
5
6
  input = <<~INPUT
6
7
  <iso-standard xmlns="http://riboseinc.com/isoxml">
@@ -1495,11 +1496,12 @@ RSpec.describe IsoDoc do
1495
1496
  .new({ suppressheadingnumbers: true })
1496
1497
  .convert("test", input, true))).to be_equivalent_to xmlpp(output)
1497
1498
  end
1498
-
1499
+ =end
1499
1500
  it "processes floating titles" do
1500
1501
  input = <<~INPUT
1501
1502
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1502
1503
  <preface>
1504
+ <floating-title depth="1">A0</p>
1503
1505
  <introduction id="B" obligation="informative">
1504
1506
  <title>Introduction</title>
1505
1507
  <floating-title depth="1">A</p>
@@ -1513,18 +1515,35 @@ RSpec.describe IsoDoc do
1513
1515
  </clause>
1514
1516
  </introduction>
1515
1517
  </preface>
1518
+ <sections>
1519
+ <clause id="C" obligation="informative">
1520
+ <title>Introduction</title>
1521
+ <floating-title depth="1">A</p>
1522
+ <clause id="C1" obligation="informative">
1523
+ <title>Introduction Subsection</title>
1524
+ <floating-title depth="2">B</p>
1525
+ <clause id="C2" obligation="informative">
1526
+ <title>Introduction Sub-subsection</title>
1527
+ <floating-title depth="1">C</p>
1528
+ </clause>
1529
+ </clause>
1530
+ </clause>
1531
+ <floating-title depth="1">D</p>
1532
+ <clause id="C4"><title>Clause 2</title></clause>
1533
+ </sections>
1516
1534
  </iso-standard>
1517
1535
  INPUT
1518
1536
 
1519
1537
  presxml = <<~PRESXML
1520
- <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
1538
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
1521
1539
  <preface>
1522
- <introduction id='B' obligation='informative' displayorder='1'>
1540
+ <p depth='1' type='floating-title' displayorder='1'>A0</p>
1541
+ <introduction id='B' obligation='informative' displayorder='2'>
1523
1542
  <title>Introduction</title>
1524
1543
  <p depth='1' type='floating-title'>A</p>
1525
1544
  <clause id='B1' obligation='informative'>
1526
1545
  <title depth='2'>Introduction Subsection</title>
1527
- <p type='floating-title' depth="2">B</p>
1546
+ <p depth='2' type='floating-title'>B</p>
1528
1547
  <clause id='B2' obligation='informative'>
1529
1548
  <title depth='3'>Introduction Sub-subsection</title>
1530
1549
  <p depth='1' type='floating-title'>C</p>
@@ -1532,13 +1551,49 @@ RSpec.describe IsoDoc do
1532
1551
  </clause>
1533
1552
  </introduction>
1534
1553
  </preface>
1554
+ <sections>
1555
+ <clause id='C' obligation='informative' displayorder='3'>
1556
+ <title depth='1'>
1557
+ 1.
1558
+ <tab/>
1559
+ Introduction
1560
+ </title>
1561
+ <p depth='1' type='floating-title'>A</p>
1562
+ <clause id='C1' obligation='informative'>
1563
+ <title depth='2'>
1564
+ 1.1.
1565
+ <tab/>
1566
+ Introduction Subsection
1567
+ </title>
1568
+ <p depth='2' type='floating-title'>B</p>
1569
+ <clause id='C2' obligation='informative'>
1570
+ <title depth='3'>
1571
+ 1.1.1.
1572
+ <tab/>
1573
+ Introduction Sub-subsection
1574
+ </title>
1575
+ <p depth='1' type='floating-title'>C</p>
1576
+ </clause>
1577
+ </clause>
1578
+ </clause>
1579
+ <p depth='1' type='floating-title'>D</p>
1580
+ <clause id='C4' displayorder='4'>
1581
+ <title depth='1'>
1582
+ 2.
1583
+ <tab/>
1584
+ Clause 2
1585
+ </title>
1586
+ </clause>
1587
+ </sections>
1535
1588
  </iso-standard>
1536
1589
  PRESXML
1537
1590
 
1538
1591
  html = <<~OUTPUT
1539
1592
  #{HTML_HDR}
1593
+ <p class='h1'>A0</p>
1540
1594
  <br/>
1541
1595
  <div class='Section3' id='B'>
1596
+ <p class='h1'>A0</p>
1542
1597
  <h1 class='IntroTitle'>Introduction</h1>
1543
1598
  <p class='h1'>A</p>
1544
1599
  <div id='B1'>
@@ -1551,6 +1606,22 @@ RSpec.describe IsoDoc do
1551
1606
  </div>
1552
1607
  </div>
1553
1608
  <p class='zzSTDTitle1'/>
1609
+ <div id='C'>
1610
+ <h1> 1. &#160; Introduction </h1>
1611
+ <p class='h1'>A</p>
1612
+ <div id='C1'>
1613
+ <h2> 1.1. &#160; Introduction Subsection </h2>
1614
+ <p class='h2'>B</p>
1615
+ <div id='C2'>
1616
+ <h3> 1.1.1. &#160; Introduction Sub-subsection </h3>
1617
+ <p class='h1'>C</p>
1618
+ </div>
1619
+ </div>
1620
+ </div>
1621
+ <div id='C4'>
1622
+ <p class='h1'>D</p>
1623
+ <h1> 2. &#160; Clause 2 </h1>
1624
+ </div>
1554
1625
  </div>
1555
1626
  </body>
1556
1627
  </html>
@@ -1569,10 +1640,12 @@ RSpec.describe IsoDoc do
1569
1640
  <br clear='all' class='section'/>
1570
1641
  </p>
1571
1642
  <div class='WordSection2'>
1643
+ <p>A0</p>
1572
1644
  <p>
1573
1645
  <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
1574
1646
  </p>
1575
1647
  <div class='Section3' id='B'>
1648
+ <p>A0</p>
1576
1649
  <h1 class='IntroTitle'>Introduction</h1>
1577
1650
  <p>A</p>
1578
1651
  <div id='B1'>
@@ -1591,6 +1664,38 @@ RSpec.describe IsoDoc do
1591
1664
  </p>
1592
1665
  <div class='WordSection3'>
1593
1666
  <p class='zzSTDTitle1'/>
1667
+ <div id='C'>
1668
+ <h1>
1669
+ 1.
1670
+ <span style='mso-tab-count:1'>&#160; </span>
1671
+ Introduction
1672
+ </h1>
1673
+ <p>A</p>
1674
+ <div id='C1'>
1675
+ <h2>
1676
+ 1.1.
1677
+ <span style='mso-tab-count:1'>&#160; </span>
1678
+ Introduction Subsection
1679
+ </h2>
1680
+ <p>B</p>
1681
+ <div id='C2'>
1682
+ <h3>
1683
+ 1.1.1.
1684
+ <span style='mso-tab-count:1'>&#160; </span>
1685
+ Introduction Sub-subsection
1686
+ </h3>
1687
+ <p>C</p>
1688
+ </div>
1689
+ </div>
1690
+ </div>
1691
+ <div id='C4'>
1692
+ <p>D</p>
1693
+ <h1>
1694
+ 2.
1695
+ <span style='mso-tab-count:1'>&#160; </span>
1696
+ Clause 2
1697
+ </h1>
1698
+ </div>
1594
1699
  </div>
1595
1700
  </body>
1596
1701
  </html>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isodoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.1
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-10 00:00:00.000000000 Z
11
+ date: 2022-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciimath