Automatically substitute event-title for event in styles

Stopgap until styles are updated in citation-style-language/styles#6151
This commit is contained in:
Dan Stillman 2022-08-10 00:52:16 -04:00
parent df5bde79e5
commit 7eab91a160
2 changed files with 69 additions and 0 deletions

View file

@ -83,4 +83,45 @@ describe("Zotero.Styles", function() {
assert.equal(o.text, '1. Foo bar: baz qux. 2019; \n');
});
});
describe("event-title replacement", function () {
var item;
var eventStyleXML = `<?xml version="1.0" encoding="utf-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0">
<info>
<title>Test</title>
<id>http://www.zotero.org/styles/test</id>
<link href="http://www.zotero.org/styles/test" rel="self"/>
<updated>2022-04-14T13:48:43+00:00</updated>
</info>
<bibliography>
<layout>
<text variable="event"/>
<text value=" - "/>
<text variable="event event-place"/>
</layout>
</bibliography>
</style>
`;
before(async function () {
item = createUnsavedDataObject(
'item',
{
itemType: 'conferencePaper',
title: 'Conference Paper'
}
);
item.setField('conferenceName', 'Conference');
await item.saveTx();
});
it("should substitute `event-title` in style using `event`", function () {
var style = new Zotero.Style(eventStyleXML);
var cslEngine = style.getCiteProc('en-US', 'text');
var text = Zotero.Cite.makeFormattedBibliographyOrCitationList(cslEngine, [item], "text");
cslEngine.free();
assert.equal(text, 'Conference - Conference\n');
});
});
});