Markdown tutorial

This commit is contained in:
Shan Carter committed 2017-01-05 14:37:23 -08:00
1 parent c3c71f186e
commit 8b12e0180b
4 files changed
+90 -54

No files matched your search

+6 -4
View File
@@ -6,13 +6,15 @@ marked.setOptions({
});
export default function(dom, data) {
let markdownElements = [].slice.call(dom.querySelectorAll('[dt-markdown]'));
let markdownElements = [].slice.call(dom.querySelectorAll('[markdown]'));
markdownElements.forEach(el => {
let content = el.innerHTML;
let indent = " ";
// Set default indents to the first or second line
// Set default indents
content = content.replace(/\n/, "");
let tabs = content.match(/\s*/);
content = content.replace(new RegExp("\n" + tabs, "g"), "\n");
content = content.trim();
// content.replace("\n ", "\n" + indent);
el.innerHTML = marked(content);
});
}
+1 -1
View File
@@ -1,3 +1,3 @@
document.write('<script src="http://'+(location.host||"localhost").split(":")[0]+':35729/livereload.js?snipver=1"></script>');var dl=function(){"use strict";function t(t,e){return e={exports:{}},t(e,e.exports),e.exports}function e(t,e){t.innerHTML+=e}function n(t){var e="citation_title="+t.title+";";return t.author.split(" and ").forEach(function(t){e+="citation_author="+t.trim()+";"}),"journal"in t&&(e+="citation_journal_title="+t.journal+";"),"volume"in t&&(e+="citation_volume="+t.volume+";"),("issue"in t||"number"in t)&&(e+="citation_number="+(t.issue||t.number)+";"),e}function i(t,e){r(t),c(t),document.addEventListener("DOMContentLoaded",function(n){h(t,e),g(t,e),m(t,e),y(t,e),k(t,e),_(t,e),E(t,e),v(t,e),console.log("final data:");for(var i in e)console.log(" ",i,": ",e[i])})}var r=function(t){t.querySelector("html").getAttribute("lang")||t.querySelector("html").setAttribute("lang","en");var e=t.querySelector("head");if(!t.querySelector("meta[charset]")){var n=t.createElement("meta");n.setAttribute("charset","utf-8"),e.appendChild(n)}if(!t.querySelector("meta[name=viewport]")){var i=t.createElement("meta");i.setAttribute("name","viewport"),i.setAttribute("content","width=device-width, initial-scale=1"),e.appendChild(i)}},a="html {\n font: 400 15px/1.55em -apple-system, BlinkMacSystemFont, \"Roboto\", sans-serif;\n}\n\nhtml {\n -ms-text-size-adjust: 100%;\n -webkit-text-size-adjust: 100%;\n text-size-adjust: 100%;\n}\nbody {\n margin: 0;\n}\n\n/*\nhtml, body, div, span, applet, object, iframe,\nh1, h2, h3, h4, h5, h6, p, blockquote, pre,\na, abbr, acronym, address, big, cite, code,\ndel, dfn, em, img, ins, kbd, q, s, samp,\nsmall, strike, strong, sub, sup, tt, var,\nb, u, i, center,\ndl, dt, dd, ol, ul, li,\nfieldset, form, label, legend,\ntable, caption, tbody, tfoot, thead, tr, th, td,\narticle, aside, canvas, details, embed,\nfigure, figcaption, footer, header, hgroup,\nmenu, nav, output, ruby, section, summary,\ntime, mark, audio, video {\n\tmargin: 0;\n\tpadding: 0;\n\tborder: 0;\n\tfont-size: 100%;\n\tfont: inherit;\n\tvertical-align: baseline;\n}\narticle, aside, details, figcaption, figure,\nfooter, header, hgroup, menu, nav, section {\n\tdisplay: block;\n}\nbody {\n\tline-height: 1;\n}\nol, ul {\n\tlist-style: none;\n}\nblockquote, q {\n\tquotes: none;\n}\nblockquote:before, blockquote:after,\nq:before, q:after {\n\tcontent: '';\n\tcontent: none;\n}\ntable {\n\tborder-collapse: collapse;\n\tborder-spacing: 0;\n}*/\n",o=".l-body,\n.l-page,\ndt-article > * {\n margin-left: 24px;\n margin-right: 24px;\n box-sizing: border-box;\n}\n\n@media(min-width: 768px) {\n .l-body,\n .l-page,\n dt-article > * {\n margin-left: 72px;\n margin-right: 72px;\n }\n}\n\n@media(min-width: 1080px) {\n .l-body,\n dt-article > * {\n margin-left: calc(50% - 984px / 2);\n width: 648px;\n }\n .l-body-outset,\n dt-article .l-body-outset {\n margin-left: calc(50% - 984px / 2 - 24px);\n width: calc(648px + 48px);\n }\n .l-middle,\n dt-article .l-middle {\n width: 816px;\n margin-left: calc(50% - 984px / 2);\n }\n .l-page,\n dt-article .l-page {\n width: 984px;\n margin-left: auto;\n margin-right: auto;\n }\n .l-page-outset,\n dt-article .l-page-outset {\n width: 1080px;\n margin-left: auto;\n margin-right: auto;\n }\n .l-screen,\n dt-article .l-screen {\n margin-left: auto;\n margin-right: auto;\n width: auto;\n }\n .l-screen-inset,\n dt-article .l-screen-inset {\n margin-left: 24px;\n margin-right: 24px;\n width: auto;\n }\n .l-gutter,\n dt-article .l-gutter {\n clear: both;\n float: right;\n margin-top: 0;\n margin-left: 24px;\n margin-right: calc((100vw - 960px) / 2);\n width: calc((984px - 648px) / 2 - 24px);\n }\n /* Side */\n .side.l-body,\n dt-article .side.l-body {\n clear: both;\n float: right;\n margin-top: 0;\n margin-left: 48px;\n margin-right: calc((100vw - 984px + 648px) / 2);\n width: calc(648px / 2 - 24px);\n }\n .side.l-body-outset,\n dt-article .side.l-body-outset {\n clear: both;\n float: right;\n margin-top: 0;\n margin-left: 48px;\n margin-right: calc((100vw - 984px + 648px - 48px) / 2);\n width: calc(648px / 2 - 48px + 24px);\n }\n .side.l-page,\n dt-article .side.l-page {\n clear: both;\n float: right;\n margin-top: 0;\n margin-left: 48px;\n margin-right: calc((100vw - 984px) / 2);\n width: calc(960px / 2 - 48px);\n }\n}\n",s='dt-article {\n color: rgba(0, 0, 0, 0.8);\n font: 15px/1.55em -apple-system, BlinkMacSystemFont, "Roboto", sans-serif;\n}\n\n@media(min-width: 1024px) {\n dt-article {\n font-size: 20px;\n }\n}\n\ndt-article h1 {\n font-weight: 700;\n font-size: 32px;\n line-height: 1.1em;\n /*-webkit-font-smoothing: antialiased;*/\n}\n\n@media(min-width: 1024px) {\n dt-article h1 {\n font-size: 50px;\n margin-bottom: 12px;\n letter-spacing: -0.025em;\n }\n}\n\n@media(min-width: 1024px) {\n dt-artiLine truncated
h._href=/\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/,h.link=s(h.link)("inside",h._inside)("href",h._href)(),h.reflink=s(h.reflink)("inside",h._inside)(),h.normal=c({},h),h.pedantic=c({},h.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),h.gfm=c({},h.normal,{escape:s(h.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:s(h.text)("]|","~]|")("|","|https?://|")()}),h.breaks=c({},h.gfm,{br:s(h.br)("{2,}","*")(),text:s(h.gfm.text)("{2,}","*")()}),n.rules=h,n.output=function(t,e,i){var r=new n(e,i);return r.output(t)},n.prototype.output=function(t){for(var e,n,i,r,o=this,s="";t;)if(r=o.rules.escape.exec(t))t=t.substring(r[0].length),s+=r[1];else if(r=o.rules.autolink.exec(t))t=t.substring(r[0].length),"@"===r[2]?(n=":"===r[1].charAt(6)?o.mangle(r[1].substring(7)):o.mangle(r[1]),i=o.mangle("mailto:")+n):(n=a(r[1]),i=n),s+=o.renderer.link(i,null,n);else if(o.inLink||!(r=o.rules.url.exec(t))){if(r=o.rules.tag.exec(t))!o.inLink&&/^<a /i.test(r[0])?o.inLink=!0:o.inLink&&/^<\/a>/i.test(r[0])&&(o.inLink=!1),t=t.substring(r[0].length),s+=o.options.sanitize?o.options.sanitizer?o.options.sanitizer(r[0]):a(r[0]):r[0];else if(r=o.rules.link.exec(t))t=t.substring(r[0].length),o.inLink=!0,s+=o.outputLink(r,{href:r[2],title:r[3]}),o.inLink=!1;else if((r=o.rules.reflink.exec(t))||(r=o.rules.nolink.exec(t))){if(t=t.substring(r[0].length),e=(r[2]||r[1]).replace(/\s+/g," "),e=o.links[e.toLowerCase()],!e||!e.href){s+=r[0].charAt(0),t=r[0].substring(1)+t;continue}o.inLink=!0,s+=o.outputLink(r,e),o.inLink=!1}else if(r=o.rules.strong.exec(t))t=t.substring(r[0].length),s+=o.renderer.strong(o.output(r[2]||r[1]));else if(r=o.rules.em.exec(t))t=t.substring(r[0].length),s+=o.renderer.em(o.output(r[2]||r[1]));else if(r=o.rules.code.exec(t))t=t.substring(r[0].length),s+=o.renderer.codespan(a(r[2],!0));else if(r=o.rules.br.exec(t))t=t.substring(r[0].length),s+=o.renderer.br();else if(r=o.rules.del.exec(t))t=t.substring(r[0].length),s+=o.renderer.del(o.output(r[1]));else if(r=o.rules.text.exec(t))t=t.substring(r[0].length),s+=o.renderer.text(a(o.smartypants(r[0])));else if(t)throw new Error("Infinite loop on byte: "+t.charCodeAt(0))}else t=t.substring(r[0].length),n=a(r[1]),i=n,s+=o.renderer.link(i,null,n);return s},n.prototype.outputLink=function(t,e){var n=a(e.href),i=e.title?a(e.title):null;return"!"!==t[0].charAt(0)?this.renderer.link(n,i,this.output(t[1])):this.renderer.image(n,i,a(t[1]))},n.prototype.smartypants=function(t){return this.options.smartypants?t.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014\/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014\/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):t},n.prototype.mangle=function(t){if(!this.options.mangle)return t;for(var e,n="",i=t.length,r=0;r<i;r++)e=t.charCodeAt(r),Math.random()>.5&&(e="x"+e.toString(16)),n+="&#"+e+";";return n},i.prototype.code=function(t,e,n){if(this.options.highlight){var i=this.options.highlight(t,e);null!=i&&i!==t&&(n=!0,t=i)}return e?'<pre><code class="'+this.options.langPrefix+a(e,!0)+'">'+(n?t:a(t,!0))+"\n</code></pre>\n":"<pre><code>"+(n?t:a(t,!0))+"\n</code></pre>"},i.prototype.blockquote=function(t){return"<blockquote>\n"+t+"</blockquote>\n"},i.prototype.html=function(t){return t},i.prototype.heading=function(t,e,n){return"<h"+e+' id="'+this.options.headerPrefix+n.toLowerCase().replace(/[^\w]+/g,"-")+'">'+t+"</h"+e+">\n"},i.prototype.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"},i.prototype.list=function(t,e){var n=e?"ol":"ul";return"<"+n+">\n"+t+"</"+n+">\n"},i.prototype.listitem=function(t){return"<li>"+t+"</li>\n"},i.prototype.paragraph=function(t){return"<p>"+t+"</p>\n"},i.prototype.table=function(t,e){return"<table>\n<thead>\n"+t+"</thead>\n<tbody>\n"+e+"</tbody>\n</table>\n"},i.prototype.tablerow=function(t){return"<tr>\n"+t+"</tr>\n"},i.prototype.tablecell=function(t,e){var n=e.header?"th":"td",i=e.align?"<"+n+' style="text-align:'+e.align+'">':"<"+n+">";return i+t+"</"+n+">\n"},i.prototype.strong=function(t){return"<strong>"+t+"</strong>"},i.prototype.em=function(t){return"<em>"+t+"</em>"},i.prototype.codespan=function(t){return"<code>"+t+"</code>"},i.prototype.br=function(){return this.options.xhtml?"<br/>":"<br>"},i.prototype.del=function(t){return"<del>"+t+"</del>"},i.prototype.link=function(t,e,n){if(this.options.sanitize){try{var i=decodeURIComponent(o(t)).replace(/[^\w:]/g,"").toLowerCase()}catch(t){return""}if(0===i.indexOf("javascript:")||0===i.indexOf("vbscript:"))return""}var r='<a href="'+t+'"';return e&&(r+=' title="'+e+'"'),r+=">"+n+"</a>"},i.prototype.image=function(t,e,n){var i='<img src="'+t+'" alt="'+n+'"';return e&&(i+=' title="'+e+'"'),i+=this.options.xhtml?"/>":">"},i.prototype.text=function(t){return t},r.parse=function(t,e,n){var i=new r(e,n);return i.parse(t)},r.prototype.parse=function(t){var e=this;this.inlinLine truncated
h._href=/\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/,h.link=s(h.link)("inside",h._inside)("href",h._href)(),h.reflink=s(h.reflink)("inside",h._inside)(),h.normal=c({},h),h.pedantic=c({},h.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),h.gfm=c({},h.normal,{escape:s(h.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:s(h.text)("]|","~]|")("|","|https?://|")()}),h.breaks=c({},h.gfm,{br:s(h.br)("{2,}","*")(),text:s(h.gfm.text)("{2,}","*")()}),n.rules=h,n.output=function(t,e,i){var r=new n(e,i);return r.output(t)},n.prototype.output=function(t){for(var e,n,i,r,o=this,s="";t;)if(r=o.rules.escape.exec(t))t=t.substring(r[0].length),s+=r[1];else if(r=o.rules.autolink.exec(t))t=t.substring(r[0].length),"@"===r[2]?(n=":"===r[1].charAt(6)?o.mangle(r[1].substring(7)):o.mangle(r[1]),i=o.mangle("mailto:")+n):(n=a(r[1]),i=n),s+=o.renderer.link(i,null,n);else if(o.inLink||!(r=o.rules.url.exec(t))){if(r=o.rules.tag.exec(t))!o.inLink&&/^<a /i.test(r[0])?o.inLink=!0:o.inLink&&/^<\/a>/i.test(r[0])&&(o.inLink=!1),t=t.substring(r[0].length),s+=o.options.sanitize?o.options.sanitizer?o.options.sanitizer(r[0]):a(r[0]):r[0];else if(r=o.rules.link.exec(t))t=t.substring(r[0].length),o.inLink=!0,s+=o.outputLink(r,{href:r[2],title:r[3]}),o.inLink=!1;else if((r=o.rules.reflink.exec(t))||(r=o.rules.nolink.exec(t))){if(t=t.substring(r[0].length),e=(r[2]||r[1]).replace(/\s+/g," "),e=o.links[e.toLowerCase()],!e||!e.href){s+=r[0].charAt(0),t=r[0].substring(1)+t;continue}o.inLink=!0,s+=o.outputLink(r,e),o.inLink=!1}else if(r=o.rules.strong.exec(t))t=t.substring(r[0].length),s+=o.renderer.strong(o.output(r[2]||r[1]));else if(r=o.rules.em.exec(t))t=t.substring(r[0].length),s+=o.renderer.em(o.output(r[2]||r[1]));else if(r=o.rules.code.exec(t))t=t.substring(r[0].length),s+=o.renderer.codespan(a(r[2],!0));else if(r=o.rules.br.exec(t))t=t.substring(r[0].length),s+=o.renderer.br();else if(r=o.rules.del.exec(t))t=t.substring(r[0].length),s+=o.renderer.del(o.output(r[1]));else if(r=o.rules.text.exec(t))t=t.substring(r[0].length),s+=o.renderer.text(a(o.smartypants(r[0])));else if(t)throw new Error("Infinite loop on byte: "+t.charCodeAt(0))}else t=t.substring(r[0].length),n=a(r[1]),i=n,s+=o.renderer.link(i,null,n);return s},n.prototype.outputLink=function(t,e){var n=a(e.href),i=e.title?a(e.title):null;return"!"!==t[0].charAt(0)?this.renderer.link(n,i,this.output(t[1])):this.renderer.image(n,i,a(t[1]))},n.prototype.smartypants=function(t){return this.options.smartypants?t.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014\/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014\/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):t},n.prototype.mangle=function(t){if(!this.options.mangle)return t;for(var e,n="",i=t.length,r=0;r<i;r++)e=t.charCodeAt(r),Math.random()>.5&&(e="x"+e.toString(16)),n+="&#"+e+";";return n},i.prototype.code=function(t,e,n){if(this.options.highlight){var i=this.options.highlight(t,e);null!=i&&i!==t&&(n=!0,t=i)}return e?'<pre><code class="'+this.options.langPrefix+a(e,!0)+'">'+(n?t:a(t,!0))+"\n</code></pre>\n":"<pre><code>"+(n?t:a(t,!0))+"\n</code></pre>"},i.prototype.blockquote=function(t){return"<blockquote>\n"+t+"</blockquote>\n"},i.prototype.html=function(t){return t},i.prototype.heading=function(t,e,n){return"<h"+e+' id="'+this.options.headerPrefix+n.toLowerCase().replace(/[^\w]+/g,"-")+'">'+t+"</h"+e+">\n"},i.prototype.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"},i.prototype.list=function(t,e){var n=e?"ol":"ul";return"<"+n+">\n"+t+"</"+n+">\n"},i.prototype.listitem=function(t){return"<li>"+t+"</li>\n"},i.prototype.paragraph=function(t){return"<p>"+t+"</p>\n"},i.prototype.table=function(t,e){return"<table>\n<thead>\n"+t+"</thead>\n<tbody>\n"+e+"</tbody>\n</table>\n"},i.prototype.tablerow=function(t){return"<tr>\n"+t+"</tr>\n"},i.prototype.tablecell=function(t,e){var n=e.header?"th":"td",i=e.align?"<"+n+' style="text-align:'+e.align+'">':"<"+n+">";return i+t+"</"+n+">\n"},i.prototype.strong=function(t){return"<strong>"+t+"</strong>"},i.prototype.em=function(t){return"<em>"+t+"</em>"},i.prototype.codespan=function(t){return"<code>"+t+"</code>"},i.prototype.br=function(){return this.options.xhtml?"<br/>":"<br>"},i.prototype.del=function(t){return"<del>"+t+"</del>"},i.prototype.link=function(t,e,n){if(this.options.sanitize){try{var i=decodeURIComponent(o(t)).replace(/[^\w:]/g,"").toLowerCase()}catch(t){return""}if(0===i.indexOf("javascript:")||0===i.indexOf("vbscript:"))return""}var r='<a href="'+t+'"';return e&&(r+=' title="'+e+'"'),r+=">"+n+"</a>"},i.prototype.image=function(t,e,n){var i='<img src="'+t+'" alt="'+n+'"';return e&&(i+=' title="'+e+'"'),i+=this.options.xhtml?"/>":">"},i.prototype.text=function(t){return t},r.parse=function(t,e,n){var i=new r(e,n);return i.parse(t)},r.prototype.parse=function(t){var e=this;this.inlinLine truncated
//# sourceMappingURL=template.min.js.map
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":null,"sources":["../components/meta.js","../index.js","../components/html.js","../components/styles.js","../node_modules/bibtex-parse-js/bibtexParse.js","../components/cite-data.js","../components/header.js","../components/appendix.js","../components/footer.js","../components/citation.js","../node_modules/marked/lib/marked.js","../components/markdown.js","../node_modules/prismjs/prism.js","../components/code.js","../test-data.js"],"sourcesContent":["export default function(dom, data) {\n let head = dom.querySelector(\"head\");\n \n appendHtml(head, `\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=Edge,chrome=1\">\n <link rel=\"icon\" type=\"image/png\" href=\"/favicon.png\">\n <link href=\"/rss.xml\" rel=\"alternate\" type=\"application/rss+xml\" title=\"Articles from Distill\">\n <link rel=\"canonical\" href=\"${data.url}\">\n <title>${data.title}</title>\n `);\n\n appendHtml(head, `\n <!-- https://schema.org/Article -->\n <meta property=\"article:published\" itemprop=\"datePublished\" content=\"${data.publishedDate}\" />\n <meta property=\"article:modified\" itemprop=\"dateModified\" content=\"${data.updatedDate}\" />\n `);\n data.authors.forEach((a) => {\n appendHtml(head, `\n <meta property=\"article:author\" content=\"${a.firstName} ${a.lastName}\" />`)\n });\n\n appendHtml(head, `\n <!-- https://developers.facebook.com/docs/sharing/webmasters#markup -->\n <meta property=\"og:type\" content=\"article\"/>\n <meta property=\"og:title\" content=\"${data.title}\"/>\n <meta property=\"og:description\" content=\"${data.description}\">\n <meta property=\"og:url\" content=\"${data.url}\"/>\n <meta property=\"og:image\" content=\"${data.url}/thumbnail.png\"/>\n <meta property=\"og:locale\" content=\"en_US\" />\n <meta property=\"og:site_name\" content=\"Distill\" />\n `);\n\n appendHtml(head, `\n <!-- https://dev.twitter.com/cards/types/summary -->\n <meta name=\"twitter:card\" content=\"summary_large_image\">\n <meta name=\"twitter:title\" content=\"${data.title}\">\n <meta name=\"twitter:description\" content=\"${data.description}\">\n <meta name=\"twitter:url\" content=\"${data.url}\">\n <meta name=\"twitter:image\" content=\"${data.url}/thumbnail.png\">\n <meta name=\"twitter:image:width\" content=\"560\">\n <meta name=\"twitter:image:height\" content=\"295\">\n `);\n\n appendHtml(head, `\n <!-- https://scholar.google.com/intl/en/scholar/inclusion.html#indexing -->\n <meta name=\"citation_title\" content=\"${data.title}\">\n <meta name=\"citation_publication_date\" content=\"${data.publishedYear}/${data.publishedMonthPadded}/${data.publishedDayPadded}\">\n <meta name=\"citation_fulltext_html_url\" content=\"${data.url}\">\n <meta name=\"citation_volume\" content=\"${data.volume}\">\n <meta name=\"citation_issue\" content=\"${data.issue}\">\n <meta name=\"citation_journal_title\" content=\"${data.journal.name}\">\n <meta name=\"citation_journal_abbrev\" content=\"${data.journal.nameAbbrev}\"/>\n <meta name=\"citation_firstpage\" content=\"e${data.doiSuffix}\"/>\n <meta name=\"citation_doi\" content=\"${data.doi}\">\n <meta name=\"citation_issn\" content=\"${data.journal.issn}\">\n <meta name=\"citation_publisher\" content=\"${data.journal.publisher}\"/>\n `);\n data.authors.forEach((a) => {\n appendHtml(head, `\n <meta name=\"citation_author\" content=\"${a.lastName}, ${a.firstName}\" />\n <meta name=\"citation_author_institution\" content=\"${a.affiliation}\"/>\n `)\n });\n\n Object.keys(data.citations).forEach(key => {\n console.log(key);\n appendHtml(head, `\n <meta name=\"citation_reference\" content=\"${citation_meta_content(data.citations[key])}\" >\n `);\n });\n}\n\n\nfunction appendHtml(el, html) {\n el.innerHTML += html;\n}\n\nfunction citation_meta_content(ref){\n var content = `citation_title=${ref.title};`;\n ref.author.split(\" and \").forEach(author => {\n content += `citation_author=${author.trim()};`;\n });\n if (\"journal\" in ref){\n content += `citation_journal_title=${ref.journal};`;\n }\n if (\"volume\" in ref) {\n content += `citation_volume=${ref.volume};`;\n }\n if (\"issue\" in ref || \"number\" in ref){\n content += `citation_number=${ref.issue || ref.number};`;\n }\n /*content += `citation_first_page=${};`;\n content += `citation_publication_date=${};`;*/\n return content;\n}\n","import html from \"./components/html\";\nimport styles from \"./components/styles\";\nimport citeData from \"./components/cite-data\";\nimport meta from \"./components/meta\";\nimport header from \"./components/header\";\nimport appendix from \"./components/appendix\";\nimport footer from \"./components/footer\";\nimport citation from \"./components/citation\";\nimport markdown from \"./components/markdown\";\nimport code from \"./components/code\";\nimport testData from \"./test-data\";Line truncated
{"version":3,"file":null,"sources":["../components/meta.js","../index.js","../components/html.js","../components/styles.js","../node_modules/bibtex-parse-js/bibtexParse.js","../components/cite-data.js","../components/header.js","../components/appendix.js","../components/footer.js","../components/citation.js","../node_modules/marked/lib/marked.js","../components/markdown.js","../node_modules/prismjs/prism.js","../components/code.js","../test-data.js"],"sourcesContent":["export default function(dom, data) {\n let head = dom.querySelector(\"head\");\n \n appendHtml(head, `\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=Edge,chrome=1\">\n <link rel=\"icon\" type=\"image/png\" href=\"/favicon.png\">\n <link href=\"/rss.xml\" rel=\"alternate\" type=\"application/rss+xml\" title=\"Articles from Distill\">\n <link rel=\"canonical\" href=\"${data.url}\">\n <title>${data.title}</title>\n `);\n\n appendHtml(head, `\n <!-- https://schema.org/Article -->\n <meta property=\"article:published\" itemprop=\"datePublished\" content=\"${data.publishedDate}\" />\n <meta property=\"article:modified\" itemprop=\"dateModified\" content=\"${data.updatedDate}\" />\n `);\n data.authors.forEach((a) => {\n appendHtml(head, `\n <meta property=\"article:author\" content=\"${a.firstName} ${a.lastName}\" />`)\n });\n\n appendHtml(head, `\n <!-- https://developers.facebook.com/docs/sharing/webmasters#markup -->\n <meta property=\"og:type\" content=\"article\"/>\n <meta property=\"og:title\" content=\"${data.title}\"/>\n <meta property=\"og:description\" content=\"${data.description}\">\n <meta property=\"og:url\" content=\"${data.url}\"/>\n <meta property=\"og:image\" content=\"${data.url}/thumbnail.png\"/>\n <meta property=\"og:locale\" content=\"en_US\" />\n <meta property=\"og:site_name\" content=\"Distill\" />\n `);\n\n appendHtml(head, `\n <!-- https://dev.twitter.com/cards/types/summary -->\n <meta name=\"twitter:card\" content=\"summary_large_image\">\n <meta name=\"twitter:title\" content=\"${data.title}\">\n <meta name=\"twitter:description\" content=\"${data.description}\">\n <meta name=\"twitter:url\" content=\"${data.url}\">\n <meta name=\"twitter:image\" content=\"${data.url}/thumbnail.png\">\n <meta name=\"twitter:image:width\" content=\"560\">\n <meta name=\"twitter:image:height\" content=\"295\">\n `);\n\n appendHtml(head, `\n <!-- https://scholar.google.com/intl/en/scholar/inclusion.html#indexing -->\n <meta name=\"citation_title\" content=\"${data.title}\">\n <meta name=\"citation_publication_date\" content=\"${data.publishedYear}/${data.publishedMonthPadded}/${data.publishedDayPadded}\">\n <meta name=\"citation_fulltext_html_url\" content=\"${data.url}\">\n <meta name=\"citation_volume\" content=\"${data.volume}\">\n <meta name=\"citation_issue\" content=\"${data.issue}\">\n <meta name=\"citation_journal_title\" content=\"${data.journal.name}\">\n <meta name=\"citation_journal_abbrev\" content=\"${data.journal.nameAbbrev}\"/>\n <meta name=\"citation_firstpage\" content=\"e${data.doiSuffix}\"/>\n <meta name=\"citation_doi\" content=\"${data.doi}\">\n <meta name=\"citation_issn\" content=\"${data.journal.issn}\">\n <meta name=\"citation_publisher\" content=\"${data.journal.publisher}\"/>\n `);\n data.authors.forEach((a) => {\n appendHtml(head, `\n <meta name=\"citation_author\" content=\"${a.lastName}, ${a.firstName}\" />\n <meta name=\"citation_author_institution\" content=\"${a.affiliation}\"/>\n `)\n });\n\n Object.keys(data.citations).forEach(key => {\n console.log(key);\n appendHtml(head, `\n <meta name=\"citation_reference\" content=\"${citation_meta_content(data.citations[key])}\" >\n `);\n });\n}\n\n\nfunction appendHtml(el, html) {\n el.innerHTML += html;\n}\n\nfunction citation_meta_content(ref){\n var content = `citation_title=${ref.title};`;\n ref.author.split(\" and \").forEach(author => {\n content += `citation_author=${author.trim()};`;\n });\n if (\"journal\" in ref){\n content += `citation_journal_title=${ref.journal};`;\n }\n if (\"volume\" in ref) {\n content += `citation_volume=${ref.volume};`;\n }\n if (\"issue\" in ref || \"number\" in ref){\n content += `citation_number=${ref.issue || ref.number};`;\n }\n /*content += `citation_first_page=${};`;\n content += `citation_publication_date=${};`;*/\n return content;\n}\n","import html from \"./components/html\";\nimport styles from \"./components/styles\";\nimport citeData from \"./components/cite-data\";\nimport meta from \"./components/meta\";\nimport header from \"./components/header\";\nimport appendix from \"./components/appendix\";\nimport footer from \"./components/footer\";\nimport citation from \"./components/citation\";\nimport markdown from \"./components/markdown\";\nimport code from \"./components/code\";\nimport testData from \"./test-data\";Line truncated
+82 -48
View File
@@ -17,21 +17,28 @@
</style>
<dt-header></dt-header>
<dt-article>
<h1>How to Create a Distill Article</h1>
<h2>A collection of examples and best practices for creating interactive explanatory articles using the Distill web framework</h2>
<!-- <dt-byline></dt-byline> -->
<p>Distill ships with a CSS framework and a collection of custom web components that make building interactive academic articles easier than with raw HTML, CSS and JavaScript. This reference article details several examples and best practices for how to use both frameworks.</p>
<hr>
<h2>Getting Started</h2>
<p>If you’re using Chrome as your development browser, here is the smallest distill post.</p>
<dt-article markdown>
# How to Create a Distill Article
## A collection of examples and best practices for creating interactive explanatory articles using the Distill web framework
Distill ships with a CSS framework and a collection of custom web components that make building interactive academic articles easier than with raw HTML, CSS and JavaScript. This reference article details several examples and best practices for how to use both frameworks.
---
## Getting Started
If you’re using Chrome as your development browser, here is the smallest distill post.
<dt-code block language="html">
&lt;script src="../dist/template.min.js"&gt;&lt;/script&gt;
&lt;dt-article&gt;
&lt;h1&gt;Hello World&lt;/h1&gt;
&lt;/dt-article&gt;
</dt-code>
<p>However, this omits some required html tags that might cause rendering problems during development if you’re using a browser other than Chrome. These missing tags will be added during publishing, so if the above works for you, feel free to use it. If you are having issues, try adding <dt-code>doctype</dt-code> and <dt-code>meta</dt-code> tags explicitly.</p>
However, this omits some required html tags that might cause rendering problems during development if you’re using a browser other than Chrome. These missing tags will be added during publishing, so if the above works for you, feel free to use it. If you are having issues, try adding <dt-code>doctype</dt-code> and <dt-code>meta</dt-code> tags explicitly.
<dt-code block language="html">
&lt;!doctype html&gt;
&lt;meta charset="utf-8"&gt;
@@ -40,23 +47,32 @@
&lt;h1&gt;Hello World&lt;/h1&gt;
&lt;/dt-article&gt;
</dt-code>
<p>A typical distill post will be quite a bit longer than this though. Below is a more complete example. Don’t worry if some of the tags don’t make sense, they’re all documented further in this post.</p>
A typical distill post will be quite a bit longer than this though. Below is a more complete example. Don’t worry if some of the tags don’t make sense, they’re all documented further in this post.
<dt-code block language="html">
&lt;!doctype html&gt;
&lt;meta charset="utf-8"&gt;
&lt;script src="../dist/template.min.js"&gt;&lt;/script&gt;
&lt;dt-front-matter&gt;
{
title: "Article Title",
description: "Description of the post"
}
title: Article Title
description: Description of the post
authors:
Chris Olah:
personalUrl: http://colah.github.io
affiliation: Google Brain
affiliationURL: http://g.co/brain
Shan Carter:
personalUrl: http://shancarter.com
affiliation: Google Brain
affiliationURL: http://g.co/brain
&lt;/dt-front-matter&gt;
&lt;dt-article&gt;
&lt;h1&gt;Hello World&lt;/h1&gt;
&lt;h2&gt;A description of the article&lt;/h2&gt;
&lt;dt-byline&gt;&lt;/dt-byline&gt;
&lt;p&gt;This is the first paragraph of the article.&lt;/p&gt;
&lt;p&gt;We can also cite &lt;dt-cite&gt;@gregor2015draw&lt;/dt-cite&gt; external publications.&lt;/p&gt;
&lt;p&gt;We can also cite &lt;dt-cite article="gregor2015draw"&gt;&lt;/dt-cite&gt; external publications.&lt;/p&gt;
&lt;/dt-article&gt;
&lt;dt-bibliography&gt;
@article{gregor2015draw,
@@ -67,9 +83,13 @@
}
&lt;/dt-bibliography&gt;
</dt-code>
<hr>
<h2>Markdown</h2>
<p>Markdown is supported as an alternative to html for the <dt-code language="html">&lt;dt-article&gt;</dt-code> element. </p>
---
## Markdown
Markdown is supported as an alternative to html for the <dt-code language="html">&lt;dt-article&gt;</dt-code> element.
<dt-code block language="html">
&lt;!doctype html&gt;
&lt;meta charset="utf-8"&gt;
@@ -83,51 +103,65 @@
&lt;/dt-article&gt;
&lt;dt-bibliography&gt;&lt;/dt-bibliography&gt;
</dt-code>
<p>We use <a href="https://github.com/chjj/marked">marked</a> as the rendering engine, with <a href="https://help.github.com/articles/basic-writing-and-formatting-syntax/">github flavored markdown</a> and <a href="https://daringfireball.net/projects/smartypants/">smartypants</a> enabled. In development mode the markdown is translated in the client after the dom content has loaded, but when published, the translation is precompiled.</p>
<hr>
<h2>Front Matter</h2>
<p>You’ll need to describe some data about you post — title, description, authors, etc. For this use the <dt-code language="html">&lt;dt-front-matter&gt;</dt-code> tag.</p>
We use <a href="https://github.com/chjj/marked">marked</a> as the rendering engine, with <a href="https://help.github.com/articles/basic-writing-and-formatting-syntax/">github flavored markdown</a> and <a href="https://daringfireball.net/projects/smartypants/">smartypants</a> enabled. In development mode the markdown is translated in the client after the dom content has loaded, but when published, the translation is precompiled.
---
## Front Matter
You’ll need to describe some data about you post — title, description, authors, etc. For this use the <dt-code language="html">&lt;dt-front-matter&gt;</dt-code> tag.
<dt-code block language="html">
&lt;dt-front-matter&gt;
{
title: "Article Title",
description: "Description of the post",
authors: []
}
title: Article Title
description: Description of the post
authors:
Chris Olah:
personalUrl: http://colah.github.io
affiliation: Google Brain
affiliationURL: http://g.co/brain
Shan Carter:
personalUrl: http://shancarter.com
affiliation: Google Brain
affiliationURL: http://g.co/brain
&lt;/dt-front-matter&gt;
</dt-code>
<p>You can also use an external JSON file if you like. We will automatically make a request for a <dt-code>./distill.json</dt-code> file if there is no <dt-code language="html">&lt;dt-front-matter&gt;</dt-code> element on the page, or you can point to another file with the <dt-code>src</dt-code> attribute. In production, these files will be inlined into the document.</p>
<p>You can also use an external JSON file if you like. We will automatically make a request for a <dt-code>distill.json</dt-code> file if there is no <dt-code language="html">&lt;dt-front-matter&gt;</dt-code> element on the page, or you can point to another file with the <dt-code>src</dt-code> attribute. In production, these files will be inlined into the document.</p>
<dt-code block language="html">
&lt;dt-front-matter src="./distill.json"&gt;&lt;/dt-front-matter&gt;
</dt-code>
<hr>
<h2>Citations</h2>
<p>Bibtex is the supported way of making academic citations. You first need have a global definition of all your possible citations. This can either be inlined in the document, or it can reference an external bibtex file.</p>
<p>Bibtex is the supported way of making academic citations. You first need have a global definition of all your possible citations. For this we’ll use the <dt-code language="html">&lt;dt-bibliography&gt;</dt-code> element.</p>
<dt-code block language="html">
&lt;dt-bibliography&gt;
@article{gregor2015draw,
title={DRAW: A recurrent neural network for image generation},
author={Gregor, Karol and Danihelka, Ivo and Graves, Alex and Rezende, Danilo Jimenez and Wierstra, Daan},
journal={arXivreprint arXiv:1502.04623},
year={2015}
}
@article{mercier2011humans,
title={Why do humans reason? Arguments for an argumentative theory},
author={Mercier, Hugo and Sperber, Dan},
journal={Behavioral and brain sciences},
volume={34},
number={02},
pages={57--74},
year={2011},
publisher={Cambridge Univ Press}
}
@article{gregor2015draw,
title={DRAW: A recurrent neural network for image generation},
author={Gregor, Karol and Danihelka, Ivo and Graves, Alex and Rezende, Danilo Jimenez and Wierstra, Daan},
journal={arXivreprint arXiv:1502.04623},
year={2015}
}
@article{mercier2011humans,
title={Why do humans reason? Arguments for an argumentative theory},
author={Mercier, Hugo and Sperber, Dan},
journal={Behavioral and brain sciences},
volume={34},
number={02},
pages={57--74},
year={2011},
publisher={Cambridge Univ Press}
}
&lt;/dt-bibliography&gt;
</dt-code>
<p>Citations are then used with the <dt-code language="html">&lt;dt-cite&gt;</dt-code> tag.</p>
<p>Like with the <dt-code language="html">&lt;dt-front-matter&gt;</dt-code> element, you can alternatively reference an external file with the <dt-code>src</dt-code> attribute. If no <dt-code language="html">&lt;dt-bibliography&gt;</dt-code> element is found on the page, a request will automatically be made for <dt-code>bibliography.bib</dt-code>. In production, these files will be inlined into the document.</p>
<dt-code block language="html">
&lt;dt-cite&gt;gregor2015draw&lt;/dt-cite&gt;
&lt;dt-bibliography src="bibliography.bib"&gt;&lt;/dt-bibliography&gt;
</dt-code>
<p>Citations are then used in the article body with the <dt-code language="html">&lt;dt-cite&gt;</dt-code> tag. The <dt-code>article</dt-code> attribute is a reference to the id provided in the bibiography.</p>
<dt-code block language="html">
&lt;dt-cite article="gregor2015draw"&gt;&lt;/dt-cite&gt;
</dt-code>
<p>Take a look at this paper <dt-cite>gregor2015draw</dt-cite>.</p>
<hr>
<h2>Code Blocks</h2>