mirror of
https://github.com/wassname/template.git
synced 2026-06-28 04:07:59 +08:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c02748434c | |||
| bed9a09325 | |||
| 010daea5f5 | |||
| 65ca734aa3 | |||
| 12d78fed92 | |||
| 722db5947e |
+23
-16
@@ -2,30 +2,37 @@ 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);
|
||||
console.log(parsed);
|
||||
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 citationKeys = el.getAttribute("key").split(",");
|
||||
citationKeys.forEach(key => {
|
||||
if (citations.indexOf(key) == -1){
|
||||
citations.push(key);
|
||||
if (! (key in bibliography)){
|
||||
let key = el.getAttribute("key");
|
||||
if (key) {
|
||||
let citationKeys = key.split(",");
|
||||
citationKeys.forEach(key => {
|
||||
if (citations.indexOf(key) == -1){
|
||||
citations.push(key);
|
||||
if (!(key in bibliography)){
|
||||
console.warn("No bibliography entry found for: " + key);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
data.bibliography = bibliography;
|
||||
data.citations = citations;
|
||||
}
|
||||
data.bibliography = bibliography;
|
||||
data.citations = citations;
|
||||
}
|
||||
|
||||
@@ -10,10 +10,13 @@ export default function(dom, data) {
|
||||
var citeTags = [].slice.apply(dom.querySelectorAll("dt-cite"));
|
||||
console.log(citeTags);
|
||||
citeTags.forEach(el => {
|
||||
var keys = el.getAttribute("key").split(",");
|
||||
console.log(keys)
|
||||
var cite_string = inline_cite_short(keys);
|
||||
el.innerHTML = cite_string;
|
||||
var key = el.getAttribute("key");
|
||||
if (key) {
|
||||
var keys = key.split(",");
|
||||
console.log(keys)
|
||||
var cite_string = inline_cite_short(keys);
|
||||
el.innerHTML = cite_string;
|
||||
}
|
||||
});
|
||||
|
||||
let bibEl = dom.querySelector("dt-bibliography");
|
||||
|
||||
Vendored
+31
-21
@@ -4188,32 +4188,39 @@ 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);
|
||||
console.log(parsed);
|
||||
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 citationKeys = el.getAttribute("key").split(",");
|
||||
citationKeys.forEach(function (key) {
|
||||
if (citations.indexOf(key) == -1){
|
||||
citations.push(key);
|
||||
if (! (key in bibliography)){
|
||||
var key = el.getAttribute("key");
|
||||
if (key) {
|
||||
var citationKeys = key.split(",");
|
||||
citationKeys.forEach(function (key) {
|
||||
if (citations.indexOf(key) == -1){
|
||||
citations.push(key);
|
||||
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) {
|
||||
@@ -4383,10 +4390,13 @@ var citation = function(dom, data) {
|
||||
var citeTags = [].slice.apply(dom.querySelectorAll("dt-cite"));
|
||||
console.log(citeTags);
|
||||
citeTags.forEach(function (el) {
|
||||
var keys = el.getAttribute("key").split(",");
|
||||
console.log(keys);
|
||||
var cite_string = inline_cite_short(keys);
|
||||
el.innerHTML = cite_string;
|
||||
var key = el.getAttribute("key");
|
||||
if (key) {
|
||||
var keys = key.split(",");
|
||||
console.log(keys);
|
||||
var cite_string = inline_cite_short(keys);
|
||||
el.innerHTML = cite_string;
|
||||
}
|
||||
});
|
||||
|
||||
var bibEl = dom.querySelector("dt-bibliography");
|
||||
@@ -6661,7 +6671,7 @@ if(window && window.document) {
|
||||
// For node
|
||||
function render(dom, data) {
|
||||
renderImmediately(dom);
|
||||
renderOnload(dom, data);
|
||||
renderOnLoad(dom, data);
|
||||
}
|
||||
|
||||
exports.render = render;
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -44,7 +44,7 @@ if(window && window.document) {
|
||||
// For node
|
||||
function render(dom, data) {
|
||||
renderImmediately(dom);
|
||||
renderOnload(dom, data);
|
||||
renderOnLoad(dom, data);
|
||||
}
|
||||
|
||||
export {render as render};
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "distill-template",
|
||||
"version": "0.0.7",
|
||||
"version": "0.0.10",
|
||||
"description": "Template for creating Distill articles.",
|
||||
"main": "dist/template.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user