Skip to content

Commit

Permalink
Merge pull request #750 from metanorma/pdf_ua1
Browse files Browse the repository at this point in the history
PDF UA1
  • Loading branch information
Intelligent2013 authored Oct 2, 2024
2 parents b8acbc3 + a632cc8 commit bf2f0bc
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 92 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/verapdfcheck.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: verapdfcheck

on: pull_request
on:
push:
branches:
- master
pull_request:

jobs:
check:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ XSLT_GENERATED := xslt/iec.international-standard.xsl \
xslt/bipm.rapport.xsl \
xslt/jcgm.standard.xsl

MN2PDF_DOWNLOAD_PATH := https://github.com/metanorma/mn2pdf/releases/download/v2.02/mn2pdf-2.02.jar
MN2PDF_DOWNLOAD_PATH := https://github.com/metanorma/mn2pdf/releases/download/v2.03/mn2pdf-2.03.jar
# MN2PDF_DOWNLOAD_PATH := https://maven.pkg.github.com/metanorma/mn2pdf/com/metanorma/fop/mn2pdf/1.7/mn2pdf-1.7.jar
MN2PDF_EXECUTABLE := $(notdir $(MN2PDF_DOWNLOAD_PATH))

Expand Down
76 changes: 40 additions & 36 deletions xslt_src/cc.standard.core.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -371,21 +371,21 @@

<xsl:template name="insertListOf_Item">
<fo:block role="TOCI">
<fo:list-block provisional-distance-between-starts="8mm">
<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:list-block provisional-distance-between-starts="8mm" role="SKIP">
<fo:list-item role="SKIP">
<fo:list-item-label end-indent="label-end()" role="SKIP">
<fo:block></fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block text-align-last="justify" margin-left="12mm" text-indent="-12mm">
<fo:list-item-body start-indent="body-start()" role="SKIP">
<fo:block text-align-last="justify" margin-left="12mm" text-indent="-12mm" role="SKIP">
<fo:basic-link internal-destination="{@id}">
<xsl:call-template name="setAltText">
<xsl:with-param name="value" select="@alt-text"/>
</xsl:call-template>
<xsl:apply-templates select="." mode="contents"/>
<fo:inline keep-together.within-line="always">
<fo:inline keep-together.within-line="always" role="SKIP">
<fo:leader leader-pattern="dots"/>
<fo:inline><fo:page-number-citation ref-id="{@id}"/></fo:inline>
<fo:inline role="SKIP"><fo:wrapper role="artifact"><fo:page-number-citation ref-id="{@id}"/></fo:wrapper></fo:inline>
</fo:inline>
</fo:basic-link>
</fo:block>
Expand All @@ -396,10 +396,12 @@
</xsl:template>

<xsl:template match="csd:preface//csd:clause[@type = 'toc']" priority="3">
<fo:block-container font-weight="bold" line-height="115%">
<fo:block-container font-weight="bold" line-height="115%" role="SKIP">
<!-- render 'Contents' outside if role="TOC" -->
<xsl:apply-templates select="*[local-name() = 'title']"/>
<fo:block role="TOC">

<xsl:apply-templates />
<xsl:apply-templates select="node()[not(local-name() = 'title')]"/>

<xsl:if test="count(*) = 1 and *[local-name() = 'title']"> <!-- if there isn't user ToC -->

Expand All @@ -410,33 +412,35 @@
<xsl:attribute name="margin-top">6pt</xsl:attribute>
</xsl:if>

<fo:list-block>
<xsl:attribute name="provisional-distance-between-starts">
<xsl:choose>
<!-- skip 0 section without subsections -->
<xsl:when test="@section != ''">8mm</xsl:when> <!-- and not(@display-section = 'false') -->
<xsl:otherwise>0mm</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block>
<xsl:value-of select="@section"/>
</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block text-align-last="justify" margin-left="12mm" text-indent="-12mm">
<fo:basic-link internal-destination="{@id}" fox:alt-text="{title}">
<xsl:apply-templates select="title"/>
<fo:inline keep-together.within-line="always">
<fo:leader leader-pattern="dots"/>
<fo:inline><fo:page-number-citation ref-id="{@id}"/></fo:inline>
</fo:inline>
</fo:basic-link>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
<fo:basic-link internal-destination="{@id}" fox:alt-text="{@section} {title}"> <!-- link at this level needs for PDF structure tags -->
<fo:list-block role="SKIP">
<xsl:attribute name="provisional-distance-between-starts">
<xsl:choose>
<!-- skip 0 section without subsections -->
<xsl:when test="@section != ''">8mm</xsl:when> <!-- and not(@display-section = 'false') -->
<xsl:otherwise>0mm</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<fo:list-item role="SKIP">
<fo:list-item-label end-indent="label-end()" role="SKIP">
<fo:block role="SKIP" id="__internal_layout__toc_label_{@id}">
<xsl:value-of select="@section"/>
</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()" role="SKIP">
<fo:block text-align-last="justify" margin-left="12mm" text-indent="-12mm" role="SKIP">
<fo:basic-link internal-destination="{@id}" fox:alt-text="{title}" role="SKIP">
<xsl:apply-templates select="title"/>
<fo:inline keep-together.within-line="always" role="SKIP">
<fo:leader leader-pattern="dots"/>
<fo:inline role="SKIP"><fo:wrapper role="artifact"><fo:page-number-citation ref-id="{@id}"/></fo:wrapper></fo:inline>
</fo:inline>
</fo:basic-link>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</fo:basic-link>
</fo:block>
</xsl:for-each>

Expand Down
28 changes: 22 additions & 6 deletions xslt_src/common.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -9065,8 +9065,10 @@

<xsl:call-template name="insert_basic_link">
<xsl:with-param name="element">
<fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}" role="Lbl">
<xsl:copy-of select="$current_fn_number_text"/>
<fo:basic-link internal-destination="{$ref_id}" fox:alt-text="footnote {$current_fn_number}"> <!-- note: role="Lbl" removed in https://github.com/metanorma/mn2pdf/issues/291 -->
<fo:inline role="Lbl"> <!-- need for https://github.com/metanorma/metanorma-iso/issues/1003 -->
<xsl:copy-of select="$current_fn_number_text"/>
</fo:inline>
</fo:basic-link>
</xsl:with-param>
</xsl:call-template>
Expand Down Expand Up @@ -9490,7 +9492,7 @@

<xsl:call-template name="refine_fn-reference-style"/>

<fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="{@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
<fo:basic-link internal-destination="{@reference}_{ancestor::*[@id][1]/@id}" fox:alt-text="footnote {@reference}"> <!-- @reference | ancestor::*[local-name()='clause'][1]/@id-->
<xsl:if test="ancestor::*[local-name()='table'][1]/@id"> <!-- for footnotes in tables -->
<xsl:attribute name="internal-destination">
<xsl:value-of select="concat(@reference, '_', ancestor::*[local-name()='table'][1]/@id)"/>
Expand Down Expand Up @@ -12428,9 +12430,12 @@
<xsl:apply-templates />
</xsl:when>
<xsl:otherwise>
<xsl:variable name="alt_text">
<xsl:call-template name="getAltText"/>
</xsl:variable>
<xsl:call-template name="insert_basic_link">
<xsl:with-param name="element">
<fo:basic-link external-destination="{$target}" fox:alt-text="{$target}">
<fo:basic-link external-destination="{$target}" fox:alt-text="{$alt_text}">
<xsl:if test="$isLinkToEmbeddedFile = 'true'">
<xsl:attribute name="role">Annot</xsl:attribute>
</xsl:if>
Expand All @@ -12457,6 +12462,14 @@
</fo:inline>
</xsl:template> <!-- link -->

<xsl:template name="getAltText">
<xsl:choose>
<xsl:when test="normalize-space(.) = ''"><xsl:value-of select="@target" /></xsl:when>
<xsl:otherwise><xsl:value-of select="normalize-space(translate(normalize-space(), '&#xa0;—', ' -'))"/></xsl:otherwise>
<!-- <xsl:otherwise><xsl:value-of select="@target"/></xsl:otherwise> -->
</xsl:choose>
</xsl:template>

<!-- ======================== -->
<!-- Appendix processing -->
<!-- ======================== -->
Expand Down Expand Up @@ -12488,7 +12501,7 @@
<xsl:template match="*[local-name() = 'callout']">
<xsl:choose>
<xsl:when test="normalize-space(@target) = ''">&lt;<xsl:apply-templates />&gt;</xsl:when>
<xsl:otherwise><fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}">&lt;<xsl:apply-templates />&gt;</fo:basic-link></xsl:otherwise>
<xsl:otherwise><fo:basic-link internal-destination="{@target}" fox:alt-text="{normalize-space()}">&lt;<xsl:apply-templates />&gt;</fo:basic-link></xsl:otherwise>
</xsl:choose>
</xsl:template>

Expand Down Expand Up @@ -12521,7 +12534,10 @@
<xsl:template match="*[local-name() = 'xref']">
<xsl:call-template name="insert_basic_link">
<xsl:with-param name="element">
<fo:basic-link internal-destination="{@target}" fox:alt-text="{@target}" xsl:use-attribute-sets="xref-style">
<xsl:variable name="alt_text">
<xsl:call-template name="getAltText"/>
</xsl:variable>
<fo:basic-link internal-destination="{@target}" fox:alt-text="{$alt_text}" xsl:use-attribute-sets="xref-style">
<xsl:if test="string-length(normalize-space()) &lt; 30 and not(contains(normalize-space(), 'http://')) and not(contains(normalize-space(), 'https://')) and not(ancestor::*[local-name() = 'table' or local-name() = 'dl'])">
<xsl:attribute name="keep-together.within-line">always</xsl:attribute>
</xsl:if>
Expand Down
102 changes: 54 additions & 48 deletions xslt_src/iec.international-standard.core.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -1278,61 +1278,64 @@
<xsl:attribute name="space-before">5pt</xsl:attribute>
</xsl:if>

<fo:list-block>
<xsl:attribute name="margin-left">
<xsl:choose>
<xsl:when test="title/@variant-title = 'true'">0mm</xsl:when>
<xsl:when test="@level = 2">8mm</xsl:when>
<xsl:when test="@level &gt;= 3"><xsl:value-of select="(@level - 2) * 23"/>mm</xsl:when>
<xsl:otherwise>0mm</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="provisional-distance-between-starts">
<xsl:choose>
<xsl:when test="@section = ''">0mm</xsl:when>
<xsl:when test="@level = 1">8mm</xsl:when>
<xsl:when test="@level = 2">15mm</xsl:when>
<xsl:when test="@level &gt;= 3"><xsl:value-of select="(@level - 2) * 19"/>mm</xsl:when>
<xsl:otherwise>0mm</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block>
<xsl:value-of select="@section"/>
</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block text-align-last="justify">
<fo:basic-link internal-destination="{@id}" fox:alt-text="{title}">
<xsl:variable name="title">
<xsl:apply-templates select="title"/>
</xsl:variable>
<xsl:call-template name="addLetterSpacing">
<xsl:with-param name="text" select="$title"/>
</xsl:call-template>
<xsl:text> </xsl:text>
<fo:inline keep-together.within-line="always">
<fo:leader leader-pattern="dots"/>
<fo:inline><fo:page-number-citation ref-id="{@id}"/></fo:inline>
</fo:inline>
</fo:basic-link>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
<fo:basic-link internal-destination="{@id}" fox:alt-text="{@section} {title}"> <!-- link at this level needs for PDF structure tags -->

<fo:list-block role="SKIP">
<xsl:attribute name="margin-left">
<xsl:choose>
<xsl:when test="title/@variant-title = 'true'">0mm</xsl:when>
<xsl:when test="@level = 2">8mm</xsl:when>
<xsl:when test="@level &gt;= 3"><xsl:value-of select="(@level - 2) * 23"/>mm</xsl:when>
<xsl:otherwise>0mm</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="provisional-distance-between-starts">
<xsl:choose>
<xsl:when test="@section = ''">0mm</xsl:when>
<xsl:when test="@level = 1">8mm</xsl:when>
<xsl:when test="@level = 2">15mm</xsl:when>
<xsl:when test="@level &gt;= 3"><xsl:value-of select="(@level - 2) * 19"/>mm</xsl:when>
<xsl:otherwise>0mm</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<fo:list-item role="SKIP">
<fo:list-item-label end-indent="label-end()" role="SKIP">
<fo:block>
<xsl:value-of select="@section"/>
</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()" role="SKIP">
<fo:block text-align-last="justify" role="SKIP">
<fo:basic-link internal-destination="{@id}" fox:alt-text="{title}" role="SKIP">
<xsl:variable name="title">
<xsl:apply-templates select="title"/>
</xsl:variable>
<xsl:call-template name="addLetterSpacing">
<xsl:with-param name="text" select="$title"/>
</xsl:call-template>
<xsl:text> </xsl:text>
<fo:inline keep-together.within-line="always" role="SKIP">
<fo:leader leader-pattern="dots"/>
<fo:inline role="SKIP"><fo:wrapper role="artifact"><fo:page-number-citation ref-id="{@id}"/></fo:wrapper></fo:inline>
</fo:inline>
</fo:basic-link>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</fo:basic-link>
</fo:block>
</xsl:for-each>

<xsl:if test="$contents//figures/figure">
<fo:block margin-bottom="5pt">&#xA0;</fo:block>
<fo:block margin-bottom="5pt" role="SKIP"><fo:wrapper role="artifact">&#xA0;</fo:wrapper></fo:block>
<xsl:for-each select="$contents//figures/figure">
<xsl:call-template name="insertListOf_Item"/>
</xsl:for-each>
</xsl:if>

<xsl:if test="$contents//tables/table">
<fo:block margin-bottom="5pt">&#xA0;</fo:block>
<fo:block margin-bottom="5pt" role="SKIP"><fo:wrapper role="artifact">&#xA0;</fo:wrapper></fo:block>
<xsl:for-each select="$contents//tables/table">
<xsl:call-template name="insertListOf_Item"/>
</xsl:for-each>
Expand All @@ -1344,11 +1347,14 @@

<xsl:template name="insertListOf_Item">
<fo:block text-align-last="justify" margin-bottom="5pt" margin-left="8mm" text-indent="-8mm" role="TOCI">
<fo:basic-link internal-destination="{@id}" fox:alt-text="{local-name()} {@id}">
<xsl:variable name="alt_text" select="normalize-space(translate(normalize-space(*[local-name() = 'name']), '&#xa0;—', ' -'))"/>
<fo:basic-link internal-destination="{@id}" fox:alt-text="{$alt_text}"> <!-- {local-name()} {@id} -->
<xsl:apply-templates select="." mode="contents"/>
<fo:inline keep-together.within-line="always">
<fo:inline keep-together.within-line="always" role="SKIP">
<fo:leader leader-pattern="dots"/>
<fo:page-number-citation ref-id="{@id}"/>
<fo:wrapper role="artifact">
<fo:page-number-citation ref-id="{@id}"/>
</fo:wrapper>
</fo:inline>
</fo:basic-link>
</fo:block>
Expand Down

0 comments on commit bf2f0bc

Please sign in to comment.