2727 * A custom exporter to write multiple bib entries as AcademicPages Markdown format.
2828 */
2929public class AcademicPagesExporter extends Exporter {
30+
3031 private static final String BLANK_LINE_PATTERN = "\\ r\\ n|\\ n" ;
3132 private static final String LAYOUT_PREFIX = "/resource/layout/" ;
3233 private static final String LAYOUT_EXTENSION = ".layout" ;
@@ -61,8 +62,9 @@ public AcademicPagesExporter(LayoutFormatterPreferences layoutPreferences, SelfC
6162 @ Override
6263 public void export (@ NonNull final BibDatabaseContext databaseContext ,
6364 @ NonNull final Path exportDirectory ,
64- @ NonNull List <BibEntry > entries ) throws SaveException {
65- export (databaseContext , exportDirectory , entries , List .of (), JournalAbbreviationLoader .loadBuiltInRepository ());
65+ @ NonNull List <BibEntry > entries )
66+ throws SaveException {
67+ export (databaseContext , exportDirectory , entries , List .of (exportDirectory ), JournalAbbreviationLoader .loadBuiltInRepository ());
6668 }
6769
6870 /**
@@ -79,7 +81,8 @@ public void export(@NonNull final BibDatabaseContext databaseContext,
7981 @ NonNull final Path file ,
8082 @ NonNull List <BibEntry > entries ,
8183 List <Path > fileDirForDataBase ,
82- JournalAbbreviationRepository abbreviationRepository ) throws SaveException {
84+ JournalAbbreviationRepository abbreviationRepository )
85+ throws SaveException {
8386 if (entries .isEmpty ()) { // Only export if entries exist
8487 return ;
8588 }
@@ -105,12 +108,12 @@ public void export(@NonNull final BibDatabaseContext databaseContext,
105108 }
106109 }
107110
108- private static @ NonNull Path getPath (BibEntry entry , Path exportDirectory ) {
111+ private static @ NonNull Path getPath (BibEntry entry , Path exportDirectory ) throws SaveException {
109112 Replace replaceFormatter = new Replace ();
110113 replaceFormatter .setArgument (" ,-" ); // The replaceFormatter expects a "-" instead of " " hence the strange argument.
111114 RemoveLatexCommandsFormatter commandsFormatter = new RemoveLatexCommandsFormatter ();
112115 HTMLChars htmlFormatter = new HTMLChars ();
113- String title = entry .getTitle ().get ( );
116+ String title = entry .getTitle ().orElseThrow (() -> new SaveException ( "Entry does not contain a title" ) );
114117 String formattedTitle = commandsFormatter .format (htmlFormatter .format (replaceFormatter .format (title )));
115118 SafeFileName safeFormatter = new SafeFileName ();
116119 String safeTitle = safeFormatter .format (formattedTitle );
0 commit comments