Skip to content

Commit

Permalink
Added parent field to Hayagriva YAML export (#10633)
Browse files Browse the repository at this point in the history
* added parent field to support publisher and series

* added testcase for parent field

* changelog

* Update CHANGELOG.md

Co-authored-by: Christoph <siedlerkiller@gmail.com>

---------

Co-authored-by: Christoph <siedlerkiller@gmail.com>
  • Loading branch information
JawadTUE and Siedlerchr authored Nov 14, 2023
1 parent eb44690 commit c75506f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
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));
}
}

0 comments on commit c75506f

Please sign in to comment.