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

Added parent field to Hayagriva YAML export #10633

Merged
merged 4 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We fixed an issue where the added protected term has unwanted leading and trailing whitespaces, where the formatted text has unwanted empty brackets and where the word at the cursor in the textbox can be added to the list. [#10415](https://github.com/JabRef/jabref/issues/10415)
- We fixed an issue where in the merge dialog the file field of entries was not correctly merged when the first and second entry both contained values inside the file field. [#10572](https://github.com/JabRef/jabref/issues/10572)
- We fixed some small inconsistencies in the user interface. [#10507](https://github.com/JabRef/jabref/issues/10507) [#10458](https://github.com/JabRef/jabref/issues/10458)
- We fixed the issue where the Hayagriva YAML exporter would not include a parent field for the publisher/series. [#10596](https://github.com/JabRef/jabref/issues/10596)

### Removed

Expand Down
17 changes: 15 additions & 2 deletions src/main/resources/resource/layout/hayagrivayaml.layout
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,24 @@
- \format[Authors(LastFirst, MiddleInitial, Sep =\n - , LastSep =\n - )]{\author}
\end{author}
\begin{date} date: \date\end{date}
\begin{journal}
parent:
type: periodical
title: \journal
\end{journal}
\begin{journal&&volume}volume: \volume\end{journal&&volume}
\begin{journal&&number}issue: \number\end{journal&&number}
\begin{journal&&publisher}publisher: \publisher\end{journal&&publisher}
\begin{series}
parent:
type: book
title: "\series"
\end{series}
\begin{editor&&number} issue: \number\end{editor&&number}
\begin{editor&&publisher} publisher: \publisher\end{editor&&publisher}
\begin{editor} editor: \editor\end{editor}
\begin{publisher} publisher: \publisher\end{publisher}
\begin{address} location: \address\end{address}
\begin{institution} organization: \institution\end{institution}
\begin{volume} volume: \volume\end{volume}
\begin{edition} edition: \edition\end{edition}
\begin{pages} page-range: \pages\end{pages}
\begin{url} url: \url\end{url}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,35 @@ void passesModifiedCharsetNull(@TempDir Path tempFile) throws Exception {
"---");
assertEquals(expected, Files.readAllLines(file));
}

@Test
public final void exportsCorrectParentField(@TempDir Path tempFile) throws Exception {
BibEntry entry = new BibEntry(StandardEntryType.Article)
.withCitationKey("test")
.withField(StandardField.AUTHOR, "Test Author")
.withField(StandardField.TITLE, "Test Title")
.withField(StandardField.JOURNAL, "Test Publisher")
.withField(StandardField.URL, "http://example.com")
.withField(StandardField.DATE, "2020-10-14");

Path file = tempFile.resolve("RandomFileName");
Files.createFile(file);
hayagrivaYamlExporter.export(databaseContext, file, Collections.singletonList(entry));

List<String> expected = List.of(
"---",
"test:",
" type: article",
" title: \"Test Title\"",
" author:",
" - Author, Test",
" date: 2020-10-14",
" parent:",
" type: periodical",
" title: Test Publisher",
" url: http://example.com",
"---");

assertEquals(expected, Files.readAllLines(file));
}
}
Loading