Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
## [Unreleased]

### Changed
- Implemented [#661](https://github.com/JabRef/jabref/issues/661): Introducing a "check for updates" mechanism (manually/automatic at startup)
- Implemented [#1356](https://github.com/JabRef/jabref/issues/1356): Added a formatter for converting HTML to Unicode
- Implemented [#661](https://github.com/JabRef/jabref/issues/661): Introducing a "check for updates" mechnism (manually/automatic at startup)
- [#1485](https://github.com/JabRef/jabref/issues/1485): Biblatex field shorttitle is now exported/imported as standard field ShortTitle to Word bibliography
- [#1431](https://github.com/JabRef/jabref/issues/1431): Import dialog shows file extensions and filters the view
- Updated German translation
Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ dependencies {

compile 'commons-logging:commons-logging:1.2'

compile 'org.apache.commons:commons-lang3:3.4'

compile 'org.jsoup:jsoup:1.9.2'
compile 'com.mashape.unirest:unirest-java:1.4.9'
compile 'info.debatty:java-string-similarity:0.13'
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/sf/jabref/logic/formatter/Formatters.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import net.sf.jabref.logic.formatter.bibtexfields.ClearFormatter;
import net.sf.jabref.logic.formatter.bibtexfields.HtmlToLatexFormatter;
import net.sf.jabref.logic.formatter.bibtexfields.HtmlToUnicodeFormatter;
import net.sf.jabref.logic.formatter.bibtexfields.LatexCleanupFormatter;
import net.sf.jabref.logic.formatter.bibtexfields.NormalizeDateFormatter;
import net.sf.jabref.logic.formatter.bibtexfields.NormalizeMonthFormatter;
Expand All @@ -45,6 +46,7 @@ public class Formatters {

public static final List<Formatter> CONVERTERS = Arrays.asList(
new HtmlToLatexFormatter(),
new HtmlToUnicodeFormatter(),
new LatexToUnicodeFormatter(),
new UnicodeToLatexFormatter()
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package net.sf.jabref.logic.formatter.bibtexfields;

import net.sf.jabref.logic.formatter.Formatter;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.layout.LayoutFormatter;

import org.apache.commons.lang3.StringEscapeUtils;

public class HtmlToUnicodeFormatter implements LayoutFormatter, Formatter {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also add a corresponding entry in the help file (for LayoutFormatter)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refs: #8 None of the current formatters are documented and I won't build documentation for all as part of this PR. This has to go separately.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant http://help.jabref.org/en/CustomExports under Built-in export formatters since the class is implementing LayoutFormatter and thus can be used for the exports too, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but not a single class of the package net.sf.jabref.logic.formatter.* is listed in this section. I don't think a patchwork solution, where I document just one of those, would be a good idea. The whole page desperately needs updating.


@Override
public String getName() {
return "HTML to Unicode";
}

@Override
public String getKey() {
return "html_to_unicode";
}

@Override
public String getDescription() {
return Localization.lang("Converts HTML code to Unicode.");
}

@Override
public String getExampleInput() {
return "<b>bread</b> &amp; butter";
}

@Override
public String format(String fieldText) {
// StringEscapeUtils converts characters and regex kills tags
return StringEscapeUtils.unescapeHtml4(fieldText).replaceAll("\\<[^>]*>","");
}
}
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_da.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1705,3 +1705,5 @@ The_link_has_been_copied_to_the_clipboard.=
Online_help_forum=

Custom=

Converts_HTML_code_to_Unicode.=
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2279,6 +2279,7 @@ Changes_the_first_letter_of_all_words_to_capital_case_and_the_remaining_letters_
Cleans_up_LaTeX_code.=Räumt_LaTeX-Code_auf.

Converts_HTML_code_to_LaTeX_code.=Konvertiere_HTML-Code_in_LaTeX-Code.
Converts_HTML_code_to_Unicode.=Konvertiere_HTML-Code_in_Unicode.
Converts_LaTeX_encoding_to_Unicode_characters.=Konvertiere_LaTeX_Kodierung_in_Unicode_Zeichen.
Converts_Unicode_characters_to_LaTeX_encoding.=Konvertiere_Unicode_Zeichen_in_LaTeX_Kodierung.
Converts_ordinals_to_LaTeX_superscripts.=Konvertiere_Ordinalzahlen_in_LaTeX_Hochstellung.
Expand Down Expand Up @@ -2422,3 +2423,5 @@ The_link_has_been_copied_to_the_clipboard.=Der_Link_wurde_in_die_Zwischenablage_
Online_help_forum=Online-Hilfeforum

Custom=


1 change: 1 addition & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2148,6 +2148,7 @@ Changes_all_letters_to_upper_case.=Changes_all_letters_to_upper_case.
Changes_the_first_letter_of_all_words_to_capital_case_and_the_remaining_letters_to_lower_case.=Changes_the_first_letter_of_all_words_to_capital_case_and_the_remaining_letters_to_lower_case.
Cleans_up_LaTeX_code.=Cleans_up_LaTeX_code.
Converts_HTML_code_to_LaTeX_code.=Converts_HTML_code_to_LaTeX_code.
Converts_HTML_code_to_Unicode.=Converts_HTML_code_to_Unicode.
Converts_LaTeX_encoding_to_Unicode_characters.=Converts_LaTeX_encoding_to_Unicode_characters.
Converts_Unicode_characters_to_LaTeX_encoding.=Converts_Unicode_characters_to_LaTeX_encoding.
Converts_ordinals_to_LaTeX_superscripts.=Converts_ordinals_to_LaTeX_superscripts.
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1607,3 +1607,5 @@ The_link_has_been_copied_to_the_clipboard.=
Online_help_forum=

Custom=

Converts_HTML_code_to_Unicode.=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_fa.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2393,3 +2393,5 @@ The_link_has_been_copied_to_the_clipboard.=
Online_help_forum=

Custom=

Converts_HTML_code_to_Unicode.=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1651,3 +1651,5 @@ The_link_has_been_copied_to_the_clipboard.=Le_lien_a_été_copié_dans_le_presse
Online_help_forum=

Custom=

Converts_HTML_code_to_Unicode.=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_in.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1626,3 +1626,5 @@ The_link_has_been_copied_to_the_clipboard.=
Online_help_forum=

Custom=

Converts_HTML_code_to_Unicode.=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_it.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1726,3 +1726,5 @@ The_link_has_been_copied_to_the_clipboard.=
Online_help_forum=

Custom=

Converts_HTML_code_to_Unicode.=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2371,3 +2371,5 @@ The_link_has_been_copied_to_the_clipboard.=
Online_help_forum=

Custom=

Converts_HTML_code_to_Unicode.=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_nl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2402,3 +2402,5 @@ The_link_has_been_copied_to_the_clipboard.=
Online_help_forum=

Custom=

Converts_HTML_code_to_Unicode.=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_no.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2798,3 +2798,5 @@ The_link_has_been_copied_to_the_clipboard.=
Online_help_forum=

Custom=

Converts_HTML_code_to_Unicode.=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_pt_BR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1620,3 +1620,5 @@ The_link_has_been_copied_to_the_clipboard.=
Online_help_forum=

Custom=

Converts_HTML_code_to_Unicode.=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2370,3 +2370,5 @@ The_link_has_been_copied_to_the_clipboard.=
Online_help_forum=

Custom=

Converts_HTML_code_to_Unicode.=
3 changes: 3 additions & 0 deletions src/main/resources/l10n/JabRef_sv.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,7 @@ Changes_all_letters_to_upper_case.=Ändrar_alla_bokstäver_till_versaler.
Changes_the_first_letter_of_all_words_to_capital_case_and_the_remaining_letters_to_lower_case.=
Cleans_up_LaTeX_code.=Städar_upp_i_LaTeX-koden.
Converts_HTML_code_to_LaTeX_code.=Konverterar_HTML-koder_till_LaTeX-kod.
Converts_HTML_code_to_Unicode.=Konverterar_HTML-koder_till_Unicode-tecken.
Converts_LaTeX_encoding_to_Unicode_characters.=Konverterar_Latex-koder_till_Unicode-tecken.
Converts_Unicode_characters_to_LaTeX_encoding.=Konverterar_Unicode-tecken_till_LaTeX-kod.
Converts_ordinals_to_LaTeX_superscripts.=Konverterar_ordningsnummer_till_LaTeX_\\superscript{}.
Expand Down Expand Up @@ -1562,3 +1563,5 @@ The_link_has_been_copied_to_the_clipboard.=Länken_har_kopierats_till_urklipp.

Online_help_forum=Onlineforum
Custom=Egna


2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_tr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1639,3 +1639,5 @@ The_link_has_been_copied_to_the_clipboard.=
Online_help_forum=

Custom=

Converts_HTML_code_to_Unicode.=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_vi.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2394,3 +2394,5 @@ The_link_has_been_copied_to_the_clipboard.=
Online_help_forum=

Custom=

Converts_HTML_code_to_Unicode.=
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1633,3 +1633,5 @@ The_link_has_been_copied_to_the_clipboard.=
Online_help_forum=

Custom=

Converts_HTML_code_to_Unicode.=
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.sf.jabref.JabRefPreferences;
import net.sf.jabref.logic.formatter.bibtexfields.ClearFormatter;
import net.sf.jabref.logic.formatter.bibtexfields.HtmlToLatexFormatter;
import net.sf.jabref.logic.formatter.bibtexfields.HtmlToUnicodeFormatter;
import net.sf.jabref.logic.formatter.bibtexfields.LatexCleanupFormatter;
import net.sf.jabref.logic.formatter.bibtexfields.NormalizeDateFormatter;
import net.sf.jabref.logic.formatter.bibtexfields.NormalizeMonthFormatter;
Expand Down Expand Up @@ -105,6 +106,7 @@ public static Collection<Object[]> instancesToTest() {
new Object[]{new CapitalizeFormatter()},
new Object[]{new ClearFormatter()},
new Object[]{new HtmlToLatexFormatter()},
new Object[]{new HtmlToUnicodeFormatter()},
new Object[]{new IdentityFormatter()},
new Object[]{new LatexCleanupFormatter()},
new Object[]{new LatexToUnicodeFormatter()},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.sf.jabref.logic.formatter;


import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
Expand All @@ -10,7 +10,12 @@
*/
public class IdentityFormatterTest {

private final IdentityFormatter formatter = new IdentityFormatter();
private IdentityFormatter formatter;

@Before
public void setUp() {
formatter = new IdentityFormatter();
}

@Test
public void formatExample() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@
* Tests in addition to the general tests from {@link net.sf.jabref.logic.formatter.FormatterTest}
*/

import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class ClearFormatterTest {

private final ClearFormatter formatter = new ClearFormatter();
private ClearFormatter formatter;

@Before
public void setUp() {
formatter = new ClearFormatter();
}

/**
* Check whether the clear formatter really returns the empty string for the empty string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.sf.jabref.JabRefPreferences;

import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
Expand All @@ -13,13 +14,18 @@
*/
public class HtmlToLatexFormatterTest {

private final HtmlToLatexFormatter formatter = new HtmlToLatexFormatter();
private HtmlToLatexFormatter formatter;

@Before
public void setUp() throws Exception {
@BeforeClass
public static void setUpBeforeClass() throws Exception {
Globals.prefs = JabRefPreferences.getInstance();
}

@Before
public void setUp() {
formatter = new HtmlToLatexFormatter();
}

@Test
public void formatWithoutHtmlCharactersReturnsSameString() {
assertEquals("abc", formatter.format("abc"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package net.sf.jabref.logic.formatter.bibtexfields;

import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class HtmlToUnicodeFormatterTest {
Copy link
Member

@tobiasdiez tobiasdiez Jul 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this formatter also to the parametrized FormatterTest class (not sure about the exact name)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do. And FormatterTest is indeed the correct class name.


private HtmlToUnicodeFormatter formatter;

@Before
public void setUp() {
formatter = new HtmlToUnicodeFormatter();
}

@Test
public void formatWithoutHtmlCharactersReturnsSameString() {
assertEquals("abc", formatter.format("abc"));
}

@Test
public void formatMultipleHtmlCharacters() {
assertEquals("åäö", formatter.format("&aring;&auml;&ouml;"));
}

@Test
public void formatCombinedAccent() {
assertEquals("í", formatter.format("i&#x301;"));
}

@Test
public void testBasic() {
assertEquals("aaa", formatter.format("aaa"));
}

@Test
public void testUmlauts() {
assertEquals("ä", formatter.format("&auml;"));
assertEquals("ä", formatter.format("&#228;"));
assertEquals("ä", formatter.format("&#xe4;"));

}

@Test
public void testGreekLetter() {
assertEquals("Ε", formatter.format("&Epsilon;"));
}

@Test
public void testHTMLRemoveTags() {
assertEquals("aaa", formatter.format("<p>aaa</p>"));
}

@Test
public void formatExample() {
assertEquals("bread & butter", formatter.format(formatter.getExampleInput()));
}
}


Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.sf.jabref.logic.formatter.bibtexfields;

import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
Expand All @@ -9,7 +10,12 @@
*/
public class LatexCleanupFormatterTest {

private final LatexCleanupFormatter formatter = new LatexCleanupFormatter();
private LatexCleanupFormatter formatter;

@Before
public void setUp() {
formatter = new LatexCleanupFormatter();
}

@Test
public void test() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package net.sf.jabref.logic.formatter.bibtexfields;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

/**
* Tests in addition to the general tests from {@link net.sf.jabref.logic.formatter.FormatterTest}
*/
public class NormalizeDateFormatterTest {

private final NormalizeDateFormatter formatter = new NormalizeDateFormatter();
private NormalizeDateFormatter formatter;

@Before
public void setUp() {
formatter = new NormalizeDateFormatter();
}

@Test
public void formatDateYYYYMM0D() {
Expand Down
Loading