metanorma-jis 0.5.3 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a6e117f7c38d6edc51ff9dd73cc5b0351e59feb650433e988522cea8cfcf833
4
- data.tar.gz: 7df7f525180c68a19b4ec860876e6bc4cc88f41189c8cf4faf005b97b22479a3
3
+ metadata.gz: 55df8821b6b10d957c78661a28310229a211e2f436fe83a46d40aa62d8bc7f79
4
+ data.tar.gz: 804934a1f4bfb4c2d2a3abad4ea557b5daa7c7eb827484c8a3c5d094f5387e1d
5
5
  SHA512:
6
- metadata.gz: 006ec681b6147de22e10aaf358727baa96fe03eb8527eb620bdaa526db68445e577c89e8ac4c0ffd5fb36b642d59c0e92f79b67ee3640d92459fe617146c07f6
7
- data.tar.gz: 9cc0e00996862955967ccff203e5cbe11fceb2dec7e7b417988e736a741a518015bdadce4894ee42fa67877da013277c96873e70dc729f454fcac6357a731e8b
6
+ metadata.gz: 0bb172cb26ce8d5896cd4efa7111a432e86f9ed7c0c50cfdd26a0f0f60d53e0fd77d6f03dd93d7981920b54b8db151f38cdf6232f8ab5edd6ea0c06704742427
7
+ data.tar.gz: f4fb40e409e343dce9282c43cc0297a692c3221cfbce756c972301de289742489a9788d0821462e2a87e52c9b4358124b5740ba0d7ca8b56a6592045d03c41d3
@@ -89,10 +89,11 @@ module IsoDoc
89
89
  end
90
90
  end
91
91
 
92
- # table name footnote is formatted like other footnotes, since table name
92
+ # table name footnote is formatted like other footnotes, since table name
93
93
  # is a table row.
94
94
  def footnote_parse(node, out)
95
95
  return table_footnote_parse(node, out) if @in_table
96
+
96
97
  super
97
98
  end
98
99
  end
@@ -35,20 +35,6 @@ module IsoDoc
35
35
  }
36
36
  end
37
37
 
38
- # TODO to Presentation XML
39
- # KILL
40
- def make_table_footnote_targetx(out, fnid, fnref)
41
- attrs = { id: fnid, class: "TableFootnoteRef" }
42
- out.span do |s|
43
- # TODO to Presentation XML
44
- s << @i18n.table_footnote
45
- out.span **attrs do |a|
46
- a << fnref
47
- end
48
- insert_tab(s, 1)
49
- end
50
- end
51
-
52
38
  include BaseConvert
53
39
  include Init
54
40
  end
@@ -6267,6 +6267,7 @@
6267
6267
  </xsl:template> <!-- refine_table-style -->
6268
6268
 
6269
6269
  <xsl:attribute-set name="table-name-style">
6270
+ <xsl:attribute name="role">Caption</xsl:attribute>
6270
6271
  <xsl:attribute name="keep-with-next">always</xsl:attribute>
6271
6272
 
6272
6273
  <xsl:attribute name="text-align">center</xsl:attribute>
@@ -6276,6 +6277,9 @@
6276
6277
 
6277
6278
  <xsl:template name="refine_table-name-style">
6278
6279
  <xsl:param name="continued"/>
6280
+ <xsl:if test="$continued = 'true'">
6281
+ <xsl:attribute name="role">SKIP</xsl:attribute>
6282
+ </xsl:if>
6279
6283
 
6280
6284
  <xsl:if test="not($vertical_layout = 'true')">
6281
6285
  <xsl:attribute name="font-family">IPAexGothic</xsl:attribute>
@@ -8147,7 +8151,7 @@
8147
8151
  </xsl:if>
8148
8152
 
8149
8153
  </fo:block-container>
8150
- </xsl:variable>
8154
+ </xsl:variable> <!-- END: variable name="table" -->
8151
8155
 
8152
8156
  <xsl:variable name="isAdded" select="@added"/>
8153
8157
  <xsl:variable name="isDeleted" select="@deleted"/>
@@ -8157,14 +8161,14 @@
8157
8161
 
8158
8162
  <!-- centered table when table name is centered (see table-name-style) -->
8159
8163
 
8160
- <fo:table table-layout="fixed" width="100%" xsl:use-attribute-sets="table-container-style">
8164
+ <fo:table table-layout="fixed" width="100%" xsl:use-attribute-sets="table-container-style" role="SKIP">
8161
8165
 
8162
8166
  <fo:table-column column-width="proportional-column-width(1)"/>
8163
8167
  <fo:table-column column-width="{@width}"/>
8164
8168
  <fo:table-column column-width="proportional-column-width(1)"/>
8165
- <fo:table-body>
8166
- <fo:table-row>
8167
- <fo:table-cell column-number="2">
8169
+ <fo:table-body role="SKIP">
8170
+ <fo:table-row role="SKIP">
8171
+ <fo:table-cell column-number="2" role="SKIP">
8168
8172
  <xsl:copy-of select="$table-preamble"/>
8169
8173
  <fo:block role="SKIP">
8170
8174
  <xsl:call-template name="setTrackChangesStyles">
@@ -8205,11 +8209,12 @@
8205
8209
 
8206
8210
  </xsl:template>
8207
8211
 
8212
+ <!-- table/name-->
8208
8213
  <xsl:template match="*[local-name()='table']/*[local-name() = 'name']">
8209
8214
  <xsl:param name="continued"/>
8210
8215
  <xsl:if test="normalize-space() != ''">
8211
8216
 
8212
- <fo:block xsl:use-attribute-sets="table-name-style" role="SKIP">
8217
+ <fo:block xsl:use-attribute-sets="table-name-style">
8213
8218
 
8214
8219
  <xsl:call-template name="refine_table-name-style">
8215
8220
  <xsl:with-param name="continued" select="$continued"/>
@@ -8686,7 +8691,7 @@
8686
8691
 
8687
8692
  <xsl:variable name="tableWithNotesAndFootnotes">
8688
8693
 
8689
- <fo:table keep-with-previous="always">
8694
+ <fo:table keep-with-previous="always" role="SKIP">
8690
8695
  <xsl:for-each select="xalan:nodeset($table_attributes)/table_attributes/@*">
8691
8696
  <xsl:variable name="name" select="local-name()"/>
8692
8697
  <xsl:choose>
@@ -8717,9 +8722,9 @@
8717
8722
  </xsl:otherwise>
8718
8723
  </xsl:choose>
8719
8724
 
8720
- <fo:table-body>
8721
- <fo:table-row>
8722
- <fo:table-cell xsl:use-attribute-sets="table-footer-cell-style" number-columns-spanned="{$cols-count}">
8725
+ <fo:table-body role="SKIP">
8726
+ <fo:table-row role="SKIP">
8727
+ <fo:table-cell xsl:use-attribute-sets="table-footer-cell-style" number-columns-spanned="{$cols-count}" role="SKIP">
8723
8728
 
8724
8729
  <xsl:call-template name="refine_table-footer-cell-style"/>
8725
8730
 
@@ -9114,6 +9119,7 @@
9114
9119
  <!-- footnotes in text (title, bibliography, main body), not for tables, figures and names --> <!-- table's, figure's names -->
9115
9120
  <!-- fn in text -->
9116
9121
  <xsl:template match="*[local-name() = 'fn'][not(ancestor::*[(local-name() = 'table' or local-name() = 'figure')] and not(ancestor::*[local-name() = 'name']))]" priority="2" name="fn">
9122
+ <xsl:param name="footnote_body_from_table">false</xsl:param>
9117
9123
 
9118
9124
  <!-- list of unique footnotes -->
9119
9125
  <xsl:variable name="p_fn_">
@@ -9212,7 +9218,7 @@
9212
9218
  <xsl:copy-of select="$footnote_inline"/>
9213
9219
  </xsl:when>
9214
9220
  <!-- <xsl:when test="$footnotes//*[local-name() = 'fmt-fn-body'][@id = $ref_id] or normalize-space(@skip_footnote_body) = 'false'"> -->
9215
- <xsl:when test="$p_fn//fn[@gen_id = $gen_id] or normalize-space(@skip_footnote_body) = 'false'">
9221
+ <xsl:when test="$p_fn//fn[@gen_id = $gen_id] or normalize-space(@skip_footnote_body) = 'false' or $footnote_body_from_table = 'true'">
9216
9222
 
9217
9223
  <fo:footnote xsl:use-attribute-sets="fn-style" role="SKIP">
9218
9224
  <xsl:copy-of select="$footnote_inline"/>
@@ -9691,39 +9697,51 @@
9691
9697
  <!-- fn reference in the table rendering (for instance, 'some text 1) some text' ) -->
9692
9698
  <!-- fn --> <!-- in table --> <!-- for figure see <xsl:template match="*[local-name() = 'figure']/*[local-name() = 'fn']" priority="2"/> -->
9693
9699
  <xsl:template match="*[local-name()='fn']">
9694
- <fo:inline xsl:use-attribute-sets="fn-reference-style">
9695
-
9696
- <xsl:call-template name="refine_fn-reference-style"/>
9700
+ <xsl:variable name="target" select="@target"/>
9701
+ <xsl:choose>
9702
+ <!-- case for footnotes in Requirement tables (https://github.com/metanorma/metanorma-ogc/issues/791) -->
9703
+ <xsl:when test="not(ancestor::*[local-name() = 'table'][1]/*[local-name() = 'fmt-footnote-container']/*[local-name() = 'fmt-fn-body'][@id = $target]) and $footnotes/*[local-name() = 'fmt-fn-body'][@id = $target]">
9704
+ <xsl:call-template name="fn">
9705
+ <xsl:with-param name="footnote_body_from_table">true</xsl:with-param>
9706
+ </xsl:call-template>
9707
+ </xsl:when>
9708
+ <xsl:otherwise>
9697
9709
 
9698
- <!-- <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="footnote {@reference}"> --> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
9699
- <fo:basic-link internal-destination="{@target}" fox:alt-text="footnote {@reference}">
9700
- <!-- <xsl:if test="ancestor::*[local-name()='table'][1]/@id"> --> <!-- for footnotes in tables -->
9701
- <!-- <xsl:attribute name="internal-destination">
9702
- <xsl:value-of select="concat(@reference, '_', ancestor::*[local-name()='table'][1]/@id)"/>
9703
- </xsl:attribute>
9704
- </xsl:if>
9705
- <xsl:if test="$namespace = 'ogc' or $namespace = 'ogc-white-paper'">
9706
- <xsl:attribute name="internal-destination">
9707
- <xsl:value-of select="@reference"/><xsl:text>_</xsl:text>
9708
- <xsl:value-of select="ancestor::*[local-name()='table'][1]/@id"/>
9709
- </xsl:attribute>
9710
- </xsl:if> -->
9711
- <!-- <xsl:if test="$namespace = 'plateau'">
9712
- <xsl:text>※</xsl:text>
9713
- </xsl:if> -->
9714
- <!-- <xsl:value-of select="@reference"/> -->
9710
+ <fo:inline xsl:use-attribute-sets="fn-reference-style">
9715
9711
 
9716
- <xsl:value-of select="normalize-space(*[local-name() = 'fmt-fn-label'])"/>
9712
+ <xsl:call-template name="refine_fn-reference-style"/>
9717
9713
 
9718
- <!-- <xsl:if test="$namespace = 'bsi'">
9719
- <xsl:text>)</xsl:text>
9720
- </xsl:if> -->
9721
- <!-- commented, https://github.com/metanorma/isodoc/issues/614 -->
9722
- <!-- <xsl:if test="$namespace = 'jis'">
9723
- <fo:inline font-weight="normal">)</fo:inline>
9724
- </xsl:if> -->
9725
- </fo:basic-link>
9726
- </fo:inline>
9714
+ <!-- <fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="footnote {@reference}"> --> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
9715
+ <fo:basic-link internal-destination="{@target}" fox:alt-text="footnote {@reference}">
9716
+ <!-- <xsl:if test="ancestor::*[local-name()='table'][1]/@id"> --> <!-- for footnotes in tables -->
9717
+ <!-- <xsl:attribute name="internal-destination">
9718
+ <xsl:value-of select="concat(@reference, '_', ancestor::*[local-name()='table'][1]/@id)"/>
9719
+ </xsl:attribute>
9720
+ </xsl:if>
9721
+ <xsl:if test="$namespace = 'ogc' or $namespace = 'ogc-white-paper'">
9722
+ <xsl:attribute name="internal-destination">
9723
+ <xsl:value-of select="@reference"/><xsl:text>_</xsl:text>
9724
+ <xsl:value-of select="ancestor::*[local-name()='table'][1]/@id"/>
9725
+ </xsl:attribute>
9726
+ </xsl:if> -->
9727
+ <!-- <xsl:if test="$namespace = 'plateau'">
9728
+ <xsl:text>※</xsl:text>
9729
+ </xsl:if> -->
9730
+ <!-- <xsl:value-of select="@reference"/> -->
9731
+
9732
+ <xsl:value-of select="normalize-space(*[local-name() = 'fmt-fn-label'])"/>
9733
+
9734
+ <!-- <xsl:if test="$namespace = 'bsi'">
9735
+ <xsl:text>)</xsl:text>
9736
+ </xsl:if> -->
9737
+ <!-- commented, https://github.com/metanorma/isodoc/issues/614 -->
9738
+ <!-- <xsl:if test="$namespace = 'jis'">
9739
+ <fo:inline font-weight="normal">)</fo:inline>
9740
+ </xsl:if> -->
9741
+ </fo:basic-link>
9742
+ </fo:inline>
9743
+ </xsl:otherwise>
9744
+ </xsl:choose>
9727
9745
  </xsl:template> <!-- fn -->
9728
9746
 
9729
9747
  <!-- fn/text() -->
@@ -13762,6 +13780,13 @@
13762
13780
  <xsl:apply-templates select="."/>
13763
13781
  </xsl:template>
13764
13782
 
13783
+ <!-- prevent missing stem for table and figures in ToC -->
13784
+ <xsl:template match="*[local-name() = 'name' or local-name() = 'fmt-name']//*[local-name() = 'stem']" mode="contents">
13785
+ <xsl:if test="not(following-sibling::*[1][local-name() = 'fmt-stem'])">
13786
+ <xsl:apply-templates select="."/>
13787
+ </xsl:if>
13788
+ </xsl:template>
13789
+
13765
13790
  <xsl:template match="*[local-name() = 'references'][@hidden='true']" mode="contents" priority="3"/>
13766
13791
 
13767
13792
  <xsl:template match="*[local-name() = 'references']/*[local-name() = 'bibitem']" mode="contents"/>
@@ -13985,7 +14010,8 @@
13985
14010
 
13986
14011
  <xsl:for-each select="$contents_nodes//tables/table">
13987
14012
  <fo:bookmark internal-destination="{@id}">
13988
- <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title>
14013
+ <!-- <fo:bookmark-title><xsl:value-of select="normalize-space(.)"/></fo:bookmark-title> -->
14014
+ <fo:bookmark-title><xsl:apply-templates mode="bookmark_clean"/></fo:bookmark-title>
13989
14015
  </fo:bookmark>
13990
14016
  </xsl:for-each>
13991
14017
  </fo:bookmark>
@@ -13994,6 +14020,26 @@
13994
14020
  </xsl:template> <!-- insertTableBookmarks -->
13995
14021
  <!-- End Bookmarks -->
13996
14022
 
14023
+ <!-- ============================ -->
14024
+ <!-- mode="bookmark_clean" -->
14025
+ <!-- ============================ -->
14026
+ <xsl:template match="node()" mode="bookmark_clean">
14027
+ <xsl:apply-templates select="node()" mode="bookmark_clean"/>
14028
+ </xsl:template>
14029
+
14030
+ <xsl:template match="text()" mode="bookmark_clean">
14031
+ <xsl:value-of select="."/>
14032
+ </xsl:template>
14033
+
14034
+ <xsl:template match="*[local-name() = 'math']" mode="bookmark_clean">
14035
+ <xsl:value-of select="normalize-space(.)"/>
14036
+ </xsl:template>
14037
+
14038
+ <xsl:template match="*[local-name() = 'asciimath']" mode="bookmark_clean"/>
14039
+ <!-- ============================ -->
14040
+ <!-- END: mode="bookmark_clean" -->
14041
+ <!-- ============================ -->
14042
+
13997
14043
  <xsl:template name="getLangVersion">
13998
14044
  <xsl:param name="lang"/>
13999
14045
  <xsl:param name="doctype" select="''"/>
@@ -15961,9 +16007,15 @@
15961
16007
  <xsl:when test="local-name(..) = 'ul'">
15962
16008
  <xsl:choose>
15963
16009
  <xsl:when test="normalize-space($processing_instruction_type) = 'simple'"/>
16010
+ <!-- https://github.com/metanorma/isodoc/issues/675 -->
16011
+ <xsl:when test="@label"><xsl:value-of select="@label"/></xsl:when>
15964
16012
  <xsl:otherwise><xsl:call-template name="setULLabel"/></xsl:otherwise>
15965
16013
  </xsl:choose>
15966
16014
  </xsl:when>
16015
+ <!-- https://github.com/metanorma/isodoc/issues/675 -->
16016
+ <xsl:when test="local-name(..) = 'ol' and @label and @full = 'true'"> <!-- @full added in the template li/fmt-name -->
16017
+ <xsl:value-of select="@label"/>
16018
+ </xsl:when>
15967
16019
  <xsl:when test="local-name(..) = 'ol' and @label"> <!-- for ordered lists 'ol', and if there is @label, for instance label="1.1.2" -->
15968
16020
 
15969
16021
  <xsl:variable name="type" select="../@type"/>
@@ -16088,7 +16140,7 @@
16088
16140
 
16089
16141
  </xsl:otherwise>
16090
16142
  </xsl:choose>
16091
- </xsl:template>
16143
+ </xsl:template> <!-- getListItemFormat -->
16092
16144
 
16093
16145
  <xsl:template match="*[local-name() = 'ul'] | *[local-name() = 'ol']">
16094
16146
  <xsl:param name="indent">0</xsl:param>
@@ -16245,6 +16297,11 @@
16245
16297
 
16246
16298
  <xsl:call-template name="refine_list-item-label-style"/>
16247
16299
 
16300
+ <xsl:if test="local-name(..) = 'ul'">
16301
+ <xsl:variable name="li_label" select="@label"/>
16302
+ <xsl:copy-of select="$ul_labels//label[. = $li_label]/@*[not(local-name() = 'level')]"/>
16303
+ </xsl:if>
16304
+
16248
16305
  <!-- if 'p' contains all text in 'add' first and last elements in first p are 'add' -->
16249
16306
  <xsl:if test="*[1][count(node()[normalize-space() != '']) = 1 and *[local-name() = 'add']]">
16250
16307
  <xsl:call-template name="append_add-style"/>
@@ -17661,6 +17718,16 @@
17661
17718
  </xsl:choose>
17662
17719
  </xsl:template>
17663
17720
 
17721
+ <!-- li/fmt-name -->
17722
+ <xsl:template match="*[local-name() = 'li']/*[local-name() = 'fmt-name']" priority="2" mode="update_xml_step1">
17723
+ <xsl:attribute name="label"><xsl:value-of select="."/></xsl:attribute>
17724
+ <xsl:attribute name="full">true</xsl:attribute>
17725
+ </xsl:template>
17726
+ <xsl:template match="*[local-name() = 'li']/*[local-name() = 'fmt-name']" priority="2" mode="update_xml_pres">
17727
+ <xsl:attribute name="label"><xsl:value-of select="."/></xsl:attribute>
17728
+ <xsl:attribute name="full">true</xsl:attribute>
17729
+ </xsl:template>
17730
+
17664
17731
  <xsl:template match="*[local-name() = 'fmt-preferred']"/>
17665
17732
  <xsl:template match="*[local-name() = 'fmt-preferred'][*[local-name() = 'p']]" mode="update_xml_step1">
17666
17733
  <xsl:apply-templates mode="update_xml_step1"/>
@@ -18582,6 +18649,64 @@
18582
18649
  <fo:inline xml:lang="none"><xsl:value-of select="."/></fo:inline>
18583
18650
  </xsl:template>
18584
18651
 
18652
+ <!-- ===================================== -->
18653
+ <!-- ===================================== -->
18654
+ <!-- Ruby text (CJK languages) rendering -->
18655
+ <!-- ===================================== -->
18656
+ <!-- ===================================== -->
18657
+ <xsl:template match="*[local-name() = 'ruby']">
18658
+ <fo:inline-container text-indent="0mm" last-line-end-indent="0mm">
18659
+ <xsl:if test="not(ancestor::*[local-name() = 'ruby'])">
18660
+ <xsl:attribute name="alignment-baseline">central</xsl:attribute>
18661
+ </xsl:if>
18662
+ <xsl:variable name="rt_text" select="*[local-name() = 'rt']"/>
18663
+ <xsl:variable name="rb_text" select=".//*[local-name() = 'rb'][not(*[local-name() = 'ruby'])]"/>
18664
+ <!-- Example: width="2em" -->
18665
+ <xsl:variable name="text_rt_width" select="java:org.metanorma.fop.Util.getStringWidthByFontSize($rt_text, $font_main, 6)"/>
18666
+ <xsl:variable name="text_rb_width" select="java:org.metanorma.fop.Util.getStringWidthByFontSize($rb_text, $font_main, 10)"/>
18667
+ <xsl:variable name="text_width">
18668
+ <xsl:choose>
18669
+ <xsl:when test="$text_rt_width &gt;= $text_rb_width"><xsl:value-of select="$text_rt_width"/></xsl:when>
18670
+ <xsl:otherwise><xsl:value-of select="$text_rb_width"/></xsl:otherwise>
18671
+ </xsl:choose>
18672
+ </xsl:variable>
18673
+ <xsl:attribute name="width"><xsl:value-of select="$text_width div 10"/>em</xsl:attribute>
18674
+
18675
+ <xsl:choose>
18676
+ <xsl:when test="ancestor::*[local-name() = 'ruby']">
18677
+ <xsl:apply-templates select="*[local-name() = 'rb']"/>
18678
+ <xsl:apply-templates select="*[local-name() = 'rt']"/>
18679
+ </xsl:when>
18680
+ <xsl:otherwise>
18681
+ <xsl:apply-templates select="*[local-name() = 'rt']"/>
18682
+ <xsl:apply-templates select="*[local-name() = 'rb']"/>
18683
+ </xsl:otherwise>
18684
+ </xsl:choose>
18685
+
18686
+ <xsl:apply-templates select="node()[not(local-name() = 'rt') and not(local-name() = 'rb')]"/>
18687
+ </fo:inline-container>
18688
+ </xsl:template>
18689
+
18690
+ <xsl:template match="*[local-name() = 'rb']">
18691
+ <fo:block line-height="1em" text-align="center"><xsl:apply-templates/></fo:block>
18692
+ </xsl:template>
18693
+
18694
+ <xsl:template match="*[local-name() = 'rt']">
18695
+ <fo:block font-size="0.5em" text-align="center" line-height="1.2em" space-before="-1.4em" space-before.conditionality="retain"> <!-- -->
18696
+ <xsl:if test="ancestor::*[local-name() = 'ruby'][last()]//*[local-name() = 'ruby'] or ancestor::*[local-name() = 'rb']">
18697
+ <xsl:attribute name="space-before">0em</xsl:attribute>
18698
+ </xsl:if>
18699
+ <xsl:apply-templates/>
18700
+ </fo:block>
18701
+
18702
+ </xsl:template>
18703
+
18704
+ <!-- ===================================== -->
18705
+ <!-- ===================================== -->
18706
+ <!-- END: Ruby text (CJK languages) rendering -->
18707
+ <!-- ===================================== -->
18708
+ <!-- ===================================== -->
18709
+
18585
18710
  <xsl:template name="printEdition">
18586
18711
  <xsl:variable name="edition_i18n" select="normalize-space((//*[local-name() = 'metanorma'])[1]/*[local-name() = 'bibdata']/*[local-name() = 'edition'][normalize-space(@language) != ''])"/>
18587
18712
 
@@ -0,0 +1,72 @@
1
+ module IsoDoc
2
+ module Jis
3
+ class PresentationXMLConvert < IsoDoc::Iso::PresentationXMLConvert
4
+ def ol_depth(node)
5
+ depth == 1 and return :alphabet
6
+ :arabic
7
+ end
8
+
9
+ def ol_depth(node)
10
+ depth = node.ancestors("ol").size + 1
11
+ @counter.ol_type(node, depth) # defined in Xref::Counter
12
+ end
13
+
14
+ def ul_label_list(_elem)
15
+ %w(&#xFF0D; &#x30FB;)
16
+ end
17
+
18
+ def ul_label_value(elem)
19
+ depth = elem.ancestors("ul").size
20
+ val = ul_label_list(elem)
21
+ val[(depth - 1) % val.size]
22
+ end
23
+
24
+ # TODO: move the table/figure key processing to Word, not Presentation XML
25
+ def dl(docxml)
26
+ super
27
+ docxml.xpath(ns("//table//dl | //figure//dl")).each do |l|
28
+ l.at(ns("./dl")) || l.at("./ancestor::xmlns:dl") and next
29
+ dl_to_para(l)
30
+ end
31
+ end
32
+
33
+ def dt_dd?(node)
34
+ %w{dt dd}.include? node.name
35
+ end
36
+
37
+ def dl_to_para(node)
38
+ ret = dl_to_para_name(node)
39
+ ret += dl_to_para_terms(node)
40
+ node.elements.reject { |n| %w(dt dd name fmt-name).include?(n.name) }
41
+ .each do |x|
42
+ ret += x.to_xml
43
+ end
44
+ dl_id_insert(node, ret)
45
+ end
46
+
47
+ def dl_id_insert(node, ret)
48
+ a = node.replace(ret)
49
+ p = a.at("./descendant-or-self::xmlns:p")
50
+ node["id"] and p << "<bookmark id='#{node['id']}'/>"
51
+ a.xpath("./descendant-or-self::*[@id = '']").each { |x| x.delete("id") }
52
+ end
53
+
54
+ def dl_to_para_name(node)
55
+ e = node.at(ns("./fmt-name")) or return ""
56
+ node.parent.parent["type"] == "participants" and return ""
57
+ "<p class='ListTitle'>#{e.children.to_xml}</p>"
58
+ end
59
+
60
+ def dl_to_para_terms(node)
61
+ ret = ""
62
+ node.elements.select { |n| dt_dd?(n) }.each_slice(2) do |dt, dd|
63
+ term = strip_para(dt)
64
+ defn = strip_para(dd)
65
+ bkmk = dd["id"] ? "<bookmark id='#{dd['id']}'/>" : ""
66
+ ret += "<p class='dl' id='#{dt['id']}'>#{term}: #{bkmk}#{defn}</p>"
67
+ end
68
+ ret
69
+ end
70
+ end
71
+ end
72
+ end
@@ -1,6 +1,7 @@
1
1
  require_relative "init"
2
2
  require "isodoc"
3
3
  require_relative "presentation_section"
4
+ require_relative "presentation_list"
4
5
  require_relative "../../relaton/render-jis/general"
5
6
 
6
7
  module IsoDoc
@@ -35,65 +36,12 @@ module IsoDoc
35
36
  ret
36
37
  end
37
38
 
38
- def ol_depth(node)
39
- depth = node.ancestors("ol").size + 1
40
- depth == 1 and return :alphabet
41
- :arabic
42
- end
43
-
44
39
  def admits(elem)
45
40
  elem.xpath(ns(".//semx[@element = 'admitted']")).each do |t|
46
41
  t.previous = @i18n.l10n("#{@i18n.admitted}: ")
47
42
  end
48
43
  end
49
44
 
50
- # TODO: move the table/figure key processing to Word, not Presentation XML
51
- def dl(docxml)
52
- super
53
- docxml.xpath(ns("//table//dl | //figure//dl")).each do |l|
54
- l.at(ns("./dl")) || l.at("./ancestor::xmlns:dl") and next
55
- dl_to_para(l)
56
- end
57
- end
58
-
59
- def dt_dd?(node)
60
- %w{dt dd}.include? node.name
61
- end
62
-
63
- def dl_to_para(node)
64
- ret = dl_to_para_name(node)
65
- ret += dl_to_para_terms(node)
66
- node.elements.reject { |n| %w(dt dd name fmt-name).include?(n.name) }
67
- .each do |x|
68
- ret += x.to_xml
69
- end
70
- dl_id_insert(node, ret)
71
- end
72
-
73
- def dl_id_insert(node, ret)
74
- a = node.replace(ret)
75
- p = a.at("./descendant-or-self::xmlns:p")
76
- node["id"] and p << "<bookmark id='#{node['id']}'/>"
77
- a.xpath("./descendant-or-self::*[@id = '']").each { |x| x.delete("id") }
78
- end
79
-
80
- def dl_to_para_name(node)
81
- e = node.at(ns("./fmt-name")) or return ""
82
- node.parent.parent["type"] == "participants" and return ""
83
- "<p class='ListTitle'>#{e.children.to_xml}</p>"
84
- end
85
-
86
- def dl_to_para_terms(node)
87
- ret = ""
88
- node.elements.select { |n| dt_dd?(n) }.each_slice(2) do |dt, dd|
89
- term = strip_para(dt)
90
- defn = strip_para(dd)
91
- bkmk = dd["id"] ? "<bookmark id='#{dd['id']}'/>" : ""
92
- ret += "<p class='dl' id='#{dt['id']}'>#{term}: #{bkmk}#{defn}</p>"
93
- end
94
- ret
95
- end
96
-
97
45
  def strip_para(node)
98
46
  node.children.to_xml.gsub(%r{</?p( [^>]*)?>}, "")
99
47
  end
@@ -1,18 +1,6 @@
1
1
  module IsoDoc
2
2
  module Jis
3
3
  class WordConvert < IsoDoc::Iso::WordConvert
4
- # KILL
5
- def make_table_footnote_targetx(out, fnid, fnref)
6
- attrs = { id: fnid, class: "TableFootnoteRef" }
7
- out.span do |s|
8
- s << @i18n.table_footnote
9
- out.span **attrs do |a|
10
- a << fnref.sub(/(?!<\))$/, ")") # TODO TO Presentation XML
11
- end
12
- insert_tab(s, 1)
13
- end
14
- end
15
-
16
4
  def table_title_parse(node, out); end
17
5
 
18
6
  def table_attrs(node)
@@ -109,26 +109,6 @@ module IsoDoc
109
109
  end
110
110
  end
111
111
 
112
- # KILL
113
- def footnote_parsex(node, out)
114
- return table_footnote_parse(node, out) if @in_table || @in_figure # &&
115
-
116
- fn = node["reference"] || UUIDTools::UUID.random_create.to_s
117
- return seen_footnote_parse(node, out, fn) if @seen_footnote.include?(fn)
118
-
119
- @fn_bookmarks[fn] = bookmarkid
120
- out.span style: "mso-bookmark:_Ref#{@fn_bookmarks[fn]}" do |s|
121
- s.a class: "FootnoteRef", "epub:type": "footnote",
122
- href: "#ftn#{fn}" do |a|
123
- a.sup { |sup| sup << fn }
124
- end
125
- end
126
- @in_footnote = true
127
- @footnotes << make_generic_footnote_text(node, fn)
128
- @in_footnote = false
129
- @seen_footnote << fn
130
- end
131
-
132
112
  def annex(node, out)
133
113
  node["commentary"] == "true" and return commentary(node, out)
134
114
  amd?(node.document.root) and