Suggestion for next version: automatically changing hyphen to en-dash in page ranges
As a copyeditor, I can't say how many thousands of times I've manually changed a citation page range to replace hyphens with en-dashes. I actually do a search for all hyphens for this purpose as one of my first steps every time I open a new project. I've noticed that page ranges in Zotero are mixed...some are expressed with a hyphen and others have an en-dash. Given that en-dash is correct, maybe the next version can automatically replace hyphens with en-dashes in the "Pages" field?
Thanks for considering!
Thanks for considering!
Is there a way for CSL to do with number ranges in titles what it already does with other fields with number ranges in them? Meanwhile, is there a fast way to enter en-dash manually in a title? I am making one in Word with a keyboard short cut and then copy/pasting it to the title in Zotero.
On Mac, you can type Alt/Opt+hyphen to get an en dash. On Windows, you can type Alt+0150. You can also install a keyboard layout that mimics the Mac behavior (I can link to one if you like).
Thank you for your response. But what presicely should I do use hyphens automatically intead of of en-dashes?
<locale xml:lang="en">
<terms>
<term name="page-range-delimiter">-</term>
</terms>
</locale>
Any thoughts on a work around?
This code seemed to do it. The item that looks like a hyphen in the new part is a non-breaking hyphen. Also once my document is ready for publication I can do a find and replace in the document and change the non-breaking hyphen to a hyphen.
var fieldName = "volume";
var newPart = "‑";
var fieldName2 = "publicationTitle";
let oldPart = "-";
let s = new Zotero.Search();
s.libraryID = ZoteroPane.getSelectedLibraryID();
s.addCondition(fieldName2, "is", "Phytoneuron");
let ids = await s.search();
if (!ids.length) {
return "No items found";
}
await Zotero.DB.executeTransaction(async function () {
for (let id of ids) {
let item = await Zotero.Items.getAsync(id);
let oldWhole = item.getField(fieldName);
let newWhole = oldWhole.replace(oldPart, newPart);
item.setField(fieldName, newWhole);
await item.save();
}
});
return ids.length + " item(s) updated";