Skip to content

Commit

Permalink
Merge pull request #309 from metanorma/issue/304
Browse files Browse the repository at this point in the history
page numbers in Japanese format identifier fixed, #304
  • Loading branch information
Intelligent2013 authored Nov 12, 2024
2 parents 66b7e4a + 91ecdea commit 6227874
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 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 := 2.08
JAR_VERSION := 2.09
JAR_FILE := mn2pdf-$(JAR_VERSION).jar

all: target/$(JAR_FILE)
Expand Down
10 changes: 5 additions & 5 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ You will need the Java Development Kit (JDK) version 8, Update 241 (8u241) or hi

[source,sh]
----
java -Xss5m -Xmx2048m -jar target/mn2pdf-2.08.jar --xml-file <XML-FileName> --xsl-file <XSLT-FileName> --pdf-file <Output-PDF-FileName> [--syntax-highlight]
java -Xss5m -Xmx2048m -jar target/mn2pdf-2.09.jar --xml-file <XML-FileName> --xsl-file <XSLT-FileName> --pdf-file <Output-PDF-FileName> [--syntax-highlight]
----

e.g.

[source,sh]
----
java -Xss5m -Xmx2048m -jar target/mn2pdf-2.08.jar --xml-file tests/G.191.xml --xsl-file tests/itu.recommendation.xsl --pdf-file tests/G.191.pdf
java -Xss5m -Xmx2048m -jar target/mn2pdf-2.09.jar --xml-file tests/G.191.xml --xsl-file tests/itu.recommendation.xsl --pdf-file tests/G.191.pdf
----

=== PDF encryption features
Expand Down Expand Up @@ -100,7 +100,7 @@ Update version in `pom.xml`, e.g.:
----
<groupId>org.metanorma.fop</groupId>
<artifactId>mn2pdf</artifactId>
<version>2.08</version>
<version>2.09</version>
<name>Metanorma XML to PDF converter</name>
----

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

[source,xml]
----
git tag v2.08
git push origin v2.08
git tag v2.09
git push origin v2.09
----

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>2.08</version>
<version>2.09</version>
<name>Metanorma XML to PDF converter</name>
<packaging>jar</packaging>
<url>https://www.metanorma.org</url>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.metanorma.fop.utils;
package org.apache.fop.complexscripts.util;

// From https://github.com/joumorisu/SuuKotoba/blob/master/src/SuuKotoba.java

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

package org.apache.fop.complexscripts.util;

import org.metanorma.fop.utils.JapaneseToNumbers;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -270,7 +268,7 @@ private Integer[] formatNumber(long number, Integer[] token) {
case (int) 'a': // handled as numeric sequence
case (int) 'I': // handled as numeric special
case (int) 'i': // handled as numeric special
case 20108: // handled as numeric special - Japanese Numerals, first is &#x4E8C; = 20108 decimal;
case 19968: // handled as numeric special - Japanese Numerals, first is &#x4E00; = 19968 decimal;
default:
if (isStartOfDecimalSequence(s)) {
fn = formatNumberAsDecimal(number, s, 1);
Expand Down Expand Up @@ -557,7 +555,7 @@ private static int getSequenceBase(int s) {
{ '\u3044' }, // kana - hiragana (iroha)
{ '\u30A2' }, // kana - katakana (gojuon) - default alphabetic sequence
{ '\u30A4' }, // kana - katakana (iroha)
{ '\u4E8C' }, // Japanese numbers
{ '\u4E00' }, // Japanese numbers
};

private static boolean isStartOfNumericSpecial(int s) {
Expand Down Expand Up @@ -595,7 +593,7 @@ private SpecialNumberFormatter getSpecialFormatter(int one, int letterValue, Str
return new KanaNumeralsFormatter();
} else if (one == (int) '\u30A4') {
return new KanaNumeralsFormatter();
} else if (one == (int) '\u4E8C') {
} else if (one == (int) '\u4E00') {
return new JapaneseNumeralsFormatter();
} else {
return null;
Expand Down Expand Up @@ -1541,7 +1539,7 @@ public Integer[] format(long number, int one, int letterValue, String features,

private class JapaneseNumeralsFormatter implements SpecialNumberFormatter {
public Integer[] format(long number, int one, int letterValue, String features, String language, String country) {
if (one == 0x4E8C) {
if (one == 0x4E00) {
List<Integer> items = new ArrayList<>();

String numStr = JapaneseToNumbers.numToWord((int)number); // add + 10 for two characters testing
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/metanorma/fop/mn2pdfTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import javax.xml.transform.stream.StreamResult;

import org.apache.commons.cli.ParseException;
import org.apache.fop.complexscripts.util.JapaneseToNumbers;
import org.apache.pdfbox.cos.COSName;

import org.apache.pdfbox.pdmodel.*;
Expand Down Expand Up @@ -43,7 +44,6 @@
import org.junit.contrib.java.lang.system.SystemErrRule;
import org.metanorma.Constants;
import org.metanorma.fop.annotations.Annotation;
import org.metanorma.fop.utils.JapaneseToNumbers;
import org.metanorma.utils.LoggerHelper;
import org.w3c.dom.Node;

Expand Down

0 comments on commit 6227874

Please sign in to comment.