Skip to content

Commit 100fe95

Browse files
committed
add all formatters as class variable
1 parent 6a4c5b0 commit 100fe95

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

jablib/src/main/java/org/jabref/logic/exporter/AcademicPagesExporter.java

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,22 @@
2020
import org.jabref.model.metadata.SelfContainedSaveOrder;
2121

2222
import org.jspecify.annotations.NonNull;
23-
import org.slf4j.Logger;
24-
import org.slf4j.LoggerFactory;
2523

2624
/**
2725
* A custom exporter to write multiple bib entries as AcademicPages Markdown format.
2826
*/
2927
public class AcademicPagesExporter extends Exporter {
3028

31-
private static final String BLANK_LINE_PATTERN = "\\r\\n|\\n";
32-
private static final String LAYOUT_PREFIX = "/resource/layout/";
33-
private static final String LAYOUT_EXTENSION = ".layout";
34-
private static final String FORMATTERS_EXTENSION = ".formatters";
35-
private static final String BEGIN_INFIX = ".begin";
36-
private static final String END_INFIX = ".end";
37-
38-
private static final Logger LOGGER = LoggerFactory.getLogger(AcademicPagesExporter.class);
39-
4029
private final String layoutFileFileName;
4130
private final String directory;
4231
private final LayoutFormatterPreferences layoutPreferences;
4332
private final SelfContainedSaveOrder saveOrder;
44-
private boolean customExport;
45-
private List<BibEntry> entries;
33+
34+
private final Replace replaceFormatter = new Replace();
35+
private final RemoveLatexCommandsFormatter commandsFormatter = new RemoveLatexCommandsFormatter();
36+
private final HTMLChars htmlFormatter = new HTMLChars();
37+
private final SafeFileName safeFormatter = new SafeFileName();
38+
4639
private TemplateExporter academicPagesTemplate;
4740

4841
/**
@@ -108,15 +101,14 @@ public void export(@NonNull final BibDatabaseContext databaseContext,
108101
}
109102
}
110103

111-
private static @NonNull Path getPath(BibEntry entry, Path exportDirectory) throws SaveException {
112-
Replace replaceFormatter = new Replace();
104+
private @NonNull Path getPath(BibEntry entry, Path exportDirectory) throws SaveException {
105+
113106
replaceFormatter.setArgument(" ,-"); // The replaceFormatter expects a "-" instead of " " hence the strange argument.
114-
RemoveLatexCommandsFormatter commandsFormatter = new RemoveLatexCommandsFormatter();
115-
HTMLChars htmlFormatter = new HTMLChars();
107+
116108
String title = entry.getTitle().orElseThrow(() -> new SaveException("Entry does not contain a title"));
117109
String formattedTitle = commandsFormatter.format(htmlFormatter.format(replaceFormatter.format(title)));
118-
SafeFileName safeFormatter = new SafeFileName();
119110
String safeTitle = safeFormatter.format(formattedTitle);
111+
120112
return exportDirectory.resolve(safeTitle + ".md");
121113
}
122114
}

0 commit comments

Comments
 (0)