|
20 | 20 | import org.jabref.model.metadata.SelfContainedSaveOrder; |
21 | 21 |
|
22 | 22 | import org.jspecify.annotations.NonNull; |
23 | | -import org.slf4j.Logger; |
24 | | -import org.slf4j.LoggerFactory; |
25 | 23 |
|
26 | 24 | /** |
27 | 25 | * A custom exporter to write multiple bib entries as AcademicPages Markdown format. |
28 | 26 | */ |
29 | 27 | public class AcademicPagesExporter extends Exporter { |
30 | 28 |
|
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 | | - |
40 | 29 | private final String layoutFileFileName; |
41 | 30 | private final String directory; |
42 | 31 | private final LayoutFormatterPreferences layoutPreferences; |
43 | 32 | 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 | + |
46 | 39 | private TemplateExporter academicPagesTemplate; |
47 | 40 |
|
48 | 41 | /** |
@@ -108,15 +101,14 @@ public void export(@NonNull final BibDatabaseContext databaseContext, |
108 | 101 | } |
109 | 102 | } |
110 | 103 |
|
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 | + |
113 | 106 | replaceFormatter.setArgument(" ,-"); // The replaceFormatter expects a "-" instead of " " hence the strange argument. |
114 | | - RemoveLatexCommandsFormatter commandsFormatter = new RemoveLatexCommandsFormatter(); |
115 | | - HTMLChars htmlFormatter = new HTMLChars(); |
| 107 | + |
116 | 108 | String title = entry.getTitle().orElseThrow(() -> new SaveException("Entry does not contain a title")); |
117 | 109 | String formattedTitle = commandsFormatter.format(htmlFormatter.format(replaceFormatter.format(title))); |
118 | | - SafeFileName safeFormatter = new SafeFileName(); |
119 | 110 | String safeTitle = safeFormatter.format(formattedTitle); |
| 111 | + |
120 | 112 | return exportDirectory.resolve(safeTitle + ".md"); |
121 | 113 | } |
122 | 114 | } |
0 commit comments