From b21005498ce75146107556f7da6e3dd4ab8208c5 Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Thu, 12 Jan 2017 17:18:38 +0100 Subject: [PATCH 1/3] Apply LatexToUnicode for formatting author names in the main table --- .../sf/jabref/gui/maintable/MainTableNameFormatter.java | 7 ++++++- .../logic/layout/format/LatexToUnicodeFormatterTest.java | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/sf/jabref/gui/maintable/MainTableNameFormatter.java b/src/main/java/net/sf/jabref/gui/maintable/MainTableNameFormatter.java index 340ae150dfa..91b6ded643e 100644 --- a/src/main/java/net/sf/jabref/gui/maintable/MainTableNameFormatter.java +++ b/src/main/java/net/sf/jabref/gui/maintable/MainTableNameFormatter.java @@ -2,17 +2,20 @@ import net.sf.jabref.Globals; import net.sf.jabref.model.entry.AuthorList; +import net.sf.jabref.model.strings.LatexToUnicode; import net.sf.jabref.preferences.JabRefPreferences; public class MainTableNameFormatter { + private static final LatexToUnicode latexToUnicode = new LatexToUnicode(); + /** * Format a name field for the table, according to user preferences. * * @param nameToFormat The contents of the name field. * @return The formatted name field. */ - public static String formatName(final String nameToFormat) { + public static String formatName(String nameToFormat) { if (nameToFormat == null) { return null; } @@ -25,6 +28,8 @@ public static String formatName(final String nameToFormat) { final boolean abbrAuthorNames = Globals.prefs.getBoolean(JabRefPreferences.ABBR_AUTHOR_NAMES); //MK: + nameToFormat = latexToUnicode.format(nameToFormat); + if (namesAsIs) { return nameToFormat; } else if (namesNatbib) { diff --git a/src/test/java/net/sf/jabref/logic/layout/format/LatexToUnicodeFormatterTest.java b/src/test/java/net/sf/jabref/logic/layout/format/LatexToUnicodeFormatterTest.java index 44a9dc593c4..d83e519a9d0 100644 --- a/src/test/java/net/sf/jabref/logic/layout/format/LatexToUnicodeFormatterTest.java +++ b/src/test/java/net/sf/jabref/logic/layout/format/LatexToUnicodeFormatterTest.java @@ -87,4 +87,9 @@ public void unknownCommandKeepsArgument() { public void unknownCommandWithEmptyArgumentIsKept() { assertEquals("aaaa", formatter.format("\\aaaa{}")); } + + @Test + public void testTildeN () { + assertEquals("MontaƱa", formatter.format("Monta\\~{n}a")); + } } From 67c2956a050c20397d867599303acfaddb053359 Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Thu, 12 Jan 2017 17:20:51 +0100 Subject: [PATCH 2/3] Add Changelog entry --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3929e77d4f6..4552cae6b1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,10 +15,10 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# ### Fixed - The formatter for normalizing pages now also can treat ACM pages such as `2:1--2:33`. -- Backslashes in content selectors are now corretly escaped. Fixes [#2426](https://github.com/JabRef/jabref/issues/2426). +- Backslashes in content selectors are now correctly escaped. Fixes [#2426](https://github.com/JabRef/jabref/issues/2426). - Non-ISO timestamp settings prevented the opening of the entry editor (see [#2447](https://github.com/JabRef/jabref/issues/2447)) - When pressing Ctrl + F and the searchbar is already focused the text will be selected. - +- LaTeX symbols are now displayed as Unicode for the author column in the main table. Fixes [#2458](https://github.com/JabRef/jabref/issues/2458). ### Removed From ddb6692b2119dbc290a787f1a7ae0b1e4dc3d08f Mon Sep 17 00:00:00 2001 From: Joerg Lenhard Date: Thu, 12 Jan 2017 17:37:47 +0100 Subject: [PATCH 3/3] Move unicode conversion to MainTableColum. Unicode conversion is already performed there for all fields except the author field --- .../java/net/sf/jabref/gui/maintable/MainTableColumn.java | 2 +- .../sf/jabref/gui/maintable/MainTableNameFormatter.java | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/sf/jabref/gui/maintable/MainTableColumn.java b/src/main/java/net/sf/jabref/gui/maintable/MainTableColumn.java index 69476c00718..10a0fbab1dd 100644 --- a/src/main/java/net/sf/jabref/gui/maintable/MainTableColumn.java +++ b/src/main/java/net/sf/jabref/gui/maintable/MainTableColumn.java @@ -104,7 +104,7 @@ public Object getColumnValue(BibEntry entry) { String result = content.orElse(null); if (isNameColumn) { - result = MainTableNameFormatter.formatName(result); + result = MainTableNameFormatter.formatName(toUnicode.format(result)); } if (result != null) { diff --git a/src/main/java/net/sf/jabref/gui/maintable/MainTableNameFormatter.java b/src/main/java/net/sf/jabref/gui/maintable/MainTableNameFormatter.java index 91b6ded643e..340ae150dfa 100644 --- a/src/main/java/net/sf/jabref/gui/maintable/MainTableNameFormatter.java +++ b/src/main/java/net/sf/jabref/gui/maintable/MainTableNameFormatter.java @@ -2,20 +2,17 @@ import net.sf.jabref.Globals; import net.sf.jabref.model.entry.AuthorList; -import net.sf.jabref.model.strings.LatexToUnicode; import net.sf.jabref.preferences.JabRefPreferences; public class MainTableNameFormatter { - private static final LatexToUnicode latexToUnicode = new LatexToUnicode(); - /** * Format a name field for the table, according to user preferences. * * @param nameToFormat The contents of the name field. * @return The formatted name field. */ - public static String formatName(String nameToFormat) { + public static String formatName(final String nameToFormat) { if (nameToFormat == null) { return null; } @@ -28,8 +25,6 @@ public static String formatName(String nameToFormat) { final boolean abbrAuthorNames = Globals.prefs.getBoolean(JabRefPreferences.ABBR_AUTHOR_NAMES); //MK: - nameToFormat = latexToUnicode.format(nameToFormat); - if (namesAsIs) { return nameToFormat; } else if (namesNatbib) {