mirror of
https://github.com/wassname/template.git
synced 2026-09-11 12:51:52 +08:00
Fixing edge cases with missing tags and data
This commit is contained in:
+22
-22
@@ -2,28 +2,28 @@ import bibtexParse from "bibtex-parse-js";
|
||||
|
||||
export default function(dom, data) {
|
||||
let el = dom.querySelector('script[type="text/bibliography"]');
|
||||
|
||||
//TODO If we don't have a local element, make a request for the document.
|
||||
|
||||
let rawBib = el.textContent;
|
||||
console.log(rawBib, bibtexParse.toJSON(rawBib))
|
||||
let bibliography = {};
|
||||
bibtexParse.toJSON(rawBib).forEach(e => {
|
||||
bibliography[e.citationKey] = e.entryTags;
|
||||
bibliography[e.citationKey].type = e.entryType;
|
||||
});
|
||||
|
||||
let citations = {};
|
||||
var citeTags = [].slice.apply(dom.querySelectorAll("dt-cite"));
|
||||
citeTags.forEach(el => {
|
||||
let citationKeys = el.getAttribute("key").split(",");
|
||||
citationKeys.forEach(key => {
|
||||
if (bibliography[key]) {
|
||||
citations[key] = bibliography[key];
|
||||
} else {
|
||||
console.warn("No bibliography entry found for: " + key);
|
||||
}
|
||||
if (el) {
|
||||
let rawBib = el.textContent;
|
||||
let bibliography = {};
|
||||
bibtexParse.toJSON(rawBib).forEach(e => {
|
||||
bibliography[e.citationKey] = e.entryTags;
|
||||
bibliography[e.citationKey].type = e.entryType;
|
||||
});
|
||||
});
|
||||
data.citations = citations;
|
||||
console.log(data.citations)
|
||||
|
||||
let citations = {};
|
||||
var citeTags = [].slice.apply(dom.querySelectorAll("dt-cite"));
|
||||
citeTags.forEach(el => {
|
||||
let citationKeys = el.getAttribute("key").split(",");
|
||||
citationKeys.forEach(key => {
|
||||
if (bibliography[key]) {
|
||||
citations[key] = bibliography[key];
|
||||
} else {
|
||||
console.warn("No bibliography entry found for: " + key);
|
||||
}
|
||||
});
|
||||
});
|
||||
data.citations = citations;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user