metanorma-jis 0.2.5 → 0.2.6

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: 65f86c5e987c2ebb3e29e79cf4257506cb59ad2e5b80036d0814b0b7e806de52
4
- data.tar.gz: a873f22013e0ffb53706b5615c1297adff565ee6ae0184465456f7a4a081af73
3
+ metadata.gz: 3e535a59c279bcefe69819d283821225f8c751cec09a3c28d9362186fc6ad6d1
4
+ data.tar.gz: 0265fc5c6ad595bd5c4cab59b539cc2d8f33c8260e6e7f908419897296889554
5
5
  SHA512:
6
- metadata.gz: '09aaa2e07d8cc7632b463c51d83a8b7d5ddd8056c636175ec1fcc9d4ca824ae7cb3c974e0ed39891c339a15706c99989f7c8dad583d1ece3985d54431a78c581'
7
- data.tar.gz: f8dcb73f59c6bcd1757c6ebee5f9ee53c8185eecfe0ab1f5922fa9c52e0cce65d661b9ba1647c6cca148e475b0630f52d1697c79dca13833a95cce7f398c468f
6
+ metadata.gz: 4426ffed2000345bf1150e89c336e22b43311af42d470aede5c894a156b1c6336766318cb07f54340e01d7ac0d230729a053673524b2fa4cde5cb896e9748e59
7
+ data.tar.gz: 6220cd22faaec6fdfedddf86c1b352c0796906e5fda536a7f31e95ea06fcbd337a289dbedd8ac9a22a796bddeea46d7f27ddaa4a0dd750e28ee2656ac8b1bf26
@@ -1583,6 +1583,9 @@
1583
1583
  <xsl:param name="copyrightText"/>
1584
1584
  <fo:static-content flow-name="footer">
1585
1585
  <fo:block-container height="24mm" display-align="after">
1586
+ <xsl:if test="$section = 'commentary'">
1587
+ <xsl:attribute name="height">24.5mm</xsl:attribute>
1588
+ </xsl:if>
1586
1589
  <xsl:if test="$section = 'preface'">
1587
1590
  <fo:block font-size="9pt" text-align="center" space-after="10pt">(<fo:inline font-family="Times New Roman"><fo:page-number/></fo:inline>)</fo:block>
1588
1591
  </xsl:if>
@@ -1627,17 +1630,30 @@
1627
1630
  <xsl:param name="add_math_as_text">true</xsl:param> <!-- add math in text behind svg formula, to copy-paste formula from PDF as text -->
1628
1631
 
1629
1632
  <xsl:param name="table_if">false</xsl:param> <!-- generate extended table in IF for autolayout-algorithm -->
1630
- <xsl:param name="table_widths"/> <!-- path to xml with table's widths, generated on 1st pass, based on FOP Intermediate Format -->
1633
+ <xsl:param name="table_widths"/> <!-- (debug: path to) xml with table's widths, generated on 1st pass, based on FOP Intermediate Format -->
1631
1634
  <!-- Example: <tables>
1632
- <table id="table_if_tab-symdu" page-width="75"> - table id prefixed by 'table_if_' to simple search in IF
1633
- <tbody>
1634
- <tr>
1635
- <td id="tab-symdu_1_1">
1636
- <p_len>6</p_len>
1637
- <p_len>100</p_len> for 2nd paragraph
1638
- <word_len>6</word_len>
1639
- <word_len>20</word_len>
1640
- ...
1635
+ <table page-width="509103" id="table1" width_max="223561" width_min="223560">
1636
+ <column width_max="39354" width_min="39354"/>
1637
+ <column width_max="75394" width_min="75394"/>
1638
+ <column width_max="108813" width_min="108813"/>
1639
+ <tbody>
1640
+ <tr>
1641
+ <td width_max="39354" width_min="39354">
1642
+ <p_len>39354</p_len>
1643
+ <word_len>39354</word_len>
1644
+ </td>
1645
+
1646
+ OLD:
1647
+ <tables>
1648
+ <table id="table_if_tab-symdu" page-width="75"> - table id prefixed by 'table_if_' to simple search in IF
1649
+ <tbody>
1650
+ <tr>
1651
+ <td id="tab-symdu_1_1">
1652
+ <p_len>6</p_len>
1653
+ <p_len>100</p_len> for 2nd paragraph
1654
+ <word_len>6</word_len>
1655
+ <word_len>20</word_len>
1656
+ ...
1641
1657
  -->
1642
1658
 
1643
1659
  <!-- for command line debug: <xsl:variable name="table_widths_from_if" select="document($table_widths)"/> -->
@@ -1857,6 +1873,9 @@
1857
1873
  <xsl:variable name="hair_space"> </xsl:variable>
1858
1874
  <xsl:variable name="en_dash">–</xsl:variable>
1859
1875
  <xsl:variable name="em_dash">—</xsl:variable>
1876
+ <xsl:variable name="cr">&#13;</xsl:variable>
1877
+ <xsl:variable name="lf">
1878
+ </xsl:variable>
1860
1879
 
1861
1880
  <xsl:template name="getTitle">
1862
1881
  <xsl:param name="name"/>
@@ -2631,6 +2650,10 @@
2631
2650
 
2632
2651
  <xsl:template name="refine_figure-block-style">
2633
2652
 
2653
+ <xsl:if test="ancestor::*[local-name() = 'example'] or ancestor::*[local-name() = 'note']">
2654
+ <xsl:attribute name="margin-left">0mm</xsl:attribute>
2655
+ </xsl:if>
2656
+
2634
2657
  </xsl:template>
2635
2658
 
2636
2659
  <xsl:attribute-set name="figure-style">
@@ -3509,6 +3532,20 @@
3509
3532
  </xsl:for-each>
3510
3533
  </xsl:template>
3511
3534
 
3535
+ <xsl:param name="table_only_with_id"/><!-- Example: table1, for table auto-layout algorithm -->
3536
+
3537
+ <xsl:template match="*[local-name()='table']" priority="2">
3538
+ <xsl:choose>
3539
+ <xsl:when test="$table_only_with_id != '' and @id = $table_only_with_id">
3540
+ <xsl:call-template name="table"/>
3541
+ </xsl:when>
3542
+ <xsl:when test="$table_only_with_id != ''"><fo:block/><!-- to prevent empty fo:block-container --></xsl:when>
3543
+ <xsl:otherwise>
3544
+ <xsl:call-template name="table"/>
3545
+ </xsl:otherwise>
3546
+ </xsl:choose>
3547
+ </xsl:template>
3548
+
3512
3549
  <xsl:template match="*[local-name()='table']" name="table">
3513
3550
 
3514
3551
  <xsl:variable name="table-preamble">
@@ -3518,9 +3555,11 @@
3518
3555
  <xsl:variable name="table">
3519
3556
 
3520
3557
  <xsl:variable name="simple-table">
3521
- <xsl:call-template name="getSimpleTable">
3522
- <xsl:with-param name="id" select="@id"/>
3523
- </xsl:call-template>
3558
+ <xsl:if test="$isGenerateTableIF = 'true' and $isApplyAutolayoutAlgorithm = 'true'">
3559
+ <xsl:call-template name="getSimpleTable">
3560
+ <xsl:with-param name="id" select="@id"/>
3561
+ </xsl:call-template>
3562
+ </xsl:if>
3524
3563
  </xsl:variable>
3525
3564
  <!-- <xsl:variable name="simple-table" select="xalan:nodeset($simple-table_)"/> -->
3526
3565
 
@@ -3616,9 +3655,9 @@
3616
3655
  </xsl:attribute>
3617
3656
  </xsl:for-each>
3618
3657
 
3619
- <xsl:variable name="isNoteOrFnExist" select="./*[local-name()='note'] or ./*[local-name()='example'] or .//*[local-name()='fn'][local-name(..) != 'name'] or ./*[local-name()='source']"/>
3658
+ <xsl:variable name="isNoteOrFnExist" select="./*[local-name()='note'][not(@type = 'units')] or ./*[local-name()='example'] or .//*[local-name()='fn'][local-name(..) != 'name'] or ./*[local-name()='source']"/>
3620
3659
  <xsl:if test="$isNoteOrFnExist = 'true'">
3621
- <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute> <!-- set 0pt border, because there is a separete table below for footer -->
3660
+ <xsl:attribute name="border-bottom">0pt solid black</xsl:attribute><!-- set 0pt border, because there is a separete table below for footer -->
3622
3661
  </xsl:if>
3623
3662
 
3624
3663
  <xsl:choose>
@@ -3750,9 +3789,28 @@
3750
3789
 
3751
3790
  </fo:block>
3752
3791
 
3792
+ <!-- <xsl:if test="$namespace = 'bsi' or $namespace = 'iec' or $namespace = 'iso'"> -->
3793
+ <xsl:if test="$continued = 'true'">
3794
+ <fo:block text-align="right">
3795
+ <xsl:apply-templates select="../*[local-name() = 'note'][@type = 'units']/node()"/>
3796
+ </fo:block>
3797
+ </xsl:if>
3798
+ <!-- </xsl:if> -->
3799
+
3753
3800
  </xsl:if>
3754
3801
  </xsl:template> <!-- table/name -->
3755
3802
 
3803
+ <!-- workaround solution for https://github.com/metanorma/metanorma-iso/issues/1151#issuecomment-2033087938 -->
3804
+ <xsl:template match="*[local-name()='table']/*[local-name() = 'note'][@type = 'units']/*[local-name() = 'p']/text()" priority="4">
3805
+ <xsl:choose>
3806
+ <xsl:when test="preceding-sibling::*[local-name() = 'br']">
3807
+ <!-- remove CR or LF at start -->
3808
+ <xsl:value-of select="java:replaceAll(java:java.lang.String.new(.),'^(&#13;&#10;|&#13;|&#10;)', '')"/>
3809
+ </xsl:when>
3810
+ <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
3811
+ </xsl:choose>
3812
+ </xsl:template>
3813
+
3756
3814
  <!-- SOURCE: ... -->
3757
3815
  <xsl:template match="*[local-name()='table']/*[local-name() = 'source']" priority="2">
3758
3816
  <xsl:call-template name="termsource"/>
@@ -4163,7 +4221,7 @@
4163
4221
  <xsl:param name="colwidths"/>
4164
4222
  <xsl:param name="colgroup"/>
4165
4223
 
4166
- <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'] or ../*[local-name()='example'] or ../*[local-name()='dl'] or ..//*[local-name()='fn'][local-name(..) != 'name'] or ../*[local-name()='source'] or ../*[local-name()='p']"/>
4224
+ <xsl:variable name="isNoteOrFnExist" select="../*[local-name()='note'][not(@type = 'units')] or ../*[local-name()='example'] or ../*[local-name()='dl'] or ..//*[local-name()='fn'][local-name(..) != 'name'] or ../*[local-name()='source'] or ../*[local-name()='p']"/>
4167
4225
 
4168
4226
  <xsl:variable name="isNoteOrFnExistShowAfterTable">
4169
4227
 
@@ -4233,7 +4291,7 @@
4233
4291
 
4234
4292
  <!-- except gb and bsi -->
4235
4293
 
4236
- <xsl:apply-templates select="../*[local-name()='p' or local-name()='dl' or local-name()='note' or local-name()='example' or local-name()='source']"/>
4294
+ <xsl:apply-templates select="../*[local-name()='p' or local-name()='dl' or (local-name()='note' and not(@type = 'units')) or local-name()='example' or local-name()='source']"/>
4237
4295
 
4238
4296
  <xsl:variable name="isDisplayRowSeparator">
4239
4297
 
@@ -4241,7 +4299,7 @@
4241
4299
 
4242
4300
  <!-- horizontal row separator -->
4243
4301
  <xsl:if test="normalize-space($isDisplayRowSeparator) = 'true'">
4244
- <xsl:if test="(../*[local-name()='note'] or ../*[local-name()='example']) and normalize-space($table_fn_block) != ''">
4302
+ <xsl:if test="(../*[local-name()='note'][not(@type = 'units')] or ../*[local-name()='example']) and normalize-space($table_fn_block) != ''">
4245
4303
  <fo:block-container border-top="0.5pt solid black" padding-left="1mm" padding-right="1mm">
4246
4304
 
4247
4305
  <xsl:call-template name="setBordersTableArray"/>
@@ -4921,7 +4979,20 @@
4921
4979
  <!-- Definition List -->
4922
4980
  <!-- ===================== -->
4923
4981
 
4924
- <xsl:template match="*[local-name()='dl']">
4982
+ <!-- for table auto-layout algorithm -->
4983
+ <xsl:template match="*[local-name()='dl']" priority="2">
4984
+ <xsl:choose>
4985
+ <xsl:when test="$table_only_with_id != '' and @id = $table_only_with_id">
4986
+ <xsl:call-template name="dl"/>
4987
+ </xsl:when>
4988
+ <xsl:when test="$table_only_with_id != ''"><fo:block/><!-- to prevent empty fo:block-container --></xsl:when>
4989
+ <xsl:otherwise>
4990
+ <xsl:call-template name="dl"/>
4991
+ </xsl:otherwise>
4992
+ </xsl:choose>
4993
+ </xsl:template>
4994
+
4995
+ <xsl:template match="*[local-name()='dl']" name="dl">
4925
4996
  <xsl:variable name="isAdded" select="@added"/>
4926
4997
  <xsl:variable name="isDeleted" select="@deleted"/>
4927
4998
  <!-- <dl><xsl:copy-of select="."/></dl> -->
@@ -6856,7 +6927,13 @@
6856
6927
  <xsl:value-of select="$language_current_2"/>
6857
6928
  </xsl:when>
6858
6929
  <xsl:otherwise>
6859
- <xsl:value-of select="//*[local-name()='bibdata']//*[local-name()='language']"/>
6930
+ <xsl:variable name="language_current_3" select="normalize-space(//*[local-name()='bibdata']//*[local-name()='language'])"/>
6931
+ <xsl:choose>
6932
+ <xsl:when test="$language_current_3 != ''">
6933
+ <xsl:value-of select="$language_current_3"/>
6934
+ </xsl:when>
6935
+ <xsl:otherwise>en</xsl:otherwise>
6936
+ </xsl:choose>
6860
6937
  </xsl:otherwise>
6861
6938
  </xsl:choose>
6862
6939
  </xsl:otherwise>
@@ -7752,7 +7829,7 @@
7752
7829
  </xsl:when>
7753
7830
  <xsl:otherwise>
7754
7831
  <fo:external-graphic src="{$src}" fox:alt-text="Image {@alt}" xsl:use-attribute-sets="image-graphic-style">
7755
- <xsl:if test="not(@mimetype = 'image/svg+xml') and ../*[local-name() = 'name'] and not(ancestor::*[local-name() = 'table'])">
7832
+ <xsl:if test="not(@mimetype = 'image/svg+xml') and (../*[local-name() = 'name'] or parent::*[local-name() = 'figure'][@unnumbered = 'true']) and not(ancestor::*[local-name() = 'table'])">
7756
7833
 
7757
7834
  <xsl:if test="@width != '' and @width != 'auto' and @width != 'text-width' and @width != 'full-page-width' and @width != 'narrow'">
7758
7835
  <xsl:attribute name="width">
@@ -12888,6 +12965,4 @@
12888
12965
  </xsl:if>
12889
12966
  </xsl:template>
12890
12967
 
12891
- <!-- update -->
12892
-
12893
12968
  </xsl:stylesheet>
@@ -3,14 +3,6 @@ require_relative "../../html2doc/lists"
3
3
  module IsoDoc
4
4
  module JIS
5
5
  class WordConvert < IsoDoc::Iso::WordConvert
6
- def postprocess(result, filename, dir)
7
- filename = filename.sub(/\.doc$/, "")
8
- header = generate_header(filename, dir)
9
- result = from_xhtml(cleanup(to_xhtml(textcleanup(result))))
10
- toWord(result, filename, dir, header)
11
- @files_to_delete.each { |f| FileUtils.rm_f f }
12
- end
13
-
14
6
  def word_cleanup(docxml)
15
7
  word_note_cleanup(docxml)
16
8
  boldface(docxml)
@@ -53,9 +45,12 @@ module IsoDoc
53
45
  end
54
46
  end
55
47
 
48
+ def postprocess_cleanup(result)
49
+ result = cleanup(to_xhtml(textcleanup(result)))
50
+ word_split(word_cleanup(result))
51
+ end
52
+
56
53
  def toWord(result, filename, dir, header)
57
- result = word_split(word_cleanup(to_xhtml(result)))
58
- @wordstylesheet = wordstylesheet_update
59
54
  result.each do |k, v|
60
55
  to_word1(v, "#{filename}#{k}", dir, header)
61
56
  end
@@ -89,11 +84,13 @@ module IsoDoc
89
84
  end
90
85
 
91
86
  def main_split(xml)
92
- c = xml.at("//div[@class = 'WordSection1']")
93
- c.next_element&.remove
94
- c.remove
95
- c = xml.at("//div[@class = 'WordSection2']")
96
- c.elements.first.at("./br") and c.elements.first.remove
87
+ if c = xml.at("//div[@class = 'WordSection1']")
88
+ c.next_element&.remove
89
+ c.remove
90
+ end
91
+ if c = xml.at("//div[@class = 'WordSection2']")
92
+ c.elements.first.at("./br") and c.elements.first.remove
93
+ end
97
94
  xml
98
95
  end
99
96
 
@@ -25,6 +25,20 @@ module IsoDoc
25
25
  l10n("#{title} #{num}<br/>#{obl}")
26
26
  end
27
27
 
28
+ def annex_name_anchors1(clause, num, level)
29
+ @anchors[clause["id"]] =
30
+ { xref: num, label: num, level: level,
31
+ subtype: "annex" }
32
+ end
33
+
34
+ def annex_names1(clause, num, level)
35
+ annex_name_anchors1(clause, num, level)
36
+ i = ::IsoDoc::XrefGen::Counter.new(0, prefix: "#{num}.")
37
+ clause.xpath(ns(SUBCLAUSES)).each do |c|
38
+ annex_names1(c, i.increment(c).print, level + 1)
39
+ end
40
+ end
41
+
28
42
  def clause_order_main(docxml)
29
43
  [
30
44
  { path: "//sections/introduction" },
@@ -97,14 +111,16 @@ module IsoDoc
97
111
  refer_list)
98
112
  c = Counter.new(list["start"] ? list["start"].to_i - 1 : 0)
99
113
  list.xpath(ns("./li")).each do |li|
100
- bare_label, label = list_item_value(li, c, depth,
101
- { list_anchor: list_anchor, prev_label: prev_label, refer_list: refer_list })
114
+ bare_label, label =
115
+ list_item_value(li, c, depth, { list_anchor: list_anchor,
116
+ prev_label: prev_label, refer_list: depth == 1 ? refer_list : nil })
102
117
  li["id"] and @anchors[li["id"]] =
103
118
  { label: bare_label, bare_xref: "#{bare_label})",
104
- xref: "#{label})", type: "listitem", refer_list:
105
- refer_list, container: list_anchor[:container] }
119
+ xref: "#{label})", type: "listitem",
120
+ refer_list: refer_list, container: list_anchor[:container] }
106
121
  (li.xpath(ns(".//ol")) - li.xpath(ns(".//ol//ol"))).each do |ol|
107
- list_item_anchor_names(ol, list_anchor, depth + 1, label, false)
122
+ list_item_anchor_names(ol, list_anchor, depth + 1, label,
123
+ refer_list)
108
124
  end
109
125
  end
110
126
  end
@@ -1,6 +1,6 @@
1
1
  module Metanorma
2
2
  module JIS
3
- VERSION = "0.2.5".freeze
3
+ VERSION = "0.2.6".freeze
4
4
  end
5
5
  end
6
6
 
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
 
33
33
  spec.add_dependency "japanese_calendar", "~> 0"
34
34
  spec.add_dependency "metanorma-iso", "~> 2.7.3"
35
- spec.add_dependency "pubid-jis"
35
+ spec.add_dependency "pubid"
36
36
 
37
37
  spec.add_development_dependency "debug"
38
38
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-jis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-25 00:00:00.000000000 Z
11
+ date: 2024-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: japanese_calendar
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.7.3
41
41
  - !ruby/object:Gem::Dependency
42
- name: pubid-jis
42
+ name: pubid
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="