Markdown tutorial

This commit is contained in:
Shan Carter
2017-01-05 14:37:23 -08:00
parent c3c71f186e
commit 8b12e0180b
4 changed files with 90 additions and 54 deletions
+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 youre 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 youre 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 youre 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 youre 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. Dont worry if some of the tags dont make sense, theyre 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. Dont worry if some of the tags dont make sense, theyre 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>Youll 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
Youll 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 well 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>