Skip to content

Commit

Permalink
review formatting updated, metanorma/metanorma-standoc#842
Browse files Browse the repository at this point in the history
  • Loading branch information
Intelligent2013 committed Dec 25, 2023
1 parent f8e47aa commit 205be85
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SHELL ?= /bin/bash
endif

#JAR_VERSION := $(shell mvn -q -Dexec.executable="echo" -Dexec.args='$${project.version}' --non-recursive exec:exec -DforceStdout)
JAR_VERSION := 1.80
JAR_VERSION := 1.81
JAR_FILE := mn2pdf-$(JAR_VERSION).jar

all: target/$(JAR_FILE)
Expand Down
6 changes: 3 additions & 3 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Update version in `pom.xml`, e.g.:
----
<groupId>org.metanorma.fop</groupId>
<artifactId>mn2pdf</artifactId>
<version>1.80</version>
<version>1.81</version>
<name>Metanorma XML to PDF converter</name>
----

Expand All @@ -111,8 +111,8 @@ Tag the same version in Git:

[source,xml]
----
git tag v1.80
git push origin v1.80
git tag v1.81
git push origin v1.81
----

Then the corresponding GitHub release will be automatically created at:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.metanorma.fop</groupId>
<artifactId>mn2pdf</artifactId>
<version>1.80</version>
<version>1.81</version>
<name>Metanorma XML to PDF converter</name>
<packaging>jar</packaging>
<url>https://www.metanorma.org</url>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/metanorma/fop/PDFGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ private File getPresentationPartXML(File fXML, String outputFolder) {
return outputFile;
}
catch (Exception ex) {
logger.severe("Can't update IF for hidden math.");
logger.severe("Can't obtain the presentation part of the XML:");
logger.severe(ex.getMessage());
ex.printStackTrace();
return fXML;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/metanorma/fop/mn2pdf.java
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ public static void main(String[] args) throws ParseException {
}
} catch (Exception e) {
e.printStackTrace(System.err);
logger.severe(e.toString());
System.exit(ERROR_EXIT_CODE);
}

Expand Down
63 changes: 63 additions & 0 deletions src/main/resources/xfdf_simple.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<xsl:param name="if_xml"/>

<xsl:variable name="if_xml_flatten" select="xalan:nodeset($if_xml)"/>
<!-- <xsl:variable name="if_xml_flatten" select="document($if_xml)"/> for debug from the xalan command line only -->

<!-- Review text coordinates calculation based on values from Apache FOP Intermediate Format -->

Expand Down Expand Up @@ -83,6 +84,12 @@

<xsl:variable name="page" select="count($element_from/preceding-sibling::*[local-name() = 'page'])"/>

<!-- <debug>
<id_from><xsl:value-of select="$id_from"/></id_from>
<element><xsl:copy-of select="$if_xml_flatten//*[local-name() = 'id'][@name = $id_from]/following-sibling::*[local-name() = 'text'][1]"/></element>
<element_from><xsl:copy-of select="$element_from"/></element_from>
</debug> -->

<text>
<xsl:attribute name="color"><xsl:value-of select="$color_annotation"/></xsl:attribute>
<xsl:attribute name="opacity"><xsl:value-of select="$opacity_popup"/></xsl:attribute>
Expand Down Expand Up @@ -232,6 +239,62 @@
<xsl:attribute name="dir">ltr</xsl:attribute>
<xsl:apply-templates mode="pdf_richtext"/>
</xsl:element>
<xsl:if test="following-sibling::*"><xsl:text>&#xa;</xsl:text></xsl:if>
</xsl:template>

<xsl:template match="*[local-name() = 'ul'] | *[local-name() = 'ol']" mode="pdf_richtext">
<xsl:apply-templates mode="pdf_richtext"/>
</xsl:template>

<xsl:template match="*[local-name() = 'ul' or local-name() = 'ol']/*" mode="pdf_richtext">
<xsl:apply-templates mode="pdf_richtext"/>
</xsl:template>

<xsl:template match="*[local-name() = 'ul' or local-name() = 'ol']/*/*[local-name() = 'p']" mode="pdf_richtext">
<xsl:element name="p" namespace="{$namespace_xhtml}">
<xsl:attribute name="dir">ltr</xsl:attribute>
<xsl:variable name="level" select="count(ancestor-or-self::*[local-name() = 'ul' or local-name() = 'ol'])"/>
<xsl:call-template name="repeat">
<xsl:with-param name="count" select="($level - 1) * 5"/>
</xsl:call-template>
<xsl:choose>
<xsl:when test="$level mod 2 = 0">• </xsl:when>
<xsl:otherwise>&#x2014; </xsl:otherwise>
</xsl:choose>

<xsl:apply-templates mode="pdf_richtext"/>
</xsl:element>
<xsl:text>&#xa;</xsl:text>
</xsl:template>

<xsl:template match="*[local-name() = 'dt']" mode="pdf_richtext">
<xsl:apply-templates mode="pdf_richtext"/>
<xsl:text>&#xa0;&#xa0;&#xa0;&#xa0;</xsl:text>
<xsl:apply-templates select="following-sibling::*[local-name() = 'dd'][1]" mode="pdf_richtext">
<xsl:with-param name="process">true</xsl:with-param>
</xsl:apply-templates>
</xsl:template>

<xsl:template match="*[local-name() = 'dd']" mode="pdf_richtext">
<xsl:param name="process">false</xsl:param>
<xsl:if test="$process = 'true'">
<xsl:apply-templates mode="pdf_richtext"/>
<xsl:if test="following-sibling::*">
<xsl:text>&#xa;</xsl:text>
</xsl:if>
</xsl:if>
</xsl:template>

<xsl:template name="repeat">
<xsl:param name="char" select="'&#xa0;'"/>
<xsl:param name="count" />
<xsl:if test="$count &gt; 0">
<xsl:value-of select="$char"/>
<xsl:call-template name="repeat">
<xsl:with-param name="char" select="$char" />
<xsl:with-param name="count" select="$count - 1" />
</xsl:call-template>
</xsl:if>
</xsl:template>

<xsl:template match="*[local-name() = 'sub' or local-name() = 'sup']" mode="pdf_richtext">
Expand Down

0 comments on commit 205be85

Please sign in to comment.