mirror of
https://github.com/wassname/template.git
synced 2026-09-09 11:38:29 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8aa8ef2206 | ||
|
|
c0824c1827 | ||
|
|
7fe35c3b88 | ||
|
|
b0b3265f72 | ||
|
|
971e90069e | ||
|
|
c8fa1f7eaa | ||
|
|
05179d887e | ||
|
|
c02748434c | ||
|
|
bed9a09325 | ||
|
|
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) {
|
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 => {
|
if(parsed) {
|
||||||
bibliography[e.citationKey] = e.entryTags;
|
parsed.forEach(e => {
|
||||||
bibliography[e.citationKey].type = e.entryType;
|
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");
|
||||||
|
|||||||
@@ -1,3 +1,169 @@
|
|||||||
|
//import xml from "xml";
|
||||||
|
|
||||||
export default function(data) {
|
export default function(data) {
|
||||||
return "crossref";
|
|
||||||
|
if (data.published == undefined) {
|
||||||
|
console.warn("Can't generate XML for post ", data.title, "with data", data);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
var date = data.published;
|
||||||
|
var batch_timestamp = Math.floor(Date.now() / 1000);
|
||||||
|
var batch_id = data.authors[0].lastName.split(" ")[0].toLowerCase().slice(0,20);
|
||||||
|
batch_id += "_" + date.getFullYear();
|
||||||
|
batch_id += "_" + data.title.split(" ")[0].toLowerCase().slice(0,20) + "_" + batch_timestamp;
|
||||||
|
// generate XML
|
||||||
|
var crf_data =
|
||||||
|
{doi_batch : [
|
||||||
|
|
||||||
|
{ _attr: {
|
||||||
|
version: "4.3.7",
|
||||||
|
xmlns: "http://www.crossref.org/schema/4.3.7",
|
||||||
|
"xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
|
||||||
|
"xsi:schemaLocation": "http://www.crossref.org/schema/4.3.7 http://www.crossref.org/schemas/crossref4.3.7.xsd",
|
||||||
|
}},
|
||||||
|
|
||||||
|
{ head: [
|
||||||
|
{doi_batch_id: batch_id},
|
||||||
|
{timestamp: batch_timestamp},
|
||||||
|
{depositor: [
|
||||||
|
{depositor_name: "Distill Admin"},
|
||||||
|
{email_address: "admin@distill.pub"},
|
||||||
|
]},
|
||||||
|
{registrant: "Distill"},
|
||||||
|
]},
|
||||||
|
|
||||||
|
{body: [
|
||||||
|
{journal: [
|
||||||
|
|
||||||
|
{journal_metadata: [
|
||||||
|
{full_title: data.journal.full_title || data.journal.title},
|
||||||
|
{abbrev_title: data.journal.abbrev_title || data.journal.title || data.journal.full_title},
|
||||||
|
{doi_data: [
|
||||||
|
{doi: data.journal.doi},
|
||||||
|
{resource: data.journal.url},
|
||||||
|
]},
|
||||||
|
]},
|
||||||
|
|
||||||
|
{journal_issue: [
|
||||||
|
{publication_date: [
|
||||||
|
{month: date.getMonth()+1},
|
||||||
|
{year: date.getFullYear()},
|
||||||
|
]},
|
||||||
|
{journal_volume: [
|
||||||
|
{volume: data.volume},
|
||||||
|
]},
|
||||||
|
{issue: data.issue},
|
||||||
|
]},
|
||||||
|
|
||||||
|
{journal_article: [
|
||||||
|
{titles: [
|
||||||
|
{title: data.title},
|
||||||
|
]},
|
||||||
|
{ contributors:
|
||||||
|
data.authors.map((author, ind) => (
|
||||||
|
{person_name: [
|
||||||
|
{ _attr: {
|
||||||
|
contributor_role: "author",
|
||||||
|
sequence: (ind == 0)? "first" : "additional"
|
||||||
|
}},
|
||||||
|
{given_name: author.firstName},
|
||||||
|
{surname: author.lastName},
|
||||||
|
{affiliation: author.affiliation}
|
||||||
|
// TODO: ORCID?
|
||||||
|
]}
|
||||||
|
))
|
||||||
|
},
|
||||||
|
{publication_date: [
|
||||||
|
{month: date.getMonth()+1},
|
||||||
|
{day: date.getDate()},
|
||||||
|
{year: date.getFullYear()}
|
||||||
|
]},
|
||||||
|
{ publisher_item: [
|
||||||
|
{item_number: data.doi}
|
||||||
|
]},
|
||||||
|
{doi_data: [
|
||||||
|
{doi: data.doi},
|
||||||
|
//{timestamp: ""},
|
||||||
|
{resource: data.url},
|
||||||
|
]},
|
||||||
|
{citation_list:
|
||||||
|
data.citations.map(key =>
|
||||||
|
citation_xml(key, data.bibliography[key]))
|
||||||
|
}
|
||||||
|
|
||||||
|
]},
|
||||||
|
|
||||||
|
]},
|
||||||
|
]},
|
||||||
|
]};
|
||||||
|
|
||||||
|
return xml(crf_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
function citation_xml(key, ent){
|
||||||
|
if (ent == undefined) return {};
|
||||||
|
var info = [];
|
||||||
|
info.push({_attr: {key: key}});
|
||||||
|
if ("title" in ent)
|
||||||
|
info.push({article_title: ent.title});
|
||||||
|
if ("author" in ent)
|
||||||
|
info.push({author: ent.author.split(" and ")[0].split(",")[0].trim()});
|
||||||
|
if ("journal" in ent)
|
||||||
|
info.push({journal_title: ent.journal});
|
||||||
|
if ("booktitle" in ent)
|
||||||
|
info.push({volume_title: ent.booktitle});
|
||||||
|
if ("volume" in ent)
|
||||||
|
info.push({volume: ent.volume});
|
||||||
|
if ("issue" in ent)
|
||||||
|
info.push({issue: ent.issue});
|
||||||
|
if ("doi" in ent)
|
||||||
|
info.push({doi: ent.doi});
|
||||||
|
return {citation: info}
|
||||||
|
}
|
||||||
|
|
||||||
|
function xml(obj) {
|
||||||
|
//console.log(typeof(obj), obj)
|
||||||
|
if (typeof obj === 'string') return obj;
|
||||||
|
if (typeof obj === 'number') return ""+obj;
|
||||||
|
let keys = Object.keys(obj);
|
||||||
|
if (keys.length != 1) console.error("can't interpret ", obj, "as xml");
|
||||||
|
let name = keys[0];
|
||||||
|
var full_content = obj[name];
|
||||||
|
var attr = {};
|
||||||
|
if (Array.isArray(full_content)){
|
||||||
|
var content = [];
|
||||||
|
for (var i in full_content) {
|
||||||
|
var obj = full_content[i];
|
||||||
|
var obj_name = Object.keys(obj)[0];
|
||||||
|
if ("_attr" == obj_name) {
|
||||||
|
attr = obj["_attr"];
|
||||||
|
} else {
|
||||||
|
//console.log(Object.keys(obj)[0])
|
||||||
|
content.push(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
content = full_content;
|
||||||
|
}
|
||||||
|
if (content == undefined){
|
||||||
|
content = "undefined"
|
||||||
|
}
|
||||||
|
|
||||||
|
let attr_string = "";
|
||||||
|
for (var k in attr) {
|
||||||
|
attr_string += ` ${k}=\"${attr[k]}\"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//console.log(typeof content, Array.isArray(content), content instanceof String, content)
|
||||||
|
if (Array.isArray(content)){
|
||||||
|
content = content.map(xml);
|
||||||
|
content = content.join("\n").split("\n");
|
||||||
|
content = content.map(s => " " + s).join("\n")
|
||||||
|
var result = `<${name}${attr_string}>\n${content}\n</${name}>`;
|
||||||
|
} else {
|
||||||
|
content = xml(content);
|
||||||
|
var result = `<${name}${attr_string}>${content}</${name}>`;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
+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
+220
-39
@@ -4188,32 +4188,38 @@ 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) {
|
if(parsed) {
|
||||||
bibliography[e.citationKey] = e.entryTags;
|
parsed.forEach(function (e) {
|
||||||
bibliography[e.citationKey].type = e.entryType;
|
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) {
|
||||||
@@ -4304,12 +4310,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;
|
||||||
}
|
}
|
||||||
@@ -4383,10 +4394,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");
|
||||||
@@ -6625,29 +6639,195 @@ var code$1 = function(dom, data) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function render(dom, data) {
|
//import xml from "xml";
|
||||||
data = data || {};
|
|
||||||
|
var generateCrossref = function(data) {
|
||||||
|
|
||||||
|
if (data.published == undefined) {
|
||||||
|
console.warn("Can't generate XML for post ", data.title, "with data", data);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
var date = data.published;
|
||||||
|
var batch_timestamp = Math.floor(Date.now() / 1000);
|
||||||
|
var batch_id = data.authors[0].lastName.split(" ")[0].toLowerCase().slice(0,20);
|
||||||
|
batch_id += "_" + date.getFullYear();
|
||||||
|
batch_id += "_" + data.title.split(" ")[0].toLowerCase().slice(0,20) + "_" + batch_timestamp;
|
||||||
|
// generate XML
|
||||||
|
var crf_data =
|
||||||
|
{doi_batch : [
|
||||||
|
|
||||||
|
{ _attr: {
|
||||||
|
version: "4.3.7",
|
||||||
|
xmlns: "http://www.crossref.org/schema/4.3.7",
|
||||||
|
"xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
|
||||||
|
"xsi:schemaLocation": "http://www.crossref.org/schema/4.3.7 http://www.crossref.org/schemas/crossref4.3.7.xsd",
|
||||||
|
}},
|
||||||
|
|
||||||
|
{ head: [
|
||||||
|
{doi_batch_id: batch_id},
|
||||||
|
{timestamp: batch_timestamp},
|
||||||
|
{depositor: [
|
||||||
|
{depositor_name: "Distill Admin"},
|
||||||
|
{email_address: "admin@distill.pub"} ]},
|
||||||
|
{registrant: "Distill"} ]},
|
||||||
|
|
||||||
|
{body: [
|
||||||
|
{journal: [
|
||||||
|
|
||||||
|
{journal_metadata: [
|
||||||
|
{full_title: data.journal.full_title || data.journal.title},
|
||||||
|
{abbrev_title: data.journal.abbrev_title || data.journal.title || data.journal.full_title},
|
||||||
|
{doi_data: [
|
||||||
|
{doi: data.journal.doi},
|
||||||
|
{resource: data.journal.url} ]} ]},
|
||||||
|
|
||||||
|
{journal_issue: [
|
||||||
|
{publication_date: [
|
||||||
|
{month: date.getMonth()+1},
|
||||||
|
{year: date.getFullYear()} ]},
|
||||||
|
{journal_volume: [
|
||||||
|
{volume: data.volume} ]},
|
||||||
|
{issue: data.issue} ]},
|
||||||
|
|
||||||
|
{journal_article: [
|
||||||
|
{titles: [
|
||||||
|
{title: data.title} ]},
|
||||||
|
{ contributors:
|
||||||
|
data.authors.map(function (author, ind) { return (
|
||||||
|
{person_name: [
|
||||||
|
{ _attr: {
|
||||||
|
contributor_role: "author",
|
||||||
|
sequence: (ind == 0)? "first" : "additional"
|
||||||
|
}},
|
||||||
|
{given_name: author.firstName},
|
||||||
|
{surname: author.lastName},
|
||||||
|
{affiliation: author.affiliation}
|
||||||
|
// TODO: ORCID?
|
||||||
|
]}
|
||||||
|
); })
|
||||||
|
},
|
||||||
|
{publication_date: [
|
||||||
|
{month: date.getMonth()+1},
|
||||||
|
{day: date.getDate()},
|
||||||
|
{year: date.getFullYear()}
|
||||||
|
]},
|
||||||
|
{ publisher_item: [
|
||||||
|
{item_number: data.doi}
|
||||||
|
]},
|
||||||
|
{doi_data: [
|
||||||
|
{doi: data.doi},
|
||||||
|
//{timestamp: ""},
|
||||||
|
{resource: data.url} ]},
|
||||||
|
{citation_list:
|
||||||
|
data.citations.map(function (key) { return citation_xml(key, data.bibliography[key]); })
|
||||||
|
}
|
||||||
|
|
||||||
|
]} ]} ]} ]};
|
||||||
|
|
||||||
|
return xml(crf_data);
|
||||||
|
};
|
||||||
|
|
||||||
|
function citation_xml(key, ent){
|
||||||
|
if (ent == undefined) { return {}; }
|
||||||
|
var info = [];
|
||||||
|
info.push({_attr: {key: key}});
|
||||||
|
if ("title" in ent)
|
||||||
|
{ info.push({article_title: ent.title}); }
|
||||||
|
if ("author" in ent)
|
||||||
|
{ info.push({author: ent.author.split(" and ")[0].split(",")[0].trim()}); }
|
||||||
|
if ("journal" in ent)
|
||||||
|
{ info.push({journal_title: ent.journal}); }
|
||||||
|
if ("booktitle" in ent)
|
||||||
|
{ info.push({volume_title: ent.booktitle}); }
|
||||||
|
if ("volume" in ent)
|
||||||
|
{ info.push({volume: ent.volume}); }
|
||||||
|
if ("issue" in ent)
|
||||||
|
{ info.push({issue: ent.issue}); }
|
||||||
|
if ("doi" in ent)
|
||||||
|
{ info.push({doi: ent.doi}); }
|
||||||
|
return {citation: info}
|
||||||
|
}
|
||||||
|
|
||||||
|
function xml(obj) {
|
||||||
|
//console.log(typeof(obj), obj)
|
||||||
|
if (typeof obj === 'string') { return obj; }
|
||||||
|
if (typeof obj === 'number') { return ""+obj; }
|
||||||
|
var keys = Object.keys(obj);
|
||||||
|
if (keys.length != 1) { console.error("can't interpret ", obj, "as xml"); }
|
||||||
|
var name = keys[0];
|
||||||
|
var full_content = obj[name];
|
||||||
|
var attr = {};
|
||||||
|
if (Array.isArray(full_content)){
|
||||||
|
var content = [];
|
||||||
|
for (var i in full_content) {
|
||||||
|
var obj = full_content[i];
|
||||||
|
var obj_name = Object.keys(obj)[0];
|
||||||
|
if ("_attr" == obj_name) {
|
||||||
|
attr = obj["_attr"];
|
||||||
|
} else {
|
||||||
|
//console.log(Object.keys(obj)[0])
|
||||||
|
content.push(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
content = full_content;
|
||||||
|
}
|
||||||
|
if (content == undefined){
|
||||||
|
content = "undefined";
|
||||||
|
}
|
||||||
|
|
||||||
|
var attr_string = "";
|
||||||
|
for (var k in attr) {
|
||||||
|
attr_string += " " + k + "=\"" + (attr[k]) + "\"";
|
||||||
|
}
|
||||||
|
|
||||||
|
//console.log(typeof content, Array.isArray(content), content instanceof String, content)
|
||||||
|
if (Array.isArray(content)){
|
||||||
|
content = content.map(xml);
|
||||||
|
content = content.join("\n").split("\n");
|
||||||
|
content = content.map(function (s) { return " " + s; }).join("\n");
|
||||||
|
var result = "<" + name + attr_string + ">\n" + content + "\n</" + name + ">";
|
||||||
|
} else {
|
||||||
|
content = xml(content);
|
||||||
|
var result = "<" + name + attr_string + ">" + content + "</" + name + ">";
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderImmediately(dom) {
|
||||||
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;
|
||||||
@@ -6662,6 +6842,7 @@ exports.footer = footer;
|
|||||||
exports.citation = citation;
|
exports.citation = citation;
|
||||||
exports.markdown = markdown;
|
exports.markdown = markdown;
|
||||||
exports.code = code$1;
|
exports.code = code$1;
|
||||||
|
exports.generateCrossref = generateCrossref;
|
||||||
|
|
||||||
Object.defineProperty(exports, '__esModule', { value: true });
|
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 citation from "./components/citation";
|
||||||
import markdown from "./components/markdown";
|
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};
|
||||||
@@ -50,5 +59,4 @@ export {footer as footer};
|
|||||||
export {citation as citation};
|
export {citation as citation};
|
||||||
export {markdown as markdown};
|
export {markdown as markdown};
|
||||||
export {code as code};
|
export {code as code};
|
||||||
|
|
||||||
export {generateCrossref as generateCrossref};
|
export {generateCrossref as generateCrossref};
|
||||||
|
|||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "distill-template",
|
"name": "distill-template",
|
||||||
"version": "0.0.4",
|
"version": "0.0.12",
|
||||||
"description": "Template for creating Distill articles.",
|
"description": "Template for creating Distill articles.",
|
||||||
"main": "dist/distill.js",
|
"main": "dist/template.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "rollup -c -w",
|
"start": "rollup -c -w",
|
||||||
"build": "rollup -c",
|
"build": "rollup -c",
|
||||||
|
|||||||
@@ -377,6 +377,10 @@ diff@1.4.0:
|
|||||||
version "1.4.0"
|
version "1.4.0"
|
||||||
resolved "https://registry.yarnpkg.com/diff/-/diff-1.4.0.tgz#7f28d2eb9ee7b15a97efd89ce63dcfdaa3ccbabf"
|
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:
|
ecc-jsbn@~0.1.1:
|
||||||
version "0.1.1"
|
version "0.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505"
|
resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505"
|
||||||
|
|||||||
Reference in New Issue
Block a user