Compare commits

...
2 Commits
Author SHA1 Message Date
Shan Carter 010daea5f5 0.0.9 2017-01-09 16:51:59 -08:00
Shan Carter 65ca734aa3 bug 2017-01-09 16:51:54 -08:00
4 changed files with 28 additions and 22 deletions
+13 -10
View File
@@ -2,17 +2,20 @@ import bibtexParse from "bibtex-parse-js";
export default function(dom, data) { export default function(dom, data) {
let el = dom.querySelector('script[type="text/bibliography"]'); let el = dom.querySelector('script[type="text/bibliography"]');
let citations = [];
let bibliography = {};
//TODO If we don't have a local element, make a request for the document. //TODO If we don't have a local element, make a request for the document.
if (el) { if (el) {
let rawBib = el.textContent; let rawBib = el.textContent;
let bibliography = {}; let parsed = bibtexParse.toJSON(rawBib);
bibtexParse.toJSON(rawBib).forEach(e => { if(parsed) {
bibliography[e.citationKey] = e.entryTags; parsed.forEach(e => {
bibliography[e.citationKey].type = e.entryType; bibliography[e.citationKey] = e.entryTags;
}); bibliography[e.citationKey].type = e.entryType;
});
}
let citations = [];
var citeTags = [].slice.apply(dom.querySelectorAll("dt-cite")); var citeTags = [].slice.apply(dom.querySelectorAll("dt-cite"));
citeTags.forEach(el => { citeTags.forEach(el => {
let key = el.getAttribute("key"); let key = el.getAttribute("key");
@@ -21,14 +24,14 @@ export default function(dom, data) {
citationKeys.forEach(key => { citationKeys.forEach(key => {
if (citations.indexOf(key) == -1){ if (citations.indexOf(key) == -1){
citations.push(key); citations.push(key);
if (! (key in bibliography)){ if (!(key in bibliography)){
console.warn("No bibliography entry found for: " + key); console.warn("No bibliography entry found for: " + key);
} }
} }
}); });
} }
}); });
data.bibliography = bibliography;
data.citations = citations;
} }
data.bibliography = bibliography;
data.citations = citations;
} }
+13 -10
View File
@@ -4188,17 +4188,20 @@ var bibtexParse = createCommonjsModule(function (module, exports) {
var bibliography = function(dom, data) { var bibliography = function(dom, data) {
var el = dom.querySelector('script[type="text/bibliography"]'); var el = dom.querySelector('script[type="text/bibliography"]');
var citations = [];
var bibliography = {};
//TODO If we don't have a local element, make a request for the document. //TODO If we don't have a local element, make a request for the document.
if (el) { if (el) {
var rawBib = el.textContent; var rawBib = el.textContent;
var bibliography = {}; var parsed = bibtexParse.toJSON(rawBib);
bibtexParse.toJSON(rawBib).forEach(function (e) { if(parsed) {
bibliography[e.citationKey] = e.entryTags; parsed.forEach(function (e) {
bibliography[e.citationKey].type = e.entryType; bibliography[e.citationKey] = e.entryTags;
}); bibliography[e.citationKey].type = e.entryType;
});
}
var citations = [];
var citeTags = [].slice.apply(dom.querySelectorAll("dt-cite")); var citeTags = [].slice.apply(dom.querySelectorAll("dt-cite"));
citeTags.forEach(function (el) { citeTags.forEach(function (el) {
var key = el.getAttribute("key"); var key = el.getAttribute("key");
@@ -4207,16 +4210,16 @@ var bibliography = function(dom, data) {
citationKeys.forEach(function (key) { citationKeys.forEach(function (key) {
if (citations.indexOf(key) == -1){ if (citations.indexOf(key) == -1){
citations.push(key); citations.push(key);
if (! (key in bibliography)){ if (!(key in bibliography)){
console.warn("No bibliography entry found for: " + key); console.warn("No bibliography entry found for: " + key);
} }
} }
}); });
} }
}); });
data.bibliography = bibliography;
data.citations = citations;
} }
data.bibliography = bibliography;
data.citations = citations;
}; };
var expandData = function(dom, data) { var expandData = function(dom, data) {
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "distill-template", "name": "distill-template",
"version": "0.0.8", "version": "0.0.9",
"description": "Template for creating Distill articles.", "description": "Template for creating Distill articles.",
"main": "dist/template.js", "main": "dist/template.js",
"scripts": { "scripts": {