1 | <!doctype html>
|
2 | <meta charset="utf-8">
|
3 | <script src="../dist/template.js"></script>
|
4 | <style>
|
5 | .fake-img {
|
6 | background: #bbb;
|
7 | border: 1px solid rgba(0, 0, 0, 0.1);
|
8 | box-shadow: 0 0px 4px rgba(0, 0, 0, 0.1);
|
9 | margin-bottom: 12px;
|
10 | }
|
11 | .fake-img p {
|
12 | font-family: monospace;
|
13 | color: white;
|
14 | text-align: left;
|
15 | margin: 12px 0;
|
16 | text-align: center;
|
17 | font-size: 16px;
|
18 | }
|
19 | </style>
|
20 |
|
21 | <dt-article>
|
22 | <h1>How to Create a Distill Article</h1>
|
23 | <h2>A collection of examples and best practices for creating interactive explanatory articles using the Distill web framework</h2>
|
24 | <hr>
|
25 | <h2>Getting Started</h2>
|
26 | <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. At its simplest, each distill post is just a single HTML file with one special script tag.</p>
|
27 | <dt-code block language="html">
|
28 | <!doctype html>
|
29 | <meta charset="utf-8">
|
30 | <script src="http://distill.pub/template.js"></script>
|
31 |
|
32 | <dt-article>
|
33 | <h1>Hello World</h1>
|
34 | </dt-article>
|
35 | </dt-code>
|
36 | <p>This script tag will modify your post in your browser, adding the distill styling and functionality. When we publish your article, we will bake in these transformations, but during development it’s handy to be able to preview it locally (It even works without a web server).</p>
|
37 | <p>A typical distill post will be quite a bit longer than the one above. 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>
|
38 | <dt-code block language="html">
|
39 | <!doctype html>
|
40 | <meta charset="utf-8">
|
41 | <script src="http://distill.pub/template.js"></script>
|
42 |
|
43 | <script type="text/front-matter">
|
44 | title: Article Title
|
45 | description: Description of the post
|
46 | published: Jan 10, 2017
|
47 | authors:
|
48 | - Chris Olah: http://colah.github.io
|
49 | - Shan Carter: http://shancarter.com
|
50 | affiliations:
|
51 | - Google Brain: http://g.co/brain
|
52 | - Google Brain: http://g.co/brain
|
53 | </script>
|
54 |
|
55 | <dt-article>
|
56 | <h1>Hello World</h1>
|
57 | <h2>A description of the article</h2>
|
58 | <dt-byline></dt-byline>
|
59 | <p>This is the first paragraph of the article.</p>
|
60 | <p>We can also cite <dt-cite key="gregor2015draw"></dt-cite> external publications.</p>
|
61 | </dt-article>
|
62 |
|
63 | <dt-appendix>
|
64 | </dt-appendix>
|
65 |
|
66 | <script type="text/bibliography">
|
67 | @article{gregor2015draw,
|
68 | title={DRAW: A recurrent neural network for image generation},
|
69 | author={Gregor, Karol and Danihelka, Ivo and Graves, Alex and Rezende, Danilo Jimenez and Wierstra, Daan},
|
70 | journal={arXivreprint arXiv:1502.04623},
|
71 | year={2015},
|
72 | url={https://arxiv.org/pdf/1502.04623.pdf}
|
73 | }
|
74 | </script>
|
75 | </dt-code>
|
76 | |
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 | <hr>
|
95 | <h2>Project Structure</h2>
|
96 | <p>Because all the templating is delivered via a script tag, you are generally free to develop however you are most comfortable. The only requirements are that each article must be its own Github repository. The simplest setup would be a repository that contained a single HTML file, along with any additional assets, like images or javascript files. Note, in this default setup, all files in the root of the repository will be published. Note, also, in this configuration you generally will not even need to run a static local webserver. You can just open the <dt-code>index.html</dt-code> file in your browser to preview.</p>
|
97 |
|
98 | <dt-code block language="html">
|
99 | image.jpg
|
100 | index.html
|
101 | script.js
|
102 | </dt-code>
|
103 |
|
104 | <p>If you have a more complicated build process, or have files you don’t want published, put your output in a <dt-code>public</dt-code> folder and we will only publish its contents.</p>
|
105 |
|
106 | <dt-code block language="html">
|
107 | build/
|
108 | _index.html
|
109 | package.json
|
110 | public/
|
111 | index.html
|
112 | image.jpg
|
113 | </dt-code>
|
114 |
|
115 | <hr>
|
116 | <h2>Front Matter</h2>
|
117 | <p>You’ll need to describe some data about you post — title, description, authors, etc. For this use the <dt-code language="html"><script type="text/front-matter"></dt-code> tag.</p>
|
118 | <dt-code block language="html">
|
119 | <script type="text/front-matter">
|
120 | title: Article Title
|
121 | description: Description of the post
|
122 | authors:
|
123 | - Chris Olah: http://colah.github.io
|
124 | - Shan Carter: http://shancarter.com
|
125 | affiliations:
|
126 | - Google Brain: http://g.co/brain
|
127 | - Google Brain: http://g.co/brain
|
128 | </script>
|
129 | </dt-code>
|
130 | |
131 |
|
132 |
|
133 |
|
134 | <hr>
|
135 | <h2>Citations</h2>
|
136 | <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"><script type="text/bibliography"></dt-code> element.</p>
|
137 | <dt-code block language="html">
|
138 | <script type="text/bibliography">
|
139 | @article{gregor2015draw,
|
140 | title={DRAW: A recurrent neural network for image generation},
|
141 | author={Gregor, Karol and Danihelka, Ivo and Graves, Alex and Rezende, Danilo Jimenez and Wierstra, Daan},
|
142 | journal={arXivreprint arXiv:1502.04623},
|
143 | year={2015},
|
144 | url={https://arxiv.org/pdf/1502.04623.pdf},
|
145 | }
|
146 | </script>
|
147 | </dt-code>
|
148 | <p>(We strongly encourage you to populate the <dt-code>url</dt-code> bibtex field where possible so that we can provide links for citations.)</p>
|
149 | |
150 |
|
151 |
|
152 |
|
153 | <p>Citations are then used in the article body with the <dt-code language="html"><dt-cite></dt-code> tag. The <dt-code>key</dt-code> attribute is a reference to the id provided in the bibiography. The <dt-code>key</dt-code> attribute can take multiple ids, separated by commas.</p>
|
154 | <dt-code block language="html">
|
155 | <dt-cite key="gregor2015draw"></dt-cite>
|
156 | </dt-code>
|
157 | <script type="text/bibliography">
|
158 | @article{gregor2015draw,
|
159 | title={DRAW: A recurrent neural network for image generation},
|
160 | author={Gregor, Karol and Danihelka, Ivo and Graves, Alex and Rezende, Danilo Jimenez and Wierstra, Daan},
|
161 | journal={arXivreprint arXiv:1502.04623},
|
162 | year={2015},
|
163 | url={https:
|
164 | }
|
165 | </script>
|
166 | <p>The citation is presented inline like this: <dt-cite key="gregor2015draw"></dt-cite> (a number that displays more information on hover). If you have an appendix, a bibliography is automatically created and populated in it.</p>
|
167 | <p>Distill chose a numerical inline citation style to improve readability of citation dense articles and because many of the benefits of longer citations are obviated by dispalying more information on hover. However, we consider it good style to mention author last names if you discuss something at length and it fits into the flow well -- the authors are human and it's nice for them to have the community associate them with their work.</p>
|
168 |
|
169 |
|
170 | <hr>
|
171 | <h2>Footnotes</h2>
|
172 | <p>Just wrap the text you would like to show up in a footnote in a <dt-code language="html"><dt-fn></dt-code> tag. The number of the footnote will be automatically generated. <dt-fn>This text will be shown on hover.</dt-fn></p>
|
173 | <dt-code block language="html">
|
174 | <dt-fn>This will become a hoverable footnote.</dt-fn>
|
175 | </dt-code>
|
176 | <dt-footnote-body ref="blah"></dt-footnote-body>
|
177 |
|
178 | <hr>
|
179 | <h2>Code Blocks</h2>
|
180 | <p>Syntax highlighting is provided within <dt-code language="html"><dt-code></dt-code> tags. An example of inline code snippets: <dt-code language="html"><dt-code language="html">let x = 10;</dt-code></dt-code>. For larger blocks of code, add a <dt-code>block</dt-code> attribute:</p>
|
181 | <dt-code block language="html">
|
182 | <dt-code block language="javascript">
|
183 | var x = 25;
|
184 | function(x){
|
185 | return x * x;
|
186 | }
|
187 | </dt-code>
|
188 | </dt-code>
|
189 |
|
190 | |
191 |
|
192 |
|
193 |
|
194 | <hr>
|
195 | <h2>Layouts</h2>
|
196 | <p>The main text column is referred to as the body. It is the assumed layout of any direct descendents of the <code>dt-article</code> element.</p>
|
197 | <div class="fake-img l-body"><p>.l-body</p></div>
|
198 | <p>For images you want to display a little larger, try these:</p>
|
199 | <div class="fake-img l-middle"><p>.l-middle</p></div>
|
200 | <div class="fake-img l-page"><p>.l-page</p></div>
|
201 | <p>All of these have an <dt-code>outset</dt-code> variant if you want to poke out from the body text a little bit. For instance:</p>
|
202 | <div class="fake-img l-body-outset"><p>.l-body-outset</p></div>
|
203 | <div class="fake-img l-middle-outset"><p>.l-middle-outset</p></div>
|
204 | <div class="fake-img l-page-outset"><p>.l-page-outset</p></div>
|
205 | <p>Occasionally you’ll want to use the full browser width. For this, use <dt-code>.l-screen</dt-code>. You can also inset the element a little from the edge of the browser by using the inset variant.</p>
|
206 | <div class="fake-img l-screen"><p>.l-screen</p></div>
|
207 | <div class="fake-img l-screen-inset"><p>.l-screen-inset</p></div>
|
208 | <p>Often you want to position smaller images so as not to completely interrupt the flow of your text. Or perhaps you want to put some text in the margin as an aside or to signal that it’s optional content. For these cases we’ll use the float-based layouts.</p>
|
209 | <div class="fake-img l-body side"><p>.l-body.side</p></div>
|
210 | <div class="fake-img l-middle side"><p>.l-middle.side</p></div>
|
211 | <div class="fake-img l-page side"><p>.l-page.side</p></div>
|
212 | <p>They are all floated to the right and anchored to the right-hand edge of the position you specify. By default, each will take up approximately half of the width of the standard layout position, but you can override the width with a more specific selector. </p>
|
213 | <div class="fake-img l-gutter"><p>.l-gutter</p></div>
|
214 | <p>The final layout is for marginalia, asides, and footnotes. It does not interrupt the normal flow of <code>.l-body</code> sized text except on mobile screen sizes.</p>
|
215 | <p>You can also use an alternate centered layout by adding a <dt-code>centered</dt-code> class to the <dt-code>dt-article</dt-code> element.</p>
|
216 | <dt-code block language="html">
|
217 | <dt-article class="centered">
|
218 | <h1>Hello World</h1>
|
219 | </dt-article>
|
220 | </dt-code>
|
221 | <p>You can toggle it on this article by <a onclick="document.querySelector('dt-article').classList.toggle('centered');">clicking here</a></p>
|
222 | <section class="centered">
|
223 |
|
224 | </section>
|
225 |
|
226 | <hr>
|
227 | <h2>Appendix</h2>
|
228 |
|
229 | <p>An appendix can be added after your article, using the <dt-code language="html"><dt-appendix></dt-code> tag.</p>
|
230 |
|
231 | <dt-code block language="html">
|
232 | <dt-article>
|
233 | ...
|
234 | </dt-article>
|
235 |
|
236 | <dt-appendix>
|
237 | <h3>Appendix Section Title</h3>
|
238 | <p>section content<p>
|
239 | </dt-appendix>
|
240 | </dt-code>
|
241 |
|
242 | <p>You may wish to include the following sections in your appendix:</p>
|
243 | <ul>
|
244 | <li><b>Acknowledgments</b>: This is a place to recognize people and institutions. It may also be a good place to acknowledge and cite software that makes your work possible (eg. TensorFlow, OpenAI Gym).</li>
|
245 | <li><b>Author Contributions</b>: We strongly encourage you to include an author contributions statement briefly describing what each author did.</li>
|
246 | </ul>
|
247 |
|
248 | <hr>
|
249 | <h2>And You’re Off</h2>
|
250 | <p>That should do it. If you have any questions or bugs to file, feel free to <a href="https://github.com/distillpub/template/issues/new">open an issue on GitHub</a>.</p>
|
251 |
|
252 |
|
253 |
|
254 |
|
255 | </dt-article>
|