mirror of
https://github.com/wassname/template.git
synced 2026-06-28 01:47:02 +08:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 010daea5f5 | |||
| 65ca734aa3 | |||
| 12d78fed92 | |||
| 722db5947e | |||
| cec3f6ab0b | |||
| 7e510b858e | |||
| 715dbec2a1 | |||
| 953991f3f7 | |||
| 998d88a927 | |||
| fa20821af9 |
+22
-16
@@ -2,30 +2,36 @@ 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 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
+60
-36
@@ -4188,32 +4188,38 @@ 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 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 +4389,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");
|
||||
@@ -6625,29 +6634,43 @@ var code$1 = function(dom, data) {
|
||||
});
|
||||
};
|
||||
|
||||
function render(dom, data) {
|
||||
data = data || {};
|
||||
var generateCrossref = function(data) {
|
||||
return "crossref";
|
||||
};
|
||||
|
||||
function renderImmediately(dom) {
|
||||
html(dom);
|
||||
styles(dom);
|
||||
dom.addEventListener("DOMContentLoaded", function(event) {
|
||||
frontMatter(dom, data);
|
||||
bibliography(dom, data);
|
||||
expandData(dom, data);
|
||||
meta(dom, data);
|
||||
header(dom, data);
|
||||
appendix(dom, data);
|
||||
footer(dom, data);
|
||||
markdown(dom, data);
|
||||
code$1(dom, data);
|
||||
citation(dom, data);
|
||||
}
|
||||
|
||||
function renderOnLoad(dom, data) {
|
||||
frontMatter(dom, data);
|
||||
bibliography(dom, data);
|
||||
expandData(dom, data);
|
||||
meta(dom, data);
|
||||
header(dom, data);
|
||||
appendix(dom, data);
|
||||
footer(dom, data);
|
||||
markdown(dom, data);
|
||||
code$1(dom, data);
|
||||
citation(dom, data);
|
||||
}
|
||||
|
||||
// If we are in a browser, render automatically.
|
||||
if(window && window.document) {
|
||||
var data = data || {};
|
||||
renderImmediately(window.document);
|
||||
window.document.addEventListener("DOMContentLoaded", function (event) {
|
||||
renderOnLoad(window.document, data);
|
||||
console.log("final data:");
|
||||
for (var k in data) {console.log(" ", k, ": ", data[k]);}
|
||||
});
|
||||
}
|
||||
|
||||
// If we are in a browser, run render automatically.
|
||||
if(window && window.document) {
|
||||
render(window.document);
|
||||
// For node
|
||||
function render(dom, data) {
|
||||
renderImmediately(dom);
|
||||
renderOnLoad(dom, data);
|
||||
}
|
||||
|
||||
exports.render = render;
|
||||
@@ -6662,6 +6685,7 @@ exports.footer = footer;
|
||||
exports.citation = citation;
|
||||
exports.markdown = markdown;
|
||||
exports.code = code$1;
|
||||
exports.generateCrossref = generateCrossref;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -10,32 +10,41 @@ import footer from "./components/footer";
|
||||
import citation from "./components/citation";
|
||||
import markdown from "./components/markdown";
|
||||
import code from "./components/code";
|
||||
|
||||
import generateCrossref from "./components/generate-crossref";
|
||||
|
||||
function render(dom, data) {
|
||||
data = data || {};
|
||||
function renderImmediately(dom) {
|
||||
html(dom);
|
||||
styles(dom);
|
||||
dom.addEventListener("DOMContentLoaded", function(event) {
|
||||
frontMatter(dom, data);
|
||||
bibliography(dom, data);
|
||||
expandData(dom, data);
|
||||
meta(dom, data);
|
||||
header(dom, data);
|
||||
appendix(dom, data);
|
||||
footer(dom, data);
|
||||
markdown(dom, data);
|
||||
code(dom, data);
|
||||
citation(dom, data);
|
||||
console.log("final data:")
|
||||
}
|
||||
|
||||
function renderOnLoad(dom, data) {
|
||||
frontMatter(dom, data);
|
||||
bibliography(dom, data);
|
||||
expandData(dom, data);
|
||||
meta(dom, data);
|
||||
header(dom, data);
|
||||
appendix(dom, data);
|
||||
footer(dom, data);
|
||||
markdown(dom, data);
|
||||
code(dom, data);
|
||||
citation(dom, data);
|
||||
}
|
||||
|
||||
// If we are in a browser, render automatically.
|
||||
if(window && window.document) {
|
||||
let data = data || {};
|
||||
renderImmediately(window.document);
|
||||
window.document.addEventListener("DOMContentLoaded", (event) => {
|
||||
renderOnLoad(window.document, data);
|
||||
console.log("final data:");
|
||||
for (var k in data) {console.log(" ", k, ": ", data[k])}
|
||||
});
|
||||
}
|
||||
|
||||
// If we are in a browser, run render automatically.
|
||||
if(window && window.document) {
|
||||
render(window.document);
|
||||
// For node
|
||||
function render(dom, data) {
|
||||
renderImmediately(dom);
|
||||
renderOnLoad(dom, data);
|
||||
}
|
||||
|
||||
export {render as render};
|
||||
@@ -50,5 +59,4 @@ export {footer as footer};
|
||||
export {citation as citation};
|
||||
export {markdown as markdown};
|
||||
export {code as code};
|
||||
|
||||
export {generateCrossref as generateCrossref};
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "distill-template",
|
||||
"version": "0.0.4",
|
||||
"version": "0.0.9",
|
||||
"description": "Template for creating Distill articles.",
|
||||
"main": "dist/distill.js",
|
||||
"main": "dist/template.js",
|
||||
"scripts": {
|
||||
"start": "rollup -c -w",
|
||||
"build": "rollup -c",
|
||||
|
||||
@@ -377,6 +377,10 @@ diff@1.4.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/diff/-/diff-1.4.0.tgz#7f28d2eb9ee7b15a97efd89ce63dcfdaa3ccbabf"
|
||||
|
||||
distill-template@^0.0.4:
|
||||
version "0.0.4"
|
||||
resolved "https://registry.yarnpkg.com/distill-template/-/distill-template-0.0.4.tgz#d9d8350001f9f6fc64884e0ad903d733b6856d59"
|
||||
|
||||
ecc-jsbn@~0.1.1:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505"
|
||||
|
||||
Reference in New Issue
Block a user