mirror of
https://github.com/wassname/template.git
synced 2026-09-09 11:38:29 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8fa1f7eaa | ||
|
|
05179d887e | ||
|
|
c02748434c | ||
|
|
bed9a09325 | ||
|
|
010daea5f5 | ||
|
|
65ca734aa3 | ||
|
|
12d78fed92 | ||
|
|
722db5947e | ||
|
|
cec3f6ab0b | ||
|
|
7e510b858e |
+23
-16
@@ -2,30 +2,37 @@ 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 citationKeys = el.getAttribute("key").split(",");
|
let key = el.getAttribute("key");
|
||||||
citationKeys.forEach(key => {
|
if (key) {
|
||||||
if (citations.indexOf(key) == -1){
|
let citationKeys = key.split(",");
|
||||||
citations.push(key);
|
citationKeys.forEach(key => {
|
||||||
if (! (key in bibliography)){
|
if (citations.indexOf(key) == -1){
|
||||||
|
citations.push(key);
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,13 @@ export default function(dom, data) {
|
|||||||
var citeTags = [].slice.apply(dom.querySelectorAll("dt-cite"));
|
var citeTags = [].slice.apply(dom.querySelectorAll("dt-cite"));
|
||||||
console.log(citeTags);
|
console.log(citeTags);
|
||||||
citeTags.forEach(el => {
|
citeTags.forEach(el => {
|
||||||
var keys = el.getAttribute("key").split(",");
|
var key = el.getAttribute("key");
|
||||||
console.log(keys)
|
if (key) {
|
||||||
var cite_string = inline_cite_short(keys);
|
var keys = key.split(",");
|
||||||
el.innerHTML = cite_string;
|
console.log(keys)
|
||||||
|
var cite_string = inline_cite_short(keys);
|
||||||
|
el.innerHTML = cite_string;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let bibEl = dom.querySelector("dt-bibliography");
|
let bibEl = dom.querySelector("dt-bibliography");
|
||||||
|
|||||||
+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
+64
-47
@@ -283,8 +283,6 @@ function Type$2(tag, options) {
|
|||||||
|
|
||||||
var type = Type$2;
|
var type = Type$2;
|
||||||
|
|
||||||
/*eslint-disable max-len*/
|
|
||||||
|
|
||||||
var common$4 = common$1;
|
var common$4 = common$1;
|
||||||
var YAMLException$3 = exception;
|
var YAMLException$3 = exception;
|
||||||
var Type$1 = type;
|
var Type$1 = type;
|
||||||
@@ -896,8 +894,6 @@ function createCommonjsModule(fn, module) {
|
|||||||
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*eslint-disable no-bitwise*/
|
|
||||||
|
|
||||||
var NodeBuffer;
|
var NodeBuffer;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -1355,8 +1351,6 @@ var default_full = Schema$6.DEFAULT = new Schema$6({
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
/*eslint-disable max-len,no-use-before-define*/
|
|
||||||
|
|
||||||
var common = common$1;
|
var common = common$1;
|
||||||
var YAMLException$1 = exception;
|
var YAMLException$1 = exception;
|
||||||
var Mark = mark;
|
var Mark = mark;
|
||||||
@@ -2948,8 +2942,6 @@ var loader$1 = {
|
|||||||
safeLoad: safeLoad_1
|
safeLoad: safeLoad_1
|
||||||
};
|
};
|
||||||
|
|
||||||
/*eslint-disable no-use-before-define*/
|
|
||||||
|
|
||||||
var common$7 = common$1;
|
var common$7 = common$1;
|
||||||
var YAMLException$5 = exception;
|
var YAMLException$5 = exception;
|
||||||
var DEFAULT_FULL_SCHEMA$2 = default_full;
|
var DEFAULT_FULL_SCHEMA$2 = default_full;
|
||||||
@@ -4196,32 +4188,39 @@ 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 citationKeys = el.getAttribute("key").split(",");
|
var key = el.getAttribute("key");
|
||||||
citationKeys.forEach(function (key) {
|
if (key) {
|
||||||
if (citations.indexOf(key) == -1){
|
var citationKeys = key.split(",");
|
||||||
citations.push(key);
|
citationKeys.forEach(function (key) {
|
||||||
if (! (key in bibliography)){
|
if (citations.indexOf(key) == -1){
|
||||||
|
citations.push(key);
|
||||||
|
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) {
|
||||||
@@ -4312,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;
|
||||||
}
|
}
|
||||||
@@ -4391,10 +4395,13 @@ var citation = function(dom, data) {
|
|||||||
var citeTags = [].slice.apply(dom.querySelectorAll("dt-cite"));
|
var citeTags = [].slice.apply(dom.querySelectorAll("dt-cite"));
|
||||||
console.log(citeTags);
|
console.log(citeTags);
|
||||||
citeTags.forEach(function (el) {
|
citeTags.forEach(function (el) {
|
||||||
var keys = el.getAttribute("key").split(",");
|
var key = el.getAttribute("key");
|
||||||
console.log(keys);
|
if (key) {
|
||||||
var cite_string = inline_cite_short(keys);
|
var keys = key.split(",");
|
||||||
el.innerHTML = cite_string;
|
console.log(keys);
|
||||||
|
var cite_string = inline_cite_short(keys);
|
||||||
|
el.innerHTML = cite_string;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var bibEl = dom.querySelector("dt-bibliography");
|
var bibEl = dom.querySelector("dt-bibliography");
|
||||||
@@ -6637,29 +6644,39 @@ var generateCrossref = function(data) {
|
|||||||
return "crossref";
|
return "crossref";
|
||||||
};
|
};
|
||||||
|
|
||||||
function render(dom, data) {
|
function renderImmediately(dom) {
|
||||||
data = data || {};
|
|
||||||
html(dom);
|
html(dom);
|
||||||
styles(dom);
|
styles(dom);
|
||||||
dom.addEventListener("DOMContentLoaded", function(event) {
|
}
|
||||||
frontMatter(dom, data);
|
|
||||||
bibliography(dom, data);
|
function renderOnLoad(dom, data) {
|
||||||
expandData(dom, data);
|
frontMatter(dom, data);
|
||||||
meta(dom, data);
|
bibliography(dom, data);
|
||||||
header(dom, data);
|
expandData(dom, data);
|
||||||
appendix(dom, data);
|
meta(dom, data);
|
||||||
footer(dom, data);
|
header(dom, data);
|
||||||
markdown(dom, data);
|
appendix(dom, data);
|
||||||
code$1(dom, data);
|
footer(dom, data);
|
||||||
citation(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:");
|
console.log("final data:");
|
||||||
for (var k in data) {console.log(" ", k, ": ", data[k]);}
|
for (var k in data) {console.log(" ", k, ": ", data[k]);}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are in a browser, run render automatically.
|
// For node
|
||||||
if(window && window.document) {
|
function render(dom, data) {
|
||||||
render(window.document);
|
renderImmediately(dom);
|
||||||
|
renderOnLoad(dom, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.render = render;
|
exports.render = render;
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -12,29 +12,39 @@ import markdown from "./components/markdown";
|
|||||||
import code from "./components/code";
|
import code from "./components/code";
|
||||||
import generateCrossref from "./components/generate-crossref";
|
import generateCrossref from "./components/generate-crossref";
|
||||||
|
|
||||||
function render(dom, data) {
|
function renderImmediately(dom) {
|
||||||
data = data || {};
|
|
||||||
html(dom);
|
html(dom);
|
||||||
styles(dom);
|
styles(dom);
|
||||||
dom.addEventListener("DOMContentLoaded", function(event) {
|
}
|
||||||
frontMatter(dom, data);
|
|
||||||
bibliography(dom, data);
|
function renderOnLoad(dom, data) {
|
||||||
expandData(dom, data);
|
frontMatter(dom, data);
|
||||||
meta(dom, data);
|
bibliography(dom, data);
|
||||||
header(dom, data);
|
expandData(dom, data);
|
||||||
appendix(dom, data);
|
meta(dom, data);
|
||||||
footer(dom, data);
|
header(dom, data);
|
||||||
markdown(dom, data);
|
appendix(dom, data);
|
||||||
code(dom, data);
|
footer(dom, data);
|
||||||
citation(dom, data);
|
markdown(dom, data);
|
||||||
console.log("final 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])}
|
for (var k in data) {console.log(" ", k, ": ", data[k])}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are in a browser, run render automatically.
|
// For node
|
||||||
if(window && window.document) {
|
function render(dom, data) {
|
||||||
render(window.document);
|
renderImmediately(dom);
|
||||||
|
renderOnLoad(dom, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
export {render as render};
|
export {render as render};
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "distill-template",
|
"name": "distill-template",
|
||||||
"version": "0.0.6",
|
"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