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) {
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.
if (el) {
let rawBib = el.textContent;
let bibliography = {};
bibtexParse.toJSON(rawBib).forEach(e => {
bibliography[e.citationKey] = e.entryTags;
bibliography[e.citationKey].type = e.entryType;
});
let parsed = bibtexParse.toJSON(rawBib);
if(parsed) {
parsed.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 key = el.getAttribute("key");
@@ -21,14 +24,14 @@ export default function(dom, data) {
citationKeys.forEach(key => {
if (citations.indexOf(key) == -1){
citations.push(key);
if (! (key in bibliography)){
if (!(key in bibliography)){
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 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.
if (el) {
var rawBib = el.textContent;
var bibliography = {};
bibtexParse.toJSON(rawBib).forEach(function (e) {
bibliography[e.citationKey] = e.entryTags;
bibliography[e.citationKey].type = e.entryType;
});
var parsed = bibtexParse.toJSON(rawBib);
if(parsed) {
parsed.forEach(function (e) {
bibliography[e.citationKey] = e.entryTags;
bibliography[e.citationKey].type = e.entryType;
});
}
var citations = [];
var citeTags = [].slice.apply(dom.querySelectorAll("dt-cite"));
citeTags.forEach(function (el) {
var key = el.getAttribute("key");
@@ -4207,16 +4210,16 @@ var bibliography = function(dom, data) {
citationKeys.forEach(function (key) {
if (citations.indexOf(key) == -1){
citations.push(key);
if (! (key in bibliography)){
if (!(key in bibliography)){
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) {
+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",
"version": "0.0.8",
"version": "0.0.9",
"description": "Template for creating Distill articles.",
"main": "dist/template.js",
"scripts": {