Skip to content

Commit

Permalink
Merge branch 'zTranslators'
Browse files Browse the repository at this point in the history
  • Loading branch information
fbennett committed Apr 13, 2023
2 parents 87b88c5 + 6634110 commit ce89e07
Show file tree
Hide file tree
Showing 7 changed files with 2,106 additions and 367 deletions.
4 changes: 2 additions & 2 deletions .ci/pull-request-check/selenium-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ var allPassed = false;

// No API to retrieve extension ID. Hacks, sigh.
await driver.get("chrome://system/");
await driver.wait(until.elementLocated({id: 'extensions-value-btn'}), 60*1000);
await driver.wait(until.elementLocated({id: 'btn-extensions-value'}), 60*1000);
// Chrome 89+ has the extension list expanded by default
try {
let extBtn = await driver.findElement({css: '#extensions-value-btn'});
let extBtn = await driver.findElement({css: '#btn-extensions-value'});
await extBtn.click();
} catch (e) {}
let contentElem = await driver.findElement({css: '#content'});
Expand Down
55 changes: 49 additions & 6 deletions BibTeX.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"inRepository": true,
"translatorType": 3,
"lastUpdated": "2022-10-31 23:11:08"
"lastUpdated": "2023-04-09 18:35:07"
}

/*
Expand Down Expand Up @@ -684,6 +684,7 @@ function unescapeBibTeX(value) {
value = value.replace(mapped, unicode);
}
}
value = value.replace(/\$([^$]+)\$/g, '$1')

// kill braces
value = value.replace(/([^\\])[{}]+/g, "$1");
Expand Down Expand Up @@ -1109,15 +1110,23 @@ function mapHTMLmarkup(characters){
return characters;
}


function xcase(prefix, cased, tag, tex) {
return (prefix ? `$${prefix}$` : '') + (reversemappingTable[`$${tex}{${cased}}$`] || `<${tag}>${cased}</${tag}>`)
}
function sup(match, prefix, cased) {
return xcase(prefix, cased, 'sup', '^');
}
function sub(match, prefix, cased) {
return xcase(prefix, cased, 'sub', '_');
}
function mapTeXmarkup(tex){
//reverse of the above - converts tex mark-up into html mark-up permitted by Zotero
//italics and bold
tex = tex.replace(/\\textit\{([^\}]+\})/g, "<i>$1</i>").replace(/\\textbf\{([^\}]+\})/g, "<b>$1</b>");
//two versions of subscript the .* after $ is necessary because people m
tex = tex.replace(/\$[^\{\$]*_\{([^\}]+\})\$/g, "<sub>$1</sub>").replace(/\$[^\{]*_\{\\textrm\{([^\}]+\}\})/g, "<sub>$1</sub>");
tex = tex.replace(/\$([^\{\$]*)_\{([^\}]+)\}\$/g, sub).replace(/\$([^\{\$]*)_\{\\textrm\{([^\}\$]+)\}\}\$/g, sub);
//two version of superscript
tex = tex.replace(/\$[^\{]*\^\{([^\}]+\}\$)/g, "<sup>$1</sup>").replace(/\$[^\{]*\^\{\\textrm\{([^\}]+\}\})/g, "<sup>$1</sup>");
tex = tex.replace(/\$([^\{\$]*)\^\{([^\}]+)\}\$/g, sup).replace(/\$([^\{\$]*)\^\{\\textrm\{([^\}]+)\}\}\$/g, sup);
//small caps
tex = tex.replace(/\\textsc\{([^\}]+)/g, "<span style=\"small-caps\">$1</span>");
return tex;
Expand Down Expand Up @@ -3326,7 +3335,7 @@ var testCases = [
"items": [
{
"itemType": "journalArticle",
"title": "Test of markupconversion: Italics, bold, superscript, subscript, and small caps: Mitochondrial DNA<sub>2</sub>$ sequences suggest unexpected phylogenetic position of Corso-Sardinian grass snakes (<i>Natrix cetti</i>) and <b>do not</b> support their <span style=\"small-caps\">species status</span>, with notes on phylogeography and subspecies delineation of grass snakes.",
"title": "Test of markupconversion: Italics, bold, superscript, subscript, and small caps: Mitochondrial DNA sequences suggest unexpected phylogenetic position of Corso-Sardinian grass snakes (<i>Natrix cetti</i>) and <b>do not</b> support their <span style=\"small-caps\">species status</span>, with notes on phylogeography and subspecies delineation of grass snakes.",
"creators": [
{
"firstName": "U.",
Expand All @@ -3348,7 +3357,7 @@ var testCases = [
"DOI": "10.1007/s13127-011-0069-8",
"itemID": "Frit2",
"pages": "71-80",
"publicationTitle": "Actes du <sup>ème</sup>$ Congrès Français d'Acoustique",
"publicationTitle": "Actes du 4<sup>ème</sup> Congrès Français d'Acoustique",
"volume": "12",
"attachments": [],
"tags": [],
Expand Down Expand Up @@ -4159,6 +4168,40 @@ var testCases = [
"seeAlso": []
}
]
},
{
"type": "import",
"input": "@article{Borissov:2855446,\r\n author = \"Borissov, Alexander and Solokhin, Sergei\",\r\n collaboration = \"ALICE\",\r\n title = \"{Production of $\\Sigma^{0}$ Hyperon and Search of\r\n $\\Sigma^{0}$ Hypernuclei at LHC with ALICE}\",\r\n journal = \"Phys. At. Nucl.\",\r\n volume = \"85\",\r\n number = \"6\",\r\n pages = \"970-975\",\r\n year = \"2023\",\r\n url = \"https://cds.cern.ch/record/2855446\",\r\n doi = \"10.1134/S1063778823010131\",\r\n }",
"items": [
{
"itemType": "journalArticle",
"title": "Production of Σ⁰ Hyperon and Search of Σ⁰ Hypernuclei at LHC with ALICE",
"creators": [
{
"firstName": "Alexander",
"lastName": "Borissov",
"creatorType": "author"
},
{
"firstName": "Sergei",
"lastName": "Solokhin",
"creatorType": "author"
}
],
"date": "2023",
"DOI": "10.1134/S1063778823010131",
"issue": "6",
"itemID": "Borissov:2855446",
"pages": "970-975",
"publicationTitle": "Phys. At. Nucl.",
"url": "https://cds.cern.ch/record/2855446",
"volume": "85",
"attachments": [],
"tags": [],
"notes": [],
"seeAlso": []
}
]
}
]
/** END TEST CASES **/
Loading

0 comments on commit ce89e07

Please sign in to comment.