Skip to content

Commit

Permalink
Merge pull request #45 from Matoking/sofiak
Browse files Browse the repository at this point in the history
added special characters to reference formatting, needs just a little bit more still to work
  • Loading branch information
tuomokar committed Apr 27, 2016
2 parents cc0f20d + 7605685 commit abd6533
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/ohtuhatut/service/ReferenceFormatService.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,18 @@ private void addEntry(String field, String value, BibTeXEntry bibEntry) {
if (value.equals("year")) {
bibEntry.addField(getFieldKey(field), new DigitStringValue(value));
} else {
replaceSpecialCharactersToBibtex(value);
bibEntry.addField(getFieldKey(field), new StringValue(value, StringValue.Style.QUOTED));
}
}

private String replaceSpecialCharactersToBibtex(String value) {
value = value.replace("ä", "\"{a}");
value = value.replace("ö", "\"{o}");
value = value.replace("å", "\r{a}");
return value;
}

private Key getFieldKey(String field) {
Map<String, Key> keys = new HashMap<String, Key>();
keys.put("author", BibTeXEntry.KEY_AUTHOR);
Expand Down

0 comments on commit abd6533

Please sign in to comment.