mirror of
https://github.com/wassname/template.git
synced 2026-09-11 12:51:52 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8fa1f7eaa | ||
|
|
05179d887e | ||
|
|
c02748434c | ||
|
|
bed9a09325 | ||
|
|
010daea5f5 | ||
|
|
65ca734aa3 |
+14
-10
@@ -2,17 +2,21 @@ 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 => {
|
console.log(parsed);
|
||||||
bibliography[e.citationKey] = e.entryTags;
|
if(parsed) {
|
||||||
bibliography[e.citationKey].type = e.entryType;
|
parsed.forEach(e => {
|
||||||
});
|
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 +25,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;
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-3
@@ -80,13 +80,17 @@ export default function(dom, data) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (data.citations) {
|
if (data.citations) {
|
||||||
data.citations.forEach(key =>
|
data.citations.forEach(key => {
|
||||||
|
let d = data.bibliography[key];
|
||||||
|
if(!d) {
|
||||||
|
console.warn("No bibliography data fround for " + key)
|
||||||
|
} else {
|
||||||
meta("citation_reference", citation_meta_content(data.bibliography[key]) )
|
meta("citation_reference", citation_meta_content(data.bibliography[key]) )
|
||||||
);
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function appendHtml(el, html) {
|
function appendHtml(el, html) {
|
||||||
el.innerHTML += html;
|
el.innerHTML += html;
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+22
-13
@@ -4188,17 +4188,21 @@ 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) {
|
console.log(parsed);
|
||||||
bibliography[e.citationKey] = e.entryTags;
|
if(parsed) {
|
||||||
bibliography[e.citationKey].type = e.entryType;
|
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"));
|
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 +4211,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) {
|
||||||
@@ -4307,12 +4311,17 @@ var meta = function(dom, data) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (data.citations) {
|
if (data.citations) {
|
||||||
data.citations.forEach(function (key) { return meta("citation_reference", citation_meta_content(data.bibliography[key]) ); }
|
data.citations.forEach(function (key) {
|
||||||
);
|
var d = data.bibliography[key];
|
||||||
|
if(!d) {
|
||||||
|
console.warn("No bibliography data fround for " + key);
|
||||||
|
} else {
|
||||||
|
meta("citation_reference", citation_meta_content(data.bibliography[key]) );
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
function appendHtml(el, html) {
|
function appendHtml(el, html) {
|
||||||
el.innerHTML += html;
|
el.innerHTML += html;
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "distill-template",
|
"name": "distill-template",
|
||||||
"version": "0.0.8",
|
"version": "0.0.11",
|
||||||
"description": "Template for creating Distill articles.",
|
"description": "Template for creating Distill articles.",
|
||||||
"main": "dist/template.js",
|
"main": "dist/template.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user