Skip to content

Conversation

@GreLucie
Copy link

@GreLucie GreLucie commented Nov 29, 2025

Closes #12727

This PR is to add a custom exporter for academicpages.github.io by adding the corresponding layouts.
It also implements a way to export multiple files to this format.

Steps to test

When jabref is running, go to file->Export->Export selected entries ( or all entries) and choose "Academic Pages Markdowns" for the export type.

image

You can then add the markdown file(s) to your academic page to see it on your own page.
image

More information about academic pages on the page : https://academicpages.github.io/

Mandatory checks

@github-actions
Copy link
Contributor

Hey @GreLucie!

Thank you for contributing to JabRef! Your help is truly appreciated ❤️

We have automated checks in place, based on which you will soon get feedback if any of them are failing. In a while, maintainers will also review your contribution. Once that happens, you can go through their comments in the "Files changed" tab and act on them, or reply to the conversation if you have further inputs.

Please re-check our contribution guide in case of any other doubts related to our contribution workflow.

@GreLucie GreLucie changed the title Fix for issue 12727 Added a custom Export for academicpages.github.io Nov 29, 2025

String content = Files.readString(expectedFile);

// Verify YAML front matter fields
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the pattern of other tests in that directory, do a full comparison. of the content

CHANGELOG.md Outdated
### Removed

## [6.0-alpha.3] – 2025-10-30
## [6.0-alpha.3] – 2025-11-29
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this change

…uits avec le format exigé de academic pages
…r-issue-12727

# Conflicts:
#	jablib/src/main/java/org/jabref/logic/exporter/AcademicPagesExporter.java
@github-actions github-actions bot added the status: changes-required Pull requests that are not yet complete label Nov 30, 2025
import org.jabref.model.entry.BibEntry;
import org.jabref.model.metadata.SelfContainedSaveOrder;

import org.jetbrains.annotations.NotNull;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use jspecify nonnull

### Removed

## [6.0-alpha.3] – 2025-11-29
## [6.0-alpha.3] – 2025-10-30
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this some automatic tool that always changes the date?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, you told me to revert this change so I went back to the unmodified CHANGELOG for now. I know we have to change it eventually but while this PR is just a draft we decided to change it once all the issues have been fixed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can change it at any time - the earlier the better :) -- BUT - do NOT CHANGE RELEASE DATES

Add your change to the "Unreleased" section.

Note: Current diff shows CHANGELOG.md unmodified: https://github.com/JabRef/jabref/pull/14463/files (which is OK at this stage).

@GreLucie GreLucie marked this pull request as ready for review December 5, 2025 08:44
Comment on lines 47 to 50
/**
* Initialize another export format based on templates stored in dir with layoutFile lfFilename.
*
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment is strange. What is lfFilename? Where does it come from? I think, this is not something a user of the class should know. You can just delete whole JavaDoc comment.


private static final Logger LOGGER = LoggerFactory.getLogger(AcademicPagesExporter.class);

private final String lfFileName;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not abbreviate. Use layoutFileFileName or short layoutFile (because you don't have layoutFileContent.

*/
@Override
public void export(@NonNull final BibDatabaseContext databaseContext,
final Path file,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that Path may be null?

Annoate all or nothing.

Proposal: Add @NullMarked to the class and mark only things which might be null - I think, there aren't any

Files.createDirectories(exportDirectory);

for (BibEntry entry : entries) {
if (entry.getType() == null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, what? When can this happen?

Comment on lines 103 to 104
List<BibEntry> individual_entry = new ArrayList<>();
individual_entry.add(entry);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, what? Use List.of(entry) directly as parameter in the next line.

}

private static @NonNull Path getPath(BibEntry entry, Path exportDirectory) {
Replace replace_formatter = new Replace();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why underscores in varable names? In Java, it is camel case.


private static @NonNull Path getPath(BibEntry entry, Path exportDirectory) {
Replace replace_formatter = new Replace();
replace_formatter.setArgument(" ,-");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thsi is a magic constant - please add a comment why this strange argument.

Replace replace_formatter = new Replace();
replace_formatter.setArgument(" ,-");
RemoveLatexCommandsFormatter commands_formatter = new RemoveLatexCommandsFormatter();
HTMLChars html_formatter = new HTMLChars();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add all formatters as class variable

HTMLChars html_formatter = new HTMLChars();
String title = entry.getTitle().get();
String formatted_title = commands_formatter.format(html_formatter.format(replace_formatter.format(title)));
SafeFileName safe_formatter = new SafeFileName(); // added custom formatter to remove all characters that are not allowed in filenames
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? It is obvious - then remove the comment.

Comment on lines 15 to 16
Optional<Month> month = Month.parse(fieldText);
return month.map(Month::getTwoDigitNumber).orElse("01");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge this into one line plese.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we adressed all of the requested changes in our last commit. More tests were also added by one of our team members.

@github-actions github-actions bot added the status: changes-required Pull requests that are not yet complete label Dec 5, 2025
…porter.java

Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
@github-actions github-actions bot removed the status: changes-required Pull requests that are not yet complete label Dec 6, 2025
@github-actions github-actions bot added the status: changes-required Pull requests that are not yet complete label Dec 6, 2025
@github-actions github-actions bot removed the status: changes-required Pull requests that are not yet complete label Dec 7, 2025
@GreLucie GreLucie requested a review from koppor December 7, 2025 14:39
Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exporter should be "intelligent"

Currently, if no PDF exists, it exports

paperurl: 'https://[insert username].github.io/files/[insert filename].pdf'

This is wrong - it has to omit paperurl if there is no PDF.

slidesurl has to be omitted in all cases, because there is "no standard" in JabRef for this.

bibtexurl can always be provided. -- Write the BibEntry to a file.

Use following method:

public @NonNull String getStringRepresentation(

For InProceedings, the venue has to be read from booktitle. That means: If journal (getFieldOrAlias) is empty, use Booktitleas venue. DO NOT use Unknownleave it empty.

category should also be mapped: InProceedings is conferences, Article is journals, all other can go into manuscripts.

citation needs to be generaed out of the entry preview

Right part at

grafik

paperurl is a file next to the markdown file - just copy the first attached file next to it and link it.

--

insert username is not acceptable. Two options:

  1. Use user from org.jabref.logic.preferences.JabRefCliPreferences#getUserHostInfo - make this method public
  2. Make it configurable in the preferences (for the export for acamdemic pages)
  3. Ask at each export using a dialog

I think, the first option is best.


you can try out the export for yourself using https://github.com/JabRef/jabref-demonstration-libraries/blob/main/chocolate/Chocolate.bib - it has even attached files.

Comment on lines +64 to +67
* @param databaseContext the database to export from
* @param file the directory to write to
* @param entries a list containing all entries that should be exported
* @param abbreviationRepository the built-in repository
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why not all comments start at the same column

}
}

private @NonNull Path getPath(BibEntry entry, Path exportDirectory) throws SaveException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the other parameters be null? I don't think so.

Just remove @NonNull and annotate the whole class as @NullMarked. - I assume, no parameter maybe null or is there one?

/**
* Convert the month name into the corresponding number and return 01 by default
*/
public class NumberMonthFormatter implements LayoutFormatter {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, it should be called MonthNumberFormatter


@Override
public String format(String fieldText) {
return fieldText.replaceAll("[\\\\/:*?\"<>|]", "");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use org.jabref.logic.util.io.FileUtil#getValidFileName

@github-actions github-actions bot added the status: changes-required Pull requests that are not yet complete label Dec 7, 2025
GreLucie and others added 4 commits December 7, 2025 22:57
…porter.java

Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
…porter.java

Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
…porter.java

Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
@jabref-machine
Copy link
Collaborator

Your code currently does not meet JabRef's code guidelines. We use Checkstyle to identify issues. You can see which checks are failing by locating the box "Some checks were not successful" on the pull request page. To see the test output, locate "Source Code Tests / Checkstyle (pull_request)" and click on it.

In case of issues with the import order, double check that you activated Auto Import. You can trigger fixing imports by pressing Ctrl+Alt+O to trigger Optimize Imports.

Please carefully follow the setup guide for the codestyle. Afterwards, please run checkstyle locally and fix the issues, commit, and push.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

first contrib status: changes-required Pull requests that are not yet complete

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Export for academicpages.github.io

7 participants