-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
open office csv format correction for abstract column (#9570)
- Loading branch information
Showing
5 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/main/java/org/jabref/logic/layout/format/ReplaceWithEscapedDoubleQuotes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.jabref.logic.layout.format; | ||
|
||
import org.jabref.logic.layout.LayoutFormatter; | ||
|
||
public class ReplaceWithEscapedDoubleQuotes implements LayoutFormatter { | ||
@Override | ||
public String format(String fieldText) { | ||
StringBuilder builder = new StringBuilder(fieldText.length()); | ||
|
||
for (char c : fieldText.toCharArray()) { | ||
if (c == '\"') { | ||
builder.append("\"\""); | ||
} else { | ||
builder.append(c); | ||
} | ||
} | ||
return builder.toString(); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/main/resources/resource/layout/openoffice/openoffice-csv.layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
\format[GetOpenOfficeType]{\entrytype},"\begin{isbn}\isbn\end{isbn}","\citationkey","\format[Authors(LastFirst,FullName,Semicolon,Semicolon)]{\author}","\format[RemoveBrackets,RemoveWhitespace]{\title}","\journal",\volume,\number,"\month","\pages",\year,"\address","\note","\url","\booktitle","\chapter","\edition","\series","\format[Authors(LastFirst,FullName,Semicolon,Semicolon)]{\editor}","\publisher","\begin{reporttype}\reporttype\end{reporttype}","\howpublished","\institution","\organization","\school","\annote","\format[Replace(\n, )]{\abstract}","\comment","\keywords","\format[FileLink(pdf)]{\file}","\key" | ||
\format[GetOpenOfficeType]{\entrytype},"\begin{isbn}\isbn\end{isbn}","\citationkey","\format[Authors(LastFirst,FullName,Semicolon,Semicolon)]{\author}","\format[RemoveBrackets,RemoveWhitespace]{\title}","\journal",\volume,\number,"\month","\pages",\year,"\address","\note","\url","\booktitle","\chapter","\edition","\series","\format[Authors(LastFirst,FullName,Semicolon,Semicolon)]{\editor}","\publisher","\begin{reporttype}\reporttype\end{reporttype}","\howpublished","\institution","\organization","\school","\annote","\format[Replace(\n, ),ReplaceWithEscapedDoubleQuotes]{\abstract}","\comment","\keywords","\format[FileLink(pdf)]{\file}","\key" |
38 changes: 38 additions & 0 deletions
38
...test/java/org/jabref/logic/formatter/bibtexfields/ReplaceWithEscapedDoubleQuotesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.jabref.logic.formatter.bibtexfields; | ||
|
||
import org.jabref.logic.layout.format.ReplaceWithEscapedDoubleQuotes; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class ReplaceWithEscapedDoubleQuotesTest { | ||
|
||
private ReplaceWithEscapedDoubleQuotes formatter; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
formatter = new ReplaceWithEscapedDoubleQuotes(); | ||
} | ||
|
||
@Test | ||
public void replacingSingleDoubleQuote() { | ||
assertEquals("single \"\"double quote", formatter.format("single \"double quote")); | ||
} | ||
|
||
@Test | ||
public void replacingMultipleDoubleQuote() { | ||
assertEquals("multiple \"\"double\"\" quote", formatter.format("multiple \"double\" quote")); | ||
} | ||
|
||
@Test | ||
public void replacingSingleDoubleQuoteHavingCommas() { | ||
assertEquals("this \"\"is\"\", a test", formatter.format("this \"is\", a test")); | ||
} | ||
|
||
@Test | ||
public void doNothing() { | ||
assertEquals("this is a test", formatter.format("this is a test")); | ||
} | ||
} |