Skip to content

Commit 190497d

Browse files
authored
Merge pull request #1572 from JabRef/implement-1356
Implement 1356
2 parents 45b3de1 + cf781bc commit 190497d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+281
-29
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
1212
## [Unreleased]
1313

1414
### Changed
15-
- Implemented [#661](https://github.com/JabRef/jabref/issues/661): Introducing a "check for updates" mechanism (manually/automatic at startup)
15+
- Implemented [#1356](https://github.com/JabRef/jabref/issues/1356): Added a formatter for converting HTML to Unicode
16+
- Implemented [#661](https://github.com/JabRef/jabref/issues/661): Introducing a "check for updates" mechnism (manually/automatic at startup)
1617
- [#1485](https://github.com/JabRef/jabref/issues/1485): Biblatex field shorttitle is now exported/imported as standard field ShortTitle to Word bibliography
1718
- [#1431](https://github.com/JabRef/jabref/issues/1431): Import dialog shows file extensions and filters the view
1819
- Updated German translation

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ dependencies {
103103

104104
compile 'commons-logging:commons-logging:1.2'
105105

106+
compile 'org.apache.commons:commons-lang3:3.4'
107+
106108
compile 'org.jsoup:jsoup:1.9.2'
107109
compile 'com.mashape.unirest:unirest-java:1.4.9'
108110
compile 'info.debatty:java-string-similarity:0.13'

src/main/java/net/sf/jabref/logic/formatter/Formatters.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import net.sf.jabref.logic.formatter.bibtexfields.ClearFormatter;
2525
import net.sf.jabref.logic.formatter.bibtexfields.HtmlToLatexFormatter;
26+
import net.sf.jabref.logic.formatter.bibtexfields.HtmlToUnicodeFormatter;
2627
import net.sf.jabref.logic.formatter.bibtexfields.LatexCleanupFormatter;
2728
import net.sf.jabref.logic.formatter.bibtexfields.NormalizeDateFormatter;
2829
import net.sf.jabref.logic.formatter.bibtexfields.NormalizeMonthFormatter;
@@ -45,6 +46,7 @@ public class Formatters {
4546

4647
public static final List<Formatter> CONVERTERS = Arrays.asList(
4748
new HtmlToLatexFormatter(),
49+
new HtmlToUnicodeFormatter(),
4850
new LatexToUnicodeFormatter(),
4951
new UnicodeToLatexFormatter()
5052
);
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package net.sf.jabref.logic.formatter.bibtexfields;
2+
3+
import net.sf.jabref.logic.formatter.Formatter;
4+
import net.sf.jabref.logic.l10n.Localization;
5+
import net.sf.jabref.logic.layout.LayoutFormatter;
6+
7+
import org.apache.commons.lang3.StringEscapeUtils;
8+
9+
public class HtmlToUnicodeFormatter implements LayoutFormatter, Formatter {
10+
11+
@Override
12+
public String getName() {
13+
return "HTML to Unicode";
14+
}
15+
16+
@Override
17+
public String getKey() {
18+
return "html_to_unicode";
19+
}
20+
21+
@Override
22+
public String getDescription() {
23+
return Localization.lang("Converts HTML code to Unicode.");
24+
}
25+
26+
@Override
27+
public String getExampleInput() {
28+
return "<b>bread</b> &amp; butter";
29+
}
30+
31+
@Override
32+
public String format(String fieldText) {
33+
// StringEscapeUtils converts characters and regex kills tags
34+
return StringEscapeUtils.unescapeHtml4(fieldText).replaceAll("\\<[^>]*>","");
35+
}
36+
}

src/main/resources/l10n/JabRef_da.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,3 +1705,5 @@ The_link_has_been_copied_to_the_clipboard.=
17051705
Online_help_forum=
17061706

17071707
Custom=
1708+
1709+
Converts_HTML_code_to_Unicode.=

src/main/resources/l10n/JabRef_de.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2279,6 +2279,7 @@ Changes_the_first_letter_of_all_words_to_capital_case_and_the_remaining_letters_
22792279
Cleans_up_LaTeX_code.=Räumt_LaTeX-Code_auf.
22802280

22812281
Converts_HTML_code_to_LaTeX_code.=Konvertiere_HTML-Code_in_LaTeX-Code.
2282+
Converts_HTML_code_to_Unicode.=Konvertiere_HTML-Code_in_Unicode.
22822283
Converts_LaTeX_encoding_to_Unicode_characters.=Konvertiere_LaTeX_Kodierung_in_Unicode_Zeichen.
22832284
Converts_Unicode_characters_to_LaTeX_encoding.=Konvertiere_Unicode_Zeichen_in_LaTeX_Kodierung.
22842285
Converts_ordinals_to_LaTeX_superscripts.=Konvertiere_Ordinalzahlen_in_LaTeX_Hochstellung.
@@ -2422,3 +2423,5 @@ The_link_has_been_copied_to_the_clipboard.=Der_Link_wurde_in_die_Zwischenablage_
24222423
Online_help_forum=Online-Hilfeforum
24232424

24242425
Custom=
2426+
2427+

src/main/resources/l10n/JabRef_en.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2148,6 +2148,7 @@ Changes_all_letters_to_upper_case.=Changes_all_letters_to_upper_case.
21482148
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.
21492149
Cleans_up_LaTeX_code.=Cleans_up_LaTeX_code.
21502150
Converts_HTML_code_to_LaTeX_code.=Converts_HTML_code_to_LaTeX_code.
2151+
Converts_HTML_code_to_Unicode.=Converts_HTML_code_to_Unicode.
21512152
Converts_LaTeX_encoding_to_Unicode_characters.=Converts_LaTeX_encoding_to_Unicode_characters.
21522153
Converts_Unicode_characters_to_LaTeX_encoding.=Converts_Unicode_characters_to_LaTeX_encoding.
21532154
Converts_ordinals_to_LaTeX_superscripts.=Converts_ordinals_to_LaTeX_superscripts.

src/main/resources/l10n/JabRef_es.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,3 +1607,5 @@ The_link_has_been_copied_to_the_clipboard.=
16071607
Online_help_forum=
16081608

16091609
Custom=
1610+
1611+
Converts_HTML_code_to_Unicode.=

src/main/resources/l10n/JabRef_fa.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2393,3 +2393,5 @@ The_link_has_been_copied_to_the_clipboard.=
23932393
Online_help_forum=
23942394

23952395
Custom=
2396+
2397+
Converts_HTML_code_to_Unicode.=

src/main/resources/l10n/JabRef_fr.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,3 +1651,5 @@ The_link_has_been_copied_to_the_clipboard.=Le_lien_a_été_copié_dans_le_presse
16511651
Online_help_forum=
16521652

16531653
Custom=
1654+
1655+
Converts_HTML_code_to_Unicode.=

0 commit comments

Comments
 (0)