Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine parsing format of CSL reference marks #11720

Merged
merged 1 commit into from
Sep 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/main/java/org/jabref/logic/openoffice/ReferenceMark.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class ReferenceMark {

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

private static final Pattern REFERENCE_MARK_FORMAT = Pattern.compile("^((?:JABREF_\\w+ CID_\\w+(?:,\\s*)?)+)(\\s*\\w+)?$");
private static final Pattern REFERENCE_MARK_FORMAT = Pattern.compile("^(JABREF_\\w+ CID_\\d+(?:, JABREF_\\w+ CID_\\d+)*) (\\w+)$");
private static final Pattern ENTRY_PATTERN = Pattern.compile("JABREF_(\\w+) CID_(\\w+)");

private final String name;
Expand All @@ -24,7 +24,11 @@ public class ReferenceMark {
private String uniqueId;

/**
* @param name Format: <code>JABREF_{citationKey} CID_{citationNumber} {uniqueId}</code>
* @param name Allowed formats:
* Single entry: <code>JABREF_{citationKey} CID_{citationNumber} {uniqueId}</code>
* Group of entries: <code>JABREF_{citationKey1} CID_{citationNumber1}, JABREF_{citationKey2} CID_{citationNumber2}, ..., JABREF_{citationKeyN} CID_{citationNumberN} {uniqueId}</code>
* Disallowed: <code>JABREF_{citationKey} CID_{citationNumber}</code> (no unique ID at the end)
* Disallowed: <code>JABREF_{citationKey1} CID_{citationNumber1} JABREF_{citationKey2} CID_{citationNumber2} {uniqueId}</code> (no comma between entries)
*/
public ReferenceMark(String name) {
this.name = name;
Expand Down
Loading