From f67279cd7b0ba8df4197ba2617b997f94f3f99c2 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sun, 16 Apr 2017 23:04:59 +0200 Subject: [PATCH 1/2] Add test for ordinals --- .../format/LatexToUnicodeFormatterTest.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/test/java/org/jabref/logic/layout/format/LatexToUnicodeFormatterTest.java b/src/test/java/org/jabref/logic/layout/format/LatexToUnicodeFormatterTest.java index 023ef4e95cf..9990dcd07bb 100644 --- a/src/test/java/org/jabref/logic/layout/format/LatexToUnicodeFormatterTest.java +++ b/src/test/java/org/jabref/logic/layout/format/LatexToUnicodeFormatterTest.java @@ -167,4 +167,29 @@ public void testConversionOfUnderscoreWithBraces() { assertEquals("Lorem ipsum_(lorem ipsum)", formatter.format("Lorem ipsum_{lorem ipsum}")); } + @Test + public void testConversionOfOrdinal1st() { + assertEquals("1st", formatter.format("1\\textsuperscript{st}")); + } + + @Test + public void testConversionOfOrdinal2nd() { + assertEquals("2nd", formatter.format("2\\textsuperscript{nd}")); + } + + @Test + public void testConversionOfOrdinal3rd() { + assertEquals("3rd", formatter.format("3\\textsuperscript{rd}")); + } + + @Test + public void testConversionOfOrdinal4th() { + assertEquals("4th", formatter.format("4\\textsuperscript{th}")); + } + + @Test + public void testConversionOfOrdinal9th() { + assertEquals("9th", formatter.format("9\\textsuperscript{th}")); + } + } From ae301895fc80d8d86ea72539f40dfc568184cdd9 Mon Sep 17 00:00:00 2001 From: Linus Dietz Date: Mon, 17 Apr 2017 15:39:59 +0200 Subject: [PATCH 2/2] Changed the Normalizer from NFKC to NFC to allow superscripts to be converted into unicode --- .../jabref/model/strings/LatexToUnicodeAdapter.java | 2 +- .../layout/format/LatexToUnicodeFormatterTest.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/jabref/model/strings/LatexToUnicodeAdapter.java b/src/main/java/org/jabref/model/strings/LatexToUnicodeAdapter.java index 0f7d612a18a..c1eb8dc4248 100644 --- a/src/main/java/org/jabref/model/strings/LatexToUnicodeAdapter.java +++ b/src/main/java/org/jabref/model/strings/LatexToUnicodeAdapter.java @@ -21,7 +21,7 @@ public static String format(String inField) { Objects.requireNonNull(inField); String toFormat = underscoreMatcher.matcher(inField).replaceAll(replacementChar); - toFormat = Normalizer.normalize(LaTeX2Unicode.convert(toFormat), Normalizer.Form.NFKC); + toFormat = Normalizer.normalize(LaTeX2Unicode.convert(toFormat), Normalizer.Form.NFC); return underscorePlaceholderMatcher.matcher(toFormat).replaceAll("_"); } } diff --git a/src/test/java/org/jabref/logic/layout/format/LatexToUnicodeFormatterTest.java b/src/test/java/org/jabref/logic/layout/format/LatexToUnicodeFormatterTest.java index 9990dcd07bb..bf31aa7c6cc 100644 --- a/src/test/java/org/jabref/logic/layout/format/LatexToUnicodeFormatterTest.java +++ b/src/test/java/org/jabref/logic/layout/format/LatexToUnicodeFormatterTest.java @@ -29,7 +29,7 @@ public void testFormatStripLatexCommands() { @Test public void testFormatTextit() { // See #1464 - assertEquals("text", formatter.format("\\textit{text}")); + assertEquals("\uD835\uDC61\uD835\uDC52\uD835\uDC65\uD835\uDC61", formatter.format("\\textit{text}")); } @@ -169,27 +169,27 @@ public void testConversionOfUnderscoreWithBraces() { @Test public void testConversionOfOrdinal1st() { - assertEquals("1st", formatter.format("1\\textsuperscript{st}")); + assertEquals("1ˢᵗ", formatter.format("1\\textsuperscript{st}")); } @Test public void testConversionOfOrdinal2nd() { - assertEquals("2nd", formatter.format("2\\textsuperscript{nd}")); + assertEquals("2ⁿᵈ", formatter.format("2\\textsuperscript{nd}")); } @Test public void testConversionOfOrdinal3rd() { - assertEquals("3rd", formatter.format("3\\textsuperscript{rd}")); + assertEquals("3ʳᵈ", formatter.format("3\\textsuperscript{rd}")); } @Test public void testConversionOfOrdinal4th() { - assertEquals("4th", formatter.format("4\\textsuperscript{th}")); + assertEquals("4ᵗʰ", formatter.format("4\\textsuperscript{th}")); } @Test public void testConversionOfOrdinal9th() { - assertEquals("9th", formatter.format("9\\textsuperscript{th}")); + assertEquals("9ᵗʰ", formatter.format("9\\textsuperscript{th}")); } }