content overhaul for first post
[kengrimes.com/content.git] / content.org
1 #+hugo_base_dir: .
2 #+hugo_level_offset: 0
3 #+seq_todo: TODO DRAFT DONE
4 #+startup: indent showall
5
6 * Home
7 :PROPERTIES:
8 :EXPORT_HUGO_SECTION:
9 :END:
10 ** Computers are the Devil
11 :PROPERTIES:
12 :EXPORT_HUGO_CUSTOM_FRONT_MATTER: :header /img/blog.png
13 :EXPORT_FILE_NAME: _index
14 :EXPORT_HUGO_MENU: :menu "main" :weight -1 :title Blog
15 :END:
16
17 ** DONE Using ox-hugo To Build Websites with Emacs :org:emacs:hugo:@tutorial:
18 CLOSED: [2018-04-11 Wed 21:56]
19 :PROPERTIES:
20 :EXPORT_FILE_NAME: ox-hugo-tutorial
21 :EXPORT_HUGO_CUSTOM_FRONT_MATTER: :caption "Exporting to Hugo's Blackfriday Markdown from Orgmode"
22 :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :header /img/org.png
23 :END:
24 This article explains in detail the process of setting up a bare-bones website
25 using Hugo and org-mode. My goal in writing this is to provide readers with a
26 superior understanding of the fundamentals of this workflow. It is by no means
27 an exhaustive explanation of org-mode or Emacs, but should give readers of any
28 skill level a strong foundation to apply their own knowledge and techniques to
29 the Emacs-Hugo toolchain.
30
31 I assume only beginner-level knowledge of Emacs.
32
33 *** Intro & Setup
34 [[https://github.com/kaushalmodi][Kaushal Modi]] made ox-hugo by extending org's ox-blackfriday package, providing
35 an impressive amount of features for organizing blog text and linked data with
36 Hugo. He maintains [[https://ox-hugo.scripter.co/][great documentation]] and ample [[https://github.com/kaushalmodi/ox-hugo/tree/master/test/site/content-org][examples]] for using the
37 package. I will explain my own workflow here, but for an exhaustive (though
38 terse) reference, I highly recommend Modi's [[https://ox-hugo.scripter.co/test/][test site]] and [[https://raw.githubusercontent.com/kaushalmodi/ox-hugo/master/test/site/content-org/all-posts.org][post source]] org file,
39 which contain demonstrations and tests for all of ox-hugo's features.
40
41 After issuing the Emacs command ~M-x package-install RET ox-hugo RET~, you'll
42 need to ~require~ it. You can do this by running ~M-: (require 'ox-hugo)~, but
43 you'll want to add it to your configuration as explained [[https://ox-hugo.scripter.co/doc/usage/][here]]. Once this is
44 done, using ox-hugo is just a matter of making an org file and writing
45 content. Org's format is very straightforward, and is designed to make sense to
46 the reader even if they're unfamiliar with the formal syntax. For instance,
47 #+begin_src org
48 ,* My food
49 | Where's My Food? | Fridge | Counter | Mouth | Total |
50 | Oranges | 1 | 3 | 0 | :=vsum($2..$4) |
51 | Marshmallows | 0 | 100 | 20 | :=vsum($2..$4) |
52 | Brussel Sprouts | 32 | 4 | 0 | :=vsum($2..$4) |
53 #+end_src
54 Produces a dynamic spreadsheet table in org-mode that exports to HTML like this:
55 **** My food
56 | Where's My Food? | Fridge | Counter | Mouth | Total |
57 | Oranges | 1 | 3 | 0 | 4 |
58 | Marshmallows | 0 | 100 | 20 | 120 |
59 | Brussel Sprouts | 32 | 4 | 0 | 36 |
60 #+TBLFM: @2$5=vsum($2..$4)::@3$5=vsum($2..$4)::@4$5=vsum($2..$4)
61
62 If you're already familiar with org-mode, the benefits are obvious and creating
63 content is fairly trivial. Org-mode is, however, a complex and expansive program
64 with many features, and its learning curve can appear daunting at first glance.
65 Using ox-hugo is a great way to learn the format, since it gives the author a
66 command-center view of their entire content hierarchy, much like a traditional
67 database, but in a flat format that's much easier to read and understand. Org
68 features present themselves naturally, and the author can easily visualize the
69 correspondence between the org format and the output on their webpage.
70
71 Just take a look at the [[https://www.kengrimes.com/gitweb/?p=kengrimes.com/content.git;a=blob_plain;f=content.org;hb=HEAD][org file]] for this webpage. Search for "ox-hugo is super
72 cool!" and you should find this very paragraph.
73
74 Eventually you'll want to [[https://orgmode.org/manual/][read the manual]], though. You may access it in Emacs
75 with ~M-x org-info~.
76
77 *** Making a New Blog
78 Compared to a generic org file, the only important "extra" data that ox-hugo
79 needs to properly export data is a ~:PROPERTIES: ... :END:~ block with
80 definitions used for Hugo's [[https://gohugo.io/content-management/front-matter/][front matter]] (used for associating a title, header,
81 or other custom data with the page it generates). ~:PROPERTIES:~ blocks are
82 common in org for defining arbitrary metadata about sections, and can be used in
83 many such ways. Providing an ~:EXPORT_FILE_NAME:~ definition signals to ox-hugo
84 that this heading is available for export, and that it should be exported to a
85 markdown file with the name provided. For example, the ~:PROPERTIES:~ block of
86 the page you're currently reading looks like this:
87 #+begin_src org
88 :PROPERTIES:
89 :EXPORT_FILE_NAME: ox-hugo
90 :EXPORT_HUGO_CUSTOM_FRONT_MATTER: :caption "Exporting to Hugo's Blackfriday Markdown from Orgmode"
91 :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :header /img/org.png
92 :END:
93 #+end_src
94 The ~:caption~ and ~:header~ variables are optional definitions allowed by the
95 Speedy theme of this website, but the filename is the only required property for
96 ox-hugo. So, as a minimal example, here's what a new blog might look like in its
97 entirety:
98 #+begin_src org -n
99 #+hugo_base_dir: .
100 ,* Home
101 :PROPERTIES:
102 :EXPORT_HUGO_SECTION:
103 :EXPORT_FILE_NAME: _index
104 :END:
105 This is the home of my blog!
106 ,** I have herpes
107 :PROPERTIES:
108 :EXPORT_FILE_NAME: herpes
109 :END:
110 Someone gave me herpes! Oh no!
111 #+end_src
112 The org file can be placed in any directory so long as ~HUGO_BASE_DIR~ correctly
113 identifies the Hugo project's root directory. This path definition is required
114 for any valid ox-hugo file, and in the example above uses ~.~ as the base
115 directory, which assumes that the file will be placed in the hugo project's base
116 directory. If you saved this file as hugotest.org, exported it with org's
117 exporter ~C-c C-e~ and selected the Hugo output ~H~ and the All Subtrees To
118 Files option ~A~, you'd wind up with the following files in your directory:
119 #+begin_src
120 .
121 ├── content
122 │   ├── _index.md
123 │   └── herpes.md
124 └── hugotest.org
125 #+end_src
126 Most sites will be more than a blog, though, and will want multiple sections. In
127 fact, many sites are made up of nothing but a slew of sections that users
128 navigate between with some built-in menu. So a more functional minimal example
129 would be the following:
130 #+begin_src org -n
131 #+hugo_base_dir: .
132 ,* My Homepage
133 :PROPERTIES:
134 :EXPORT_HUGO_SECTION:
135 :EXPORT_FILE_NAME: _index
136 :EXPORT_HUGO_MENU: :menu "main"
137 :END:
138 This is the home of my blog!
139 ,* My Blog
140 :PROPERTIES:
141 :EXPORT_HUGO_SECTION: posts
142 :END:
143 ,** My Blog Homepage
144 :PROPERTIES:
145 :EXPORT_HUGO_MENU: :menu "main"
146 :EXPORT_FILE_NAME: _index
147 :END:
148 Man, look at all my blog posts.
149 ,** I have herpes
150 :PROPERTIES:
151 :EXPORT_FILE_NAME: herpes
152 :END:
153 Someone gave me herpes! Oh no!
154 #+end_src
155 Which yields the following:
156 #+begin_src
157 .
158 ├── content
159 │   ├── _index.md
160 │   └── posts
161 │   ├── herpes.md
162 │   └── _index.md
163 └── hugotest.org
164 #+end_src
165 As you might expect, this structure adheres to the Hugo [[https://gohugo.io/content-management/organization/][content management]]
166 scheme. Additionally, the index files have been marked with menu metadata, which
167 allows Hugo themes to automatically generate navigation menus from the markdown
168 files. Hereafter, making new blog posts is as simple as adding new sub-headings
169 under the "My Blog" heading, and exporting. As you can see, this is suitable for
170 defining the hierarchical structure of any general website, not just
171 blogs. Org-mode and Hugo just make creating new pages so simple and
172 well-structured that providing content is all that's required for a new page,
173 blog entry, or entirely new site section. If you can blog with ox-hugo, you can
174 deftly deploy any manner of web content, or even develop entire websites as
175 naturally as you make blog posts. Any tool that can turn blogging and web
176 development into the same task is quite an achievement!
177
178 Of course, themes to style this content are another can of worms entirely, but
179 it is sufficient for now to mention that Hugo makes [[https://gohugo.io/themes/installing-and-using-themes/][using themes]] as easy as
180 downloading one and specifying it in Hugo's config file.
181
182 One question you may ask is why the blog's homepage is not defined in the *My
183 Blog* heading. This is a fair question! Property blocks are inherited by
184 sub-headings, and as of the current version of ox-hugo even ~:EXPORT_HUGO_MENU:~
185 properties are inherited. This might be intended by the content creator, but
186 most likely you don't want every single post you make to be in the main menu. So
187 it makes sense to define all your pages, including the index, as a sub-heading
188 of the section definition (which specifies which sub-directory content will
189 output to).
190
191 To illustrate, let's assume you want to extend the previous site definition with
192 a section about fishsticks.
193 #+begin_src org -n 24
194 ,* Fishsticks
195 :PROPERTIES:
196 :EXPORT_HUGO_MENU: :menu "main"
197 :EXPORT_HUGO_SECTION: fishsticks
198 :EXPORT_FILE_NAME: _index
199 :END:
200 This section devoted to Orson Wells, R.I.P.
201 ,** Van De Camps
202 :PROPERTIES:
203 :EXPORT_FILE_NAME: van-de-camps
204 :END:
205 If this is fish, I'll be a monkey's uncle.
206 ,** Gortons
207 :PROPERTIES:
208 :EXPORT_FILE_NAME: gortons
209 :END:
210 I think these gave me the herpes.
211 #+end_src
212 In this example, we've defined the main homepage of the section inside the
213 tier-1 heading for Fishsticks. This is valid, and produces the expected file output:
214 #+begin_src
215 .
216 ├── content
217 │   ├── fishsticks
218 │   │   ├── gortons.md
219 │   │   ├── _index.md
220 │   │   └── van-de-camps.md
221 │   ├── _index.md
222 │   └── posts
223 │   ├── herpes.md
224 │   └── _index.md
225 └── hugotest.org
226 #+end_src
227 But on inspection of the gortons.md file, we find the anomoly mentioned above:
228 #+begin_src markdown -n
229 ---
230 title: "Gortons"
231 author: ["Ken Grimes"]
232 draft: false
233 menu:
234 main:
235 weight: 2002
236 identifier: "gortons"
237 ---
238
239 I think these gave me the herpes.
240 #+end_src
241 Uh oh! Not only did these fishsticks give us herpes, they are now part of the
242 main menu. Tisk tisk. So if you use this workflow, be sure to put your index
243 pages in subheadings so that the tier-1 heading can be used for "global"
244 definitions that affect all of the pages.
245
246 Another question might be why the index pages are named *_index*. You can use
247 *index* instead of *_index*, the only difference is whether Hugo treats the
248 index page as a leaf, or a branch, when [[https://gohugo.io/content-management/page-bundles/][bundling resources]] for Hugo to query
249 during site generation. This is a relatively new addition to Hugo as of version
250 0.39, and isn't fully functional or integrated well into ox-hugo, so I simply
251 don't use it at the moment. I define all indexes as *_index* to make them
252 branches because, in future versions, packaging files within bundles like this
253 will provide a more stable way for Hugo themes to reference page- and
254 section-specific files that accompany the content. Currently, I store all such
255 files in the static folder, which is copied verbatim to the output directory by
256 Hugo when the site is built.
257
258 *** Hugo Setup
259 At this point, setting up Hugo and publishing is simple. [[https://gohugo.io/getting-started/installing/][Installing]] Hugo is
260 pretty straightforward on any Unix-like system with a package manager; it is
261 available on most distributions at this point. Windows installation is a bigger
262 pain in the ass, but you should be used to that if you're still in the
263 stone-age.
264
265 Using ~hugo new site .~ on the command-line will create a new hugo site in the
266 current directory, but ~hugo~ expects to be creating a new directory with this
267 command and will complain if it already exists. It also provides the ~--force~
268 option to allow creating a new site in an extant directory, but this too will
269 fail if the *content* subdirectory already exists (which ox-hugo will create
270 when you export).
271
272 So you have three choices:
273 1. run ~hugo new site /path/to/some-new-dir~ and move your org file to it
274 2. simply ~rm -Rf content/~ to remove the content directory ox-hugo created,
275 then run ~hugo new site --force .~
276 3. don't even bother with the ~hugo new site~ command, and make a *config.toml*
277 file manually.
278
279 It's convenient to do this through the ~hugo~ command because it will create
280 Hugo-specific subdirectories like archetypes, layouts, themes, etcetera, in
281 addition to populating a basic *config.toml* file. The subdirectories it creates
282 aren't necessary, but help illustrate Hugo's structure. In any case, you'll want
283 to wind up with a directory structure something like this (created with option 2
284 above, extending from previous examples):
285 #+begin_src
286 .
287 ├── archetypes
288 │   └── default.md
289 ├── config.toml
290 ├── content
291 ├── data
292 ├── hugotest.org
293 ├── layouts
294 ├── static
295 └── themes
296 #+end_src
297 Exporting with ox-hugo using ~C-c C-e H A~ again will, as expected, fill the
298 content directory with our content.
299 #+begin_src
300 .
301 ├── archetypes
302 │   └── default.md
303 ├── config.toml
304 ├── content
305 │   ├── fishsticks
306 │   │   ├── gortons.md
307 │   │   ├── _index.md
308 │   │   └── van-de-camps.md
309 │   ├── _index.md
310 │   └── posts
311 │   ├── herpes.md
312 │   └── _index.md
313 ├── data
314 ├── hugotest.org
315 ├── layouts
316 ├── static
317 └── themes
318 #+end_src
319 Now, running the command ~hugo~ with no subcommands will invoke the Hugo
320 generator on the current directory, and output finalized content in the
321 *public/* directory.
322 #+begin_src
323 .
324 ├── archetypes
325 │   └── default.md
326 ├── config.toml
327 ├── content
328 │   ├── fishsticks
329 │   │   ├── gortons.md
330 │   │   ├── _index.md
331 │   │   └── van-de-camps.md
332 │   ├── _index.md
333 │   └── posts
334 │   ├── herpes.md
335 │   └── _index.md
336 ├── data
337 ├── hugotest.org
338 ├── layouts
339 ├── public
340 │   ├── categories
341 │   │   └── index.xml
342 │   ├── fishsticks
343 │   │   └── index.xml
344 │   ├── index.xml
345 │   ├── posts
346 │   │   └── index.xml
347 │   ├── sitemap.xml
348 │   └── tags
349 │   └── index.xml
350 ├── static
351 └── themes
352 #+end_src
353 Hugo, by default, generates xml files that are suitable for RSS feeds. With a
354 theme installed, Hugo will produce more suitable web content (usually
355 HTML). You'll notice from this default output however that Hugo creates a
356 sitemap, and two directories for [[https://gohugo.io/content-management/taxonomies/][taxonomies]] that let you "tag" and "categorize"
357 content. The taxonomy index pages allow users to browse content by category or
358 tag. These taxonomies correspond to org-mode tags, and ox-hugo will
359 automatically associated tagged headings with the tags taxonomy, or the
360 categories taxonomy if prefixed with an @ symbol. You are free to define your
361 own taxonomies, and even disable the default "tags" and "categories" taxonomies,
362 but since org-mode tags directly translate to the default Hugo taxonomies, it
363 makes sense to just use the default taxonomies for now.
364
365 *** Example Hugo Site
366 As an example, let's add some tags and categories to our *hugotest.org* file:
367 #+begin_src org -n
368 #+hugo_base_dir: .
369 ,* My Homepage
370 :PROPERTIES:
371 :EXPORT_HUGO_SECTION:
372 :EXPORT_FILE_NAME: _index
373 :EXPORT_HUGO_MENU: :menu "main"
374 :END:
375 This is the home of my blog!
376 ,* My Blog
377 :PROPERTIES:
378 :EXPORT_HUGO_SECTION: posts
379 :END:
380 ,** My Blog Homepage
381 :PROPERTIES:
382 :EXPORT_HUGO_MENU: :menu "main"
383 :EXPORT_FILE_NAME: _index
384 :END:
385 Man, look at all my blog posts.
386 ,** I have herpes :@inanity:herpes:fear:
387 :PROPERTIES:
388 :EXPORT_FILE_NAME: herpes
389 :END:
390 Someone gave me herpes! Oh no!
391 ,* Fishsticks
392 :PROPERTIES:
393 :EXPORT_HUGO_MENU: :menu "main"
394 :EXPORT_HUGO_SECTION: fishsticks
395 :EXPORT_FILE_NAME: _index
396 :END:
397 This section devoted to Orson Wells, R.I.P.
398 ,** Van De Camps :@inanity:
399 :PROPERTIES:
400 :EXPORT_FILE_NAME: van-de-camps
401 :END:
402 If this is fish, I'll be a monkey's uncle.
403 ,** Gortons :@inanity:herpes:
404 :PROPERTIES:
405 :EXPORT_FILE_NAME: gortons
406 :END:
407 I think these gave me the herpes.
408 #+end_src
409 Exporting *hugotest.org* with ~C-c C-e H A~ and generate with ~hugo~ will yield
410 the same file structure as before, but this time we'll see that the categories
411 and tags directories have sections for our newly added tags.
412 #+begin_src
413 .
414 ├── archetypes
415 │   └── default.md
416 ├── config.toml
417 ├── content
418 │   ├── fishsticks
419 │   │   ├── gortons.md
420 │   │   ├── _index.md
421 │   │   └── van-de-camps.md
422 │   └── posts
423 │   └── herpes.md
424 ├── data
425 ├── hugotest.org
426 ├── layouts
427 ├── public
428 │   ├── categories
429 │   │   ├── inanity
430 │   │   │   └── index.xml
431 │   │   └── index.xml
432 │   ├── fishsticks
433 │   │   └── index.xml
434 │   ├── index.xml
435 │   ├── posts
436 │   │   └── index.xml
437 │   ├── sitemap.xml
438 │   └── tags
439 │   ├── fear
440 │   │   └── index.xml
441 │   ├── herpes
442 │   │   └── index.xml
443 │   └── index.xml
444 ├── static
445 └── themes
446 #+end_src
447 The index pages of taxonomies provide a list of all available taxonomies of that
448 type, with links to lists that show content associated with that taxonomy. For
449 instance, public/tags/index.xml looks like this:
450 #+begin_src xml -n
451 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
452 <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
453 <channel>
454 <title>Tags on My New Hugo Site</title>
455 <link>http://example.org/tags/</link>
456 <description>Recent content in Tags on My New Hugo Site</description>
457 <generator>Hugo -- gohugo.io</generator>
458 <language>en-us</language>
459
460 <atom:link href="http://example.org/tags/index.xml" rel="self" type="application/rss+xml" />
461
462
463 <item>
464 <title>Fear</title>
465 <link>http://example.org/tags/fear/</link>
466 <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
467
468 <guid>http://example.org/tags/fear/</guid>
469 <description></description>
470 </item>
471
472 <item>
473 <title>Herpes</title>
474 <link>http://example.org/tags/herpes/</link>
475 <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
476
477 <guid>http://example.org/tags/herpes/</guid>
478 <description></description>
479 </item>
480
481 </channel>
482 </rss>
483 #+end_src
484 And public/tags/fear/index.xml looks like this:
485 #+begin_src xml -n
486 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
487 <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
488 <channel>
489 <title>Fear on My New Hugo Site</title>
490 <link>http://example.org/tags/fear/</link>
491 <description>Recent content in Fear on My New Hugo Site</description>
492 <generator>Hugo -- gohugo.io</generator>
493 <language>en-us</language>
494
495 <atom:link href="http://example.org/tags/fear/index.xml" rel="self" type="application/rss+xml" />
496
497
498 <item>
499 <title>I have herpes</title>
500 <link>http://example.org/posts/herpes/</link>
501 <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
502
503 <guid>http://example.org/posts/herpes/</guid>
504 <description>Someone gave me herpes! Oh no!</description>
505 </item>
506
507 <item>
508 <title>Van De Camps</title>
509 <link>http://example.org/fishsticks/van-de-camps/</link>
510 <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
511
512 <guid>http://example.org/fishsticks/van-de-camps/</guid>
513 <description>If this is fish, I&amp;rsquo;ll be a monkey&amp;rsquo;s uncle.</description>
514 </item>
515
516 </channel>
517 </rss>
518 #+end_src
519 This allows themes to easily build navigation pages for browsing or querying
520 taxonomies. Files like these are often useful to output as JSON (done by the
521 theme) to allow Javascript-driven dynamic search features, but a simpler scheme
522 can output HTML pages to browse taxonomies just as you would posts in a section
523 (i.e. org-mode heading).
524
525 **** Theming
526 The last thing to do here is to download or create a theme for Hugo. As
527 mentioned before, installing a theme is very simple. This blog uses a custom
528 theme named Speedy that I have been developing to help myself learn Hugo's
529 internals, but for this example I'll be using Kaushal Modi's [[https://github.com/kaushalmodi/hugo-bare-min-theme][bare-min theme]]. The
530 bare-min theme is the best starting place out there for making new themes, and
531 outputs basic HTML pages without any need to mess with CSS or JS. It also
532 provides easy debugging facilities and search features.
533
534 We'll just install it and generate the site again. You can download the theme
535 from its github page and extract it to the themes folder, or much more easily
536 use git to clone it to your themes directory.
537 ~git clone https://github.com/kaushalmodi/hugo-bare-min-theme.git themes/bare-min~
538 Then open up your *config.toml* file, and add the theme.
539 #+begin_src toml -n
540 baseURL = "http://example.org/"
541 languageCode = "en-us"
542 title = "My New Hugo Site"
543 # Adding a theme:
544 theme = "bare-min"
545 #+end_src
546 Be sure that the theme's name matches the theme directory's name in the themes/
547 directory of your project base directory. (e.g. themes/bare-min here).
548
549 That's it for installing the theme. Just run ~hugo~ again, and behold your output:
550 #+begin_src
551 .
552 └── public
553 ├── categories
554 │   ├── inanity
555 │   │   ├── index.html
556 │   │   └── index.xml
557 │   ├── index.html
558 │   └── index.xml
559 ├── css
560 │   └── github_chroma.css
561 ├── fishsticks
562 │   ├── gortons
563 │   │   └── index.html
564 │   ├── index.html
565 │   ├── index.xml
566 │   └── van-de-camps
567 │   └── index.html
568 ├── index.html
569 ├── index.xml
570 ├── js
571 │   └── search.js
572 ├── page
573 │   └── 1
574 │   └── index.html
575 ├── posts
576 │   ├── herpes
577 │   │   └── index.html
578 │   ├── index.html
579 │   └── index.xml
580 ├── sitemap.xml
581 └── tags
582 ├── fear
583 │   ├── index.html
584 │   └── index.xml
585 ├── herpes
586 │   ├── index.html
587 │   └── index.xml
588 ├── index.html
589 └── index.xml
590 #+end_src
591 The bare-min theme outputs HTML, provides CSS for doing chroma-based syntax
592 highlighting (in case you include code blocks), and inline styles for basic
593 page formatting. Generated pages also have a lot of useful debugging information.
594
595 You can now serve the *public/* directory over an HTTP server. Hugo is packaged
596 with an internal [[https://gohugo.io/commands/hugo_server/][HTTP server]] to help with testing, which is quite convenient
597 because it can automatically refresh whenever content in its content directory
598 is updated (so when you export from ox-hugo, you don't have to run ~hugo~
599 again). To use it, simply run ~hugo server~ and point your browser at
600 http://localhost:1313 (1313 is the default ~--port~ argument for ~hugo server~).
601
602 Eventually you'll want to move on to other themes, or develop your own, but at
603 this point you've got a fully functional blog publishing workflow from start to
604 finish.
605
606 *** Attaching Files, Capturing Information & Automation
607 Once you have a basic site structured in your org file, you're ready to start
608 throwing information in it. It is of course sufficient to open the org file and
609 edit it, but most org-mode users prefer to automate /everything/, and being able
610 to use org's capture feature to instantly populate new blog posts is extremely
611 convenient.
612
613 The [[https://ox-hugo.scripter.co/][ox-hugo documentation]] provides succinct explanations on how to do this,
614 including elisp snippets for [[https://ox-hugo.scripter.co/doc/org-capture-setup/][capture setup]], [[https://ox-hugo.scripter.co/doc/images-in-content/][image linking]], and [[https://ox-hugo.scripter.co/doc/auto-export-on-saving/][automating
615 exports]] when you save your org file (so no more need to ~C-c C-e H A~ every
616 time, just save the file as usual with ~C-x C-s~).
617 ** DONE I did a blog :blog:org:emacs:hugo:
618 CLOSED: [2018-04-06 Fri 18:29]
619 :PROPERTIES:
620 :EXPORT_FILE_NAME: ox-hugo
621 :EXPORT_HUGO_CUSTOM_FRONT_MATTER: :caption "Exporting to Hugo's Blackfriday Markdown from Orgmode"
622 :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :header /img/org.png
623 :END:
624 ox-hugo is an [[http://en.wikipedia.org/wiki/Emacs][Emacs]] package for [[http://en.wikipedia.org/wiki/org-mode][org-mode]] that produces input for the static
625 content generator [[https://gohugo.io/][Hugo]], which I use for this website. Today I integrated its
626 expectations about file structure into the Speedy theme for this blog, allowing
627 me to keep all blog contents in a single org-mode file and export [[http://en.wikipedia.org/wiki/markdown][markdown]]
628 content for Hugo's excellent [[https://github.com/russross/blackfriday][blackfriday markdown parser]] (a markdown format with
629 many added features). Hugo does support limited parsing of org files internally,
630 but org-mode features like inline spreadsheets and system communication are
631 beyond the scope of most external tools, so org-mode is best used as an
632 exporter. As an Emacs user, this allows me to instantly capture interesting
633 information I come across and publish it within seconds. Now I have no excuses!
634
635 ** DONE Another topic
636 CLOSED: [2018-04-01 Sun 18:29]
637 :PROPERTIES:
638 :EXPORT_HUGO_CUSTOM_FRONT_MATTER: :caption "Just Another Topic"
639 :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :header /img/ox-hugo.png
640 :EXPORT_FILE_NAME: another-topic-1
641 :END:
642 This is just another topic, don't worry about it.
643
644 ** DONE Another topic :@test:test:
645 CLOSED: [2018-04-01 Sun 18:30]
646 :PROPERTIES:
647 :EXPORT_HUGO_CUSTOM_FRONT_MATTER: :caption "Just Another Topic"
648 :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :header /img/ox-hugo.png
649 :EXPORT_FILE_NAME: another-topic-2
650 :END:
651 This is just another topic, don't worry about it.
652
653 ** DONE Another topic :@test:test:
654 CLOSED: [2018-04-01 Sun 18:30]
655 :PROPERTIES:
656 :EXPORT_HUGO_CUSTOM_FRONT_MATTER: :caption "Just Another Topic"
657 :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :header /img/ox-hugo.png
658 :EXPORT_FILE_NAME: another-topic-3
659 :END:
660 This is just another topic, don't worry about it.
661
662 ** DONE Another topic :@test:test:
663 CLOSED: [2018-04-01 Sun 18:30]
664 :PROPERTIES:
665 :EXPORT_HUGO_CUSTOM_FRONT_MATTER: :caption "Just Another Topic"
666 :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :header /img/ox-hugo.png
667 :EXPORT_FILE_NAME: another-topic-4
668 :END:
669 This is just another topic, don't worry about it.
670 ** DONE Another topic :@test:test:
671 CLOSED: [2018-04-01 Sun 18:30]
672 :PROPERTIES:
673 :EXPORT_HUGO_CUSTOM_FRONT_MATTER: :caption "Just Another Topic"
674 :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :header /img/ox-hugo.png
675 :EXPORT_FILE_NAME: another-topic-5
676 :END:
677 This is just another topic, don't worry about it.
678 ** DONE Another topic :@test:test:
679 CLOSED: [2018-04-01 Sun 18:30]
680 :PROPERTIES:
681 :EXPORT_HUGO_CUSTOM_FRONT_MATTER: :caption "Just Another Topic"
682 :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :header /img/ox-hugo.png
683 :EXPORT_FILE_NAME: another-topic-6
684 :END:
685 This is just another topic, don't worry about it.
686 ** DONE Another topic :@test:test:
687 CLOSED: [2018-04-01 Sun 18:30]
688 :PROPERTIES:
689 :EXPORT_HUGO_CUSTOM_FRONT_MATTER: :caption "Just Another Topic"
690 :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :header /img/ox-hugo.png
691 :EXPORT_FILE_NAME: another-topic-7
692 :END:
693 This is just another topic, don't worry about it.
694 ** DONE Another topic :@test:test:
695 CLOSED: [2018-04-01 Sun 18:30]
696 :PROPERTIES:
697 :EXPORT_HUGO_CUSTOM_FRONT_MATTER: :caption "Just Another Topic"
698 :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :header /img/ox-hugo.png
699 :EXPORT_FILE_NAME: another-topic-8
700 :END:
701 This is just another topic, don't worry about it.
702 ** DONE Another topic :@test:test:
703 CLOSED: [2018-04-01 Sun 18:30]
704 :PROPERTIES:
705 :EXPORT_HUGO_CUSTOM_FRONT_MATTER: :caption "Just Another Topic"
706 :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :header /img/ox-hugo.png
707 :EXPORT_FILE_NAME: another-topic-9
708 :END:
709 This is just another topic, don't worry about it.
710 ** DONE Another topic :@test:test:
711 CLOSED: [2018-04-01 Sun 18:30]
712 :PROPERTIES:
713 :EXPORT_HUGO_CUSTOM_FRONT_MATTER: :caption "Just Another Topic"
714 :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :header /img/ox-hugo.png
715 :EXPORT_FILE_NAME: another-topic-10
716 :END:
717 This is just another topic, don't worry about it.
718 ** DONE Another topic :@test:test:
719 CLOSED: [2018-04-01 Sun 18:30]
720 :PROPERTIES:
721 :EXPORT_HUGO_CUSTOM_FRONT_MATTER: :caption "Just Another Topic"
722 :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :header /img/ox-hugo.png
723 :EXPORT_FILE_NAME: another-topic-11
724 :END:
725 This is just another topic, don't worry about it.
726 ** DONE Another topic :@test:test:
727 CLOSED: [2018-04-01 Sun 18:30]
728 :PROPERTIES:
729 :EXPORT_HUGO_CUSTOM_FRONT_MATTER: :caption "Just Another Topic"
730 :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :header /img/ox-hugo.png
731 :EXPORT_FILE_NAME: another-topic-12
732 :END:
733 This is just another topic, don't worry about it.
734 ** DONE Another topic :@test:test:
735 CLOSED: [2018-04-01 Sun 18:30]
736 :PROPERTIES:
737 :EXPORT_HUGO_CUSTOM_FRONT_MATTER: :caption "Just Another Topic"
738 :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :header /img/ox-hugo.png
739 :EXPORT_FILE_NAME: another-topic-13
740 :END:
741 This is just another topic, don't worry about it.
742 * Forth
743 :PROPERTIES:
744 :EXPORT_FILE_NAME: _index
745 :EXPORT_HUGO_MENU: :menu "main"
746 :EXPORT_HUGO_SECTION: forth
747 :EXPORT_HUGO_CUSTOM_FRONT_MATTER: :heading "Highly Factored Code"
748 :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :header /img/forth.png
749 :END:
750 This is where I post my watForth programs.
751
752 * Code Repositories
753 :PROPERTIES:
754 :EXPORT_FILE_NAME: _index
755 :EXPORT_HUGO_MENU: :menu "main" :title Git
756 :EXPORT_HUGO_SECTION: git
757 :EXPORT_HUGO_CUSTOM_FRONT_MATTER: :header /img/git.png
758 :END:
759 <iframe height="600px" width="100%" frameborder="0" scrolling="no" src="/gitweb" onload="resizeIFrame(this)">
760 <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
761 <a href="https://git.kengrimes.com">https://git.kengrimes.com</a>
762 </iframe>
763
764 * About
765 :PROPERTIES:
766 :EXPORT_HUGO_SECTION: about
767 :EXPORT_HUGO_MENU: :menu "main" :title About
768 :EXPORT_HUGO_CUSTOM_FRONT_MATTER: :heading '("Ken Grimes" "Computer Scientist" "At Large")
769 :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :header /img/home.png
770 :EXPORT_FILE_NAME: _index
771 :END:
772 Hi! I'm Ken, a 34-year-old computer scientist currently living in Irvine,
773 California. This is a website I've constructed for the purpose of developing
774 web-facing software. I will probably blog with it once development is
775 complete. In the mean time, if you're curious, this is my [[file:static/cv.pdf][curriculum vitae]]
776
777 * COMMENT
778 ** Why Emacs/Org
779 #+attr_html: :class center
780 [[file:static/img/emacs-logo.png]]
781
782 Org-mode is sometimes seen as an esoteric tool for an already esoteric IDE
783 (Emacs), but to me it is the natural evolution of decades of careful work to do
784 things the right way. When a software developer, after much study and
785 deliberation, finally comes to the realization that we are all fundamentally
786 programming one enormous system, it suddenly becomes important to understand the
787 fundamentals of computing and peel away the abstractions we live in like layers
788 of an onion. At the core, computer scientists will find that Names and Naming
789 are the universal "API" with which we all work. As such, being able to work with
790 raw words is invaluable to any serious student of computing. This is why the
791 much ignored medium of plain text is, somewhat paradoxically, the most powerful
792 of all tools for us. Indeed, Names and Naming have a long history of association
793 with power, and it seems most sciences that recognize this relationship are
794 themselves deemed "esoteric".
795
796 It's easy to get washed away in the torrent of new-age development tools that
797 add layer after layer of abstraction and "boilerplate" automation. These days,
798 it's trivial with tools like [[http://en.wikipedia.org/wiki/Webstorm][Webstorm]], [[http://en.wikipedia.org/wiki/Xcode][Xcode]], or [[http://en.wikipedia.org/wiki/Visual_Studio][Visual Studio]] to start
799 producing working code in minutes, regardless of experience or knowledge. It is
800 much harder, and in many environments impossible, to really understand what you
801 are doing. Most new programming languages, freed from developing sophisticated
802 compiler backends by new tools like [[http://en.wikipedia.org/wiki/llvm][llvm]], have instead focused on providing
803 tooling for automatically formatting, linting, bootstrapping, and even building
804 code to make this process even easier. These tools enforce an opinionated
805 workflow that, although good, are generally not portable to other languages or
806 toolchains. Tools like these are medicine for remedying the enormous time sink
807 and productivity loss suffered during configuration and setup. But like many
808 medicines, they can lead to addiction, and dependency on the vendor who provided
809 it. Eventually, being constrained to a single environment will cause essential
810 skills to atrophy, or never develop in the first place, making the victim a
811 slave to both their vendor and the drug.
812
813 I'm no tea-totaller, though. These tools are part of my regular workflow, and I
814 advocate using them when it is appropriate. The primary goal in developing
815 skills is to unapolagetically empower yourself by /any/ means necessary. It's a
816 balancing act, in the end, whether the drugs are hurting or hindering. Just be
817 conscious of the debilitating effects of what the buzz-slingers call "vendor
818 lock-in" these days. Study the topic, read the documentation, and understand
819 everything that is going to happen when you invoke any command. This applies to
820 tooling as well as library functions and even language statements - even
821 english. Admittedly, that's a steep mountain to climb for most people, and
822 crippling when wading through spaghetti-code, but you'll come to understand that
823 the most powerful words are the ones you /didn't have to say/ in the first
824 place.
825
826 Emacs and Org-mode take these philosophies to heart in different, and incomplete
827 ways. Org-mode is a plain text formatting system, not so dissimilar to markdown,
828 bbcode, or even twitter's automatic recognition of hashtags and @s. It's a
829 formatting engine that recognizes certain plain-text patterns as having special
830 meanings, geared eponymously towards organization of data. For instance,
831
832
833
834 Emacs and Org-mode take these philosophies to heart. Partly because Emacs has
835 been around in some form since the early 70s, While I extend this philosophy to
836 my coding style, it's also integral
837
838 ** Blackfriday Markdown: Syntax
839 #+begin_export md
840 <ul id="ProjectSubmenu">
841 <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
842 <li><a href="/projects/markdown/basics" title="Markdown Basics">Basics</a></li>
843 <li><a class="selected" title="Markdown Syntax Documentation">Syntax</a></li>
844 <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
845 <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
846 </ul>
847
848
849 * [Overview](#overview)
850 * [Philosophy](#philosophy)
851 * [Inline HTML](#html)
852 * [Automatic Escaping for Special Characters](#autoescape)
853 * [Block Elements](#block)
854 * [Paragraphs and Line Breaks](#p)
855 * [Headers](#header)
856 * [Blockquotes](#blockquote)
857 * [Lists](#list)
858 * [Code Blocks](#precode)
859 * [Horizontal Rules](#hr)
860 * [Span Elements](#span)
861 * [Links](#link)
862 * [Emphasis](#em)
863 * [Code](#code)
864 * [Images](#img)
865 * [Miscellaneous](#misc)
866 * [Backslash Escapes](#backslash)
867 * [Automatic Links](#autolink)
868
869
870 **Note:** This document is itself written using Markdown; you
871 can [see the source for it by adding '.text' to the URL][src].
872
873 [src]: https://raw.githubusercontent.com/russross/blackfriday/master/testdata/Markdown%20Documentation%20-%20Syntax.text
874
875 * * *
876
877 <h2 id="overview">Overview</h2>
878
879 <h3 id="philosophy">Philosophy</h3>
880
881 Markdown is intended to be as easy-to-read and easy-to-write as is feasible.
882
883 Readability, however, is emphasized above all else. A Markdown-formatted
884 document should be publishable as-is, as plain text, without looking
885 like it's been marked up with tags or formatting instructions. While
886 Markdown's syntax has been influenced by several existing text-to-HTML
887 filters -- including [Setext] [1], [atx] [2], [Textile] [3], [reStructuredText] [4],
888 [Grutatext] [5], and [EtText] [6] -- the single biggest source of
889 inspiration for Markdown's syntax is the format of plain text email.
890
891 [1]: http://docutils.sourceforge.net/mirror/setext.html
892 [2]: http://www.aaronsw.com/2002/atx/
893 [3]: http://textism.com/tools/textile/
894 [4]: http://docutils.sourceforge.net/rst.html
895 [5]: http://www.triptico.com/software/grutatxt.html
896 [6]: http://ettext.taint.org/doc/
897
898 To this end, Markdown's syntax is comprised entirely of punctuation
899 characters, which punctuation characters have been carefully chosen so
900 as to look like what they mean. E.g., asterisks around a word actually
901 look like \*emphasis\*. Markdown lists look like, well, lists. Even
902 blockquotes look like quoted passages of text, assuming you've ever
903 used email.
904
905
906
907 <h3 id="html">Inline HTML</h3>
908
909 Markdown's syntax is intended for one purpose: to be used as a
910 format for *writing* for the web.
911
912 Markdown is not a replacement for HTML, or even close to it. Its
913 syntax is very small, corresponding only to a very small subset of
914 HTML tags. The idea is *not* to create a syntax that makes it easier
915 to insert HTML tags. In my opinion, HTML tags are already easy to
916 insert. The idea for Markdown is to make it easy to read, write, and
917 edit prose. HTML is a *publishing* format; Markdown is a *writing*
918 format. Thus, Markdown's formatting syntax only addresses issues that
919 can be conveyed in plain text.
920
921 For any markup that is not covered by Markdown's syntax, you simply
922 use HTML itself. There's no need to preface it or delimit it to
923 indicate that you're switching from Markdown to HTML; you just use
924 the tags.
925
926 The only restrictions are that block-level HTML elements -- e.g. `<div>`,
927 `<table>`, `<pre>`, `<p>`, etc. -- must be separated from surrounding
928 content by blank lines, and the start and end tags of the block should
929 not be indented with tabs or spaces. Markdown is smart enough not
930 to add extra (unwanted) `<p>` tags around HTML block-level tags.
931
932 For example, to add an HTML table to a Markdown article:
933
934 This is a regular paragraph.
935
936 <table>
937 <tr>
938 <td>Foo</td>
939 </tr>
940 </table>
941
942 This is another regular paragraph.
943
944 Note that Markdown formatting syntax is not processed within block-level
945 HTML tags. E.g., you can't use Markdown-style `*emphasis*` inside an
946 HTML block.
947
948 Span-level HTML tags -- e.g. `<span>`, `<cite>`, or `<del>` -- can be
949 used anywhere in a Markdown paragraph, list item, or header. If you
950 want, you can even use HTML tags instead of Markdown formatting; e.g. if
951 you'd prefer to use HTML `<a>` or `<img>` tags instead of Markdown's
952 link or image syntax, go right ahead.
953
954 Unlike block-level HTML tags, Markdown syntax *is* processed within
955 span-level tags.
956
957
958 <h3 id="autoescape">Automatic Escaping for Special Characters</h3>
959
960 In HTML, there are two characters that demand special treatment: `<`
961 and `&`. Left angle brackets are used to start tags; ampersands are
962 used to denote HTML entities. If you want to use them as literal
963 characters, you must escape them as entities, e.g. `&lt;`, and
964 `&amp;`.
965
966 Ampersands in particular are bedeviling for web writers. If you want to
967 write about 'AT&T', you need to write '`AT&amp;T`'. You even need to
968 escape ampersands within URLs. Thus, if you want to link to:
969
970 http://images.google.com/images?num=30&q=larry+bird
971
972 you need to encode the URL as:
973
974 http://images.google.com/images?num=30&amp;q=larry+bird
975
976 in your anchor tag `href` attribute. Needless to say, this is easy to
977 forget, and is probably the single most common source of HTML validation
978 errors in otherwise well-marked-up web sites.
979
980 Markdown allows you to use these characters naturally, taking care of
981 all the necessary escaping for you. If you use an ampersand as part of
982 an HTML entity, it remains unchanged; otherwise it will be translated
983 into `&amp;`.
984
985 So, if you want to include a copyright symbol in your article, you can write:
986
987 &copy;
988
989 and Markdown will leave it alone. But if you write:
990
991 AT&T
992
993 Markdown will translate it to:
994
995 AT&amp;T
996
997 Similarly, because Markdown supports [inline HTML](#html), if you use
998 angle brackets as delimiters for HTML tags, Markdown will treat them as
999 such. But if you write:
1000
1001 4 < 5
1002
1003 Markdown will translate it to:
1004
1005 4 &lt; 5
1006
1007 However, inside Markdown code spans and blocks, angle brackets and
1008 ampersands are *always* encoded automatically. This makes it easy to use
1009 Markdown to write about HTML code. (As opposed to raw HTML, which is a
1010 terrible format for writing about HTML syntax, because every single `<`
1011 and `&` in your example code needs to be escaped.)
1012
1013
1014 * * *
1015
1016
1017 <h2 id="block">Block Elements</h2>
1018
1019
1020 <h3 id="p">Paragraphs and Line Breaks</h3>
1021
1022 A paragraph is simply one or more consecutive lines of text, separated
1023 by one or more blank lines. (A blank line is any line that looks like a
1024 blank line -- a line containing nothing but spaces or tabs is considered
1025 blank.) Normal paragraphs should not be intended with spaces or tabs.
1026
1027 The implication of the "one or more consecutive lines of text" rule is
1028 that Markdown supports "hard-wrapped" text paragraphs. This differs
1029 significantly from most other text-to-HTML formatters (including Movable
1030 Type's "Convert Line Breaks" option) which translate every line break
1031 character in a paragraph into a `<br />` tag.
1032
1033 When you *do* want to insert a `<br />` break tag using Markdown, you
1034 end a line with two or more spaces, then type return.
1035
1036 Yes, this takes a tad more effort to create a `<br />`, but a simplistic
1037 "every line break is a `<br />`" rule wouldn't work for Markdown.
1038 Markdown's email-style [blockquoting][bq] and multi-paragraph [list items][l]
1039 work best -- and look better -- when you format them with hard breaks.
1040
1041 [bq]: #blockquote
1042 [l]: #list
1043
1044
1045
1046 <h3 id="header">Headers</h3>
1047
1048 Markdown supports two styles of headers, [Setext] [1] and [atx] [2].
1049
1050 Setext-style headers are "underlined" using equal signs (for first-level
1051 headers) and dashes (for second-level headers). For example:
1052
1053 This is an H1
1054 =============
1055
1056 This is an H2
1057 -------------
1058
1059 Any number of underlining `=`'s or `-`'s will work.
1060
1061 Atx-style headers use 1-6 hash characters at the start of the line,
1062 corresponding to header levels 1-6. For example:
1063
1064 # This is an H1
1065
1066 ## This is an H2
1067
1068 ###### This is an H6
1069
1070 Optionally, you may "close" atx-style headers. This is purely
1071 cosmetic -- you can use this if you think it looks better. The
1072 closing hashes don't even need to match the number of hashes
1073 used to open the header. (The number of opening hashes
1074 determines the header level.) :
1075
1076 # This is an H1 #
1077
1078 ## This is an H2 ##
1079
1080 ### This is an H3 ######
1081
1082
1083 <h3 id="blockquote">Blockquotes</h3>
1084
1085 Markdown uses email-style `>` characters for blockquoting. If you're
1086 familiar with quoting passages of text in an email message, then you
1087 know how to create a blockquote in Markdown. It looks best if you hard
1088 wrap the text and put a `>` before every line:
1089
1090 > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
1091 > consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
1092 > Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
1093 >
1094 > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
1095 > id sem consectetuer libero luctus adipiscing.
1096
1097 Markdown allows you to be lazy and only put the `>` before the first
1098 line of a hard-wrapped paragraph:
1099
1100 > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
1101 consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
1102 Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
1103
1104 > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
1105 id sem consectetuer libero luctus adipiscing.
1106
1107 Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by
1108 adding additional levels of `>`:
1109
1110 > This is the first level of quoting.
1111 >
1112 > > This is nested blockquote.
1113 >
1114 > Back to the first level.
1115
1116 Blockquotes can contain other Markdown elements, including headers, lists,
1117 and code blocks:
1118
1119 > ## This is a header.
1120 >
1121 > 1. This is the first list item.
1122 > 2. This is the second list item.
1123 >
1124 > Here's some example code:
1125 >
1126 > return shell_exec("echo $input | $markdown_script");
1127
1128 Any decent text editor should make email-style quoting easy. For
1129 example, with BBEdit, you can make a selection and choose Increase
1130 Quote Level from the Text menu.
1131
1132
1133 <h3 id="list">Lists</h3>
1134
1135 Markdown supports ordered (numbered) and unordered (bulleted) lists.
1136
1137 Unordered lists use asterisks, pluses, and hyphens -- interchangably
1138 -- as list markers:
1139
1140 * Red
1141 * Green
1142 * Blue
1143
1144 is equivalent to:
1145
1146 + Red
1147 + Green
1148 + Blue
1149
1150 and:
1151
1152 - Red
1153 - Green
1154 - Blue
1155
1156 Ordered lists use numbers followed by periods:
1157
1158 1. Bird
1159 2. McHale
1160 3. Parish
1161
1162 It's important to note that the actual numbers you use to mark the
1163 list have no effect on the HTML output Markdown produces. The HTML
1164 Markdown produces from the above list is:
1165
1166 <ol>
1167 <li>Bird</li>
1168 <li>McHale</li>
1169 <li>Parish</li>
1170 </ol>
1171
1172 If you instead wrote the list in Markdown like this:
1173
1174 1. Bird
1175 1. McHale
1176 1. Parish
1177
1178 or even:
1179
1180 3. Bird
1181 1. McHale
1182 8. Parish
1183
1184 you'd get the exact same HTML output. The point is, if you want to,
1185 you can use ordinal numbers in your ordered Markdown lists, so that
1186 the numbers in your source match the numbers in your published HTML.
1187 But if you want to be lazy, you don't have to.
1188
1189 If you do use lazy list numbering, however, you should still start the
1190 list with the number 1. At some point in the future, Markdown may support
1191 starting ordered lists at an arbitrary number.
1192
1193 List markers typically start at the left margin, but may be indented by
1194 up to three spaces. List markers must be followed by one or more spaces
1195 or a tab.
1196
1197 To make lists look nice, you can wrap items with hanging indents:
1198
1199 * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
1200 Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
1201 viverra nec, fringilla in, laoreet vitae, risus.
1202 * Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
1203 Suspendisse id sem consectetuer libero luctus adipiscing.
1204
1205 But if you want to be lazy, you don't have to:
1206
1207 * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
1208 Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
1209 viverra nec, fringilla in, laoreet vitae, risus.
1210 * Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
1211 Suspendisse id sem consectetuer libero luctus adipiscing.
1212
1213 If list items are separated by blank lines, Markdown will wrap the
1214 items in `<p>` tags in the HTML output. For example, this input:
1215
1216 * Bird
1217 * Magic
1218
1219 will turn into:
1220
1221 <ul>
1222 <li>Bird</li>
1223 <li>Magic</li>
1224 </ul>
1225
1226 But this:
1227
1228 * Bird
1229
1230 * Magic
1231
1232 will turn into:
1233
1234 <ul>
1235 <li><p>Bird</p></li>
1236 <li><p>Magic</p></li>
1237 </ul>
1238
1239 List items may consist of multiple paragraphs. Each subsequent
1240 paragraph in a list item must be intended by either 4 spaces
1241 or one tab:
1242
1243 1. This is a list item with two paragraphs. Lorem ipsum dolor
1244 sit amet, consectetuer adipiscing elit. Aliquam hendrerit
1245 mi posuere lectus.
1246
1247 Vestibulum enim wisi, viverra nec, fringilla in, laoreet
1248 vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
1249 sit amet velit.
1250
1251 2. Suspendisse id sem consectetuer libero luctus adipiscing.
1252
1253 It looks nice if you indent every line of the subsequent
1254 paragraphs, but here again, Markdown will allow you to be
1255 lazy:
1256
1257 * This is a list item with two paragraphs.
1258
1259 This is the second paragraph in the list item. You're
1260 only required to indent the first line. Lorem ipsum dolor
1261 sit amet, consectetuer adipiscing elit.
1262
1263 * Another item in the same list.
1264
1265 To put a blockquote within a list item, the blockquote's `>`
1266 delimiters need to be indented:
1267
1268 * A list item with a blockquote:
1269
1270 > This is a blockquote
1271 > inside a list item.
1272
1273 To put a code block within a list item, the code block needs
1274 to be indented *twice* -- 8 spaces or two tabs:
1275
1276 * A list item with a code block:
1277
1278 <code goes here>
1279
1280
1281 It's worth noting that it's possible to trigger an ordered list by
1282 accident, by writing something like this:
1283
1284 1986. What a great season.
1285
1286 In other words, a *number-period-space* sequence at the beginning of a
1287 line. To avoid this, you can backslash-escape the period:
1288
1289 1986\. What a great season.
1290
1291
1292
1293 <h3 id="precode">Code Blocks</h3>
1294
1295 Pre-formatted code blocks are used for writing about programming or
1296 markup source code. Rather than forming normal paragraphs, the lines
1297 of a code block are interpreted literally. Markdown wraps a code block
1298 in both `<pre>` and `<code>` tags.
1299
1300 To produce a code block in Markdown, simply indent every line of the
1301 block by at least 4 spaces or 1 tab. For example, given this input:
1302
1303 This is a normal paragraph:
1304
1305 This is a code block.
1306
1307 Markdown will generate:
1308
1309 <p>This is a normal paragraph:</p>
1310
1311 <pre><code>This is a code block.
1312 </code></pre>
1313
1314 One level of indentation -- 4 spaces or 1 tab -- is removed from each
1315 line of the code block. For example, this:
1316
1317 Here is an example of AppleScript:
1318
1319 tell application "Foo"
1320 beep
1321 end tell
1322
1323 will turn into:
1324
1325 <p>Here is an example of AppleScript:</p>
1326
1327 <pre><code>tell application "Foo"
1328 beep
1329 end tell
1330 </code></pre>
1331
1332 A code block continues until it reaches a line that is not indented
1333 (or the end of the article).
1334
1335 Within a code block, ampersands (`&`) and angle brackets (`<` and `>`)
1336 are automatically converted into HTML entities. This makes it very
1337 easy to include example HTML source code using Markdown -- just paste
1338 it and indent it, and Markdown will handle the hassle of encoding the
1339 ampersands and angle brackets. For example, this:
1340
1341 <div class="footer">
1342 &copy; 2004 Foo Corporation
1343 </div>
1344
1345 will turn into:
1346
1347 <pre><code>&lt;div class="footer"&gt;
1348 &amp;copy; 2004 Foo Corporation
1349 &lt;/div&gt;
1350 </code></pre>
1351
1352 Regular Markdown syntax is not processed within code blocks. E.g.,
1353 asterisks are just literal asterisks within a code block. This means
1354 it's also easy to use Markdown to write about Markdown's own syntax.
1355
1356
1357
1358 <h3 id="hr">Horizontal Rules</h3>
1359
1360 You can produce a horizontal rule tag (`<hr />`) by placing three or
1361 more hyphens, asterisks, or underscores on a line by themselves. If you
1362 wish, you may use spaces between the hyphens or asterisks. Each of the
1363 following lines will produce a horizontal rule:
1364
1365 * * *
1366
1367 ***
1368
1369 *****
1370
1371 - - -
1372
1373 ---------------------------------------
1374
1375 _ _ _
1376
1377
1378 * * *
1379
1380 <h2 id="span">Span Elements</h2>
1381
1382 <h3 id="link">Links</h3>
1383
1384 Markdown supports two style of links: *inline* and *reference*.
1385
1386 In both styles, the link text is delimited by [square brackets].
1387
1388 To create an inline link, use a set of regular parentheses immediately
1389 after the link text's closing square bracket. Inside the parentheses,
1390 put the URL where you want the link to point, along with an *optional*
1391 title for the link, surrounded in quotes. For example:
1392
1393 This is [an example](http://example.com/ "Title") inline link.
1394
1395 [This link](http://example.net/) has no title attribute.
1396
1397 Will produce:
1398
1399 <p>This is <a href="http://example.com/" title="Title">
1400 an example</a> inline link.</p>
1401
1402 <p><a href="http://example.net/">This link</a> has no
1403 title attribute.</p>
1404
1405 If you're referring to a local resource on the same server, you can
1406 use relative paths:
1407
1408 See my [About](/about/) page for details.
1409
1410 Reference-style links use a second set of square brackets, inside
1411 which you place a label of your choosing to identify the link:
1412
1413 This is [an example][id] reference-style link.
1414
1415 You can optionally use a space to separate the sets of brackets:
1416
1417 This is [an example] [id] reference-style link.
1418
1419 Then, anywhere in the document, you define your link label like this,
1420 on a line by itself:
1421
1422 [id]: http://example.com/ "Optional Title Here"
1423
1424 That is:
1425
1426 * Square brackets containing the link identifier (optionally
1427 indented from the left margin using up to three spaces);
1428 * followed by a colon;
1429 * followed by one or more spaces (or tabs);
1430 * followed by the URL for the link;
1431 * optionally followed by a title attribute for the link, enclosed
1432 in double or single quotes.
1433
1434 The link URL may, optionally, be surrounded by angle brackets:
1435
1436 [id]: <http://example.com/> "Optional Title Here"
1437
1438 You can put the title attribute on the next line and use extra spaces
1439 or tabs for padding, which tends to look better with longer URLs:
1440
1441 [id]: http://example.com/longish/path/to/resource/here
1442 "Optional Title Here"
1443
1444 Link definitions are only used for creating links during Markdown
1445 processing, and are stripped from your document in the HTML output.
1446
1447 Link definition names may constist of letters, numbers, spaces, and punctuation -- but they are *not* case sensitive. E.g. these two links:
1448
1449 [link text][a]
1450 [link text][A]
1451
1452 are equivalent.
1453
1454 The *implicit link name* shortcut allows you to omit the name of the
1455 link, in which case the link text itself is used as the name.
1456 Just use an empty set of square brackets -- e.g., to link the word
1457 "Google" to the google.com web site, you could simply write:
1458
1459 [Google][]
1460
1461 And then define the link:
1462
1463 [Google]: http://google.com/
1464
1465 Because link names may contain spaces, this shortcut even works for
1466 multiple words in the link text:
1467
1468 Visit [Daring Fireball][] for more information.
1469
1470 And then define the link:
1471
1472 [Daring Fireball]: http://daringfireball.net/
1473
1474 Link definitions can be placed anywhere in your Markdown document. I
1475 tend to put them immediately after each paragraph in which they're
1476 used, but if you want, you can put them all at the end of your
1477 document, sort of like footnotes.
1478
1479 Here's an example of reference links in action:
1480
1481 I get 10 times more traffic from [Google] [1] than from
1482 [Yahoo] [2] or [MSN] [3].
1483
1484 [1]: http://google.com/ "Google"
1485 [2]: http://search.yahoo.com/ "Yahoo Search"
1486 [3]: http://search.msn.com/ "MSN Search"
1487
1488 Using the implicit link name shortcut, you could instead write:
1489
1490 I get 10 times more traffic from [Google][] than from
1491 [Yahoo][] or [MSN][].
1492
1493 [google]: http://google.com/ "Google"
1494 [yahoo]: http://search.yahoo.com/ "Yahoo Search"
1495 [msn]: http://search.msn.com/ "MSN Search"
1496
1497 Both of the above examples will produce the following HTML output:
1498
1499 <p>I get 10 times more traffic from <a href="http://google.com/"
1500 title="Google">Google</a> than from
1501 <a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a>
1502 or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>
1503
1504 For comparison, here is the same paragraph written using
1505 Markdown's inline link style:
1506
1507 I get 10 times more traffic from [Google](http://google.com/ "Google")
1508 than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or
1509 [MSN](http://search.msn.com/ "MSN Search").
1510
1511 The point of reference-style links is not that they're easier to
1512 write. The point is that with reference-style links, your document
1513 source is vastly more readable. Compare the above examples: using
1514 reference-style links, the paragraph itself is only 81 characters
1515 long; with inline-style links, it's 176 characters; and as raw HTML,
1516 it's 234 characters. In the raw HTML, there's more markup than there
1517 is text.
1518
1519 With Markdown's reference-style links, a source document much more
1520 closely resembles the final output, as rendered in a browser. By
1521 allowing you to move the markup-related metadata out of the paragraph,
1522 you can add links without interrupting the narrative flow of your
1523 prose.
1524
1525
1526 <h3 id="em">Emphasis</h3>
1527
1528 Markdown treats asterisks (`*`) and underscores (`_`) as indicators of
1529 emphasis. Text wrapped with one `*` or `_` will be wrapped with an
1530 HTML `<em>` tag; double `*`'s or `_`'s will be wrapped with an HTML
1531 `<strong>` tag. E.g., this input:
1532
1533 *single asterisks*
1534
1535 _single underscores_
1536
1537 **double asterisks**
1538
1539 __double underscores__
1540
1541 will produce:
1542
1543 <em>single asterisks</em>
1544
1545 <em>single underscores</em>
1546
1547 <strong>double asterisks</strong>
1548
1549 <strong>double underscores</strong>
1550
1551 You can use whichever style you prefer; the lone restriction is that
1552 the same character must be used to open and close an emphasis span.
1553
1554 Emphasis can be used in the middle of a word:
1555
1556 un*fucking*believable
1557
1558 But if you surround an `*` or `_` with spaces, it'll be treated as a
1559 literal asterisk or underscore.
1560
1561 To produce a literal asterisk or underscore at a position where it
1562 would otherwise be used as an emphasis delimiter, you can backslash
1563 escape it:
1564
1565 \*this text is surrounded by literal asterisks\*
1566
1567
1568
1569 <h3 id="code">Code</h3>
1570
1571 To indicate a span of code, wrap it with backtick quotes (`` ` ``).
1572 Unlike a pre-formatted code block, a code span indicates code within a
1573 normal paragraph. For example:
1574
1575 Use the `printf()` function.
1576
1577 will produce:
1578
1579 <p>Use the <code>printf()</code> function.</p>
1580
1581 To include a literal backtick character within a code span, you can use
1582 multiple backticks as the opening and closing delimiters:
1583
1584 ``There is a literal backtick (`) here.``
1585
1586 which will produce this:
1587
1588 <p><code>There is a literal backtick (`) here.</code></p>
1589
1590 The backtick delimiters surrounding a code span may include spaces --
1591 one after the opening, one before the closing. This allows you to place
1592 literal backtick characters at the beginning or end of a code span:
1593
1594 A single backtick in a code span: `` ` ``
1595
1596 A backtick-delimited string in a code span: `` `foo` ``
1597
1598 will produce:
1599
1600 <p>A single backtick in a code span: <code>`</code></p>
1601
1602 <p>A backtick-delimited string in a code span: <code>`foo`</code></p>
1603
1604 With a code span, ampersands and angle brackets are encoded as HTML
1605 entities automatically, which makes it easy to include example HTML
1606 tags. Markdown will turn this:
1607
1608 Please don't use any `<blink>` tags.
1609
1610 into:
1611
1612 <p>Please don't use any <code>&lt;blink&gt;</code> tags.</p>
1613
1614 You can write this:
1615
1616 `&#8212;` is the decimal-encoded equivalent of `&mdash;`.
1617
1618 to produce:
1619
1620 <p><code>&amp;#8212;</code> is the decimal-encoded
1621 equivalent of <code>&amp;mdash;</code>.</p>
1622
1623
1624
1625 <h3 id="img">Images</h3>
1626
1627 Admittedly, it's fairly difficult to devise a "natural" syntax for
1628 placing images into a plain text document format.
1629
1630 Markdown uses an image syntax that is intended to resemble the syntax
1631 for links, allowing for two styles: *inline* and *reference*.
1632
1633 Inline image syntax looks like this:
1634
1635 ![Alt text](/path/to/img.jpg)
1636
1637 ![Alt text](/path/to/img.jpg "Optional title")
1638
1639 That is:
1640
1641 * An exclamation mark: `!`;
1642 * followed by a set of square brackets, containing the `alt`
1643 attribute text for the image;
1644 * followed by a set of parentheses, containing the URL or path to
1645 the image, and an optional `title` attribute enclosed in double
1646 or single quotes.
1647
1648 Reference-style image syntax looks like this:
1649
1650 ![Alt text][id]
1651
1652 Where "id" is the name of a defined image reference. Image references
1653 are defined using syntax identical to link references:
1654
1655 [id]: url/to/image "Optional title attribute"
1656
1657 As of this writing, Markdown has no syntax for specifying the
1658 dimensions of an image; if this is important to you, you can simply
1659 use regular HTML `<img>` tags.
1660
1661
1662 * * *
1663
1664
1665 <h2 id="misc">Miscellaneous</h2>
1666
1667 <h3 id="autolink">Automatic Links</h3>
1668
1669 Markdown supports a shortcut style for creating "automatic" links for URLs and email addresses: simply surround the URL or email address with angle brackets. What this means is that if you want to show the actual text of a URL or email address, and also have it be a clickable link, you can do this:
1670
1671 <http://example.com/>
1672
1673 Markdown will turn this into:
1674
1675 <a href="http://example.com/">http://example.com/</a>
1676
1677 Automatic links for email addresses work similarly, except that
1678 Markdown will also perform a bit of randomized decimal and hex
1679 entity-encoding to help obscure your address from address-harvesting
1680 spambots. For example, Markdown will turn this:
1681
1682 <address@example.com>
1683
1684 into something like this:
1685
1686 <a href="&#x6D;&#x61;i&#x6C;&#x74;&#x6F;:&#x61;&#x64;&#x64;&#x72;&#x65;
1687 &#115;&#115;&#64;&#101;&#120;&#x61;&#109;&#x70;&#x6C;e&#x2E;&#99;&#111;
1688 &#109;">&#x61;&#x64;&#x64;&#x72;&#x65;&#115;&#115;&#64;&#101;&#120;&#x61;
1689 &#109;&#x70;&#x6C;e&#x2E;&#99;&#111;&#109;</a>
1690
1691 which will render in a browser as a clickable link to "address@example.com".
1692
1693 (This sort of entity-encoding trick will indeed fool many, if not
1694 most, address-harvesting bots, but it definitely won't fool all of
1695 them. It's better than nothing, but an address published in this way
1696 will probably eventually start receiving spam.)
1697
1698
1699
1700 <h3 id="backslash">Backslash Escapes</h3>
1701
1702 Markdown allows you to use backslash escapes to generate literal
1703 characters which would otherwise have special meaning in Markdown's
1704 formatting syntax. For example, if you wanted to surround a word with
1705 literal asterisks (instead of an HTML `<em>` tag), you can backslashes
1706 before the asterisks, like this:
1707
1708 \*literal asterisks\*
1709
1710 Markdown provides backslash escapes for the following characters:
1711
1712 \ backslash
1713 ` backtick
1714 * asterisk
1715 _ underscore
1716 {} curly braces
1717 [] square brackets
1718 () parentheses
1719 # hash mark
1720 + plus sign
1721 - minus sign (hyphen)
1722 . dot
1723 ! exclamation mark
1724 #+end_export
1725 ** OS Wars
1726 The operating system wars are still going, they've just taken on a new form: the
1727 ecosystems of major software development centers like microsoft, facebook,
1728 google, apple, amazon, have just become the new battleground. All of these
1729 ecosystems are seeking to replace the entire unix operating system stack with
1730 their own internal APIs and code. from writing code in awk/sed/bash to utilize
1731 the OS's commands as an api, to generalizing this in python-esque languages, and
1732 now to new programming frameworks for every language which package endless
1733 libraries that are just sloppy new rewrites of decades-old functionality already
1734 in the GNU environment. the good news is that there's a ton of energy going into
1735 language research, compilers, and there are many new emerging standards as a
1736 result for message sending (alan kay "real objects"), network federation,
1737 package management, build tools, live coding, web technology, execution
1738 platforms, and everything in between. the bad news is that basically all energy
1739 is just going towards building, and rebuilding, and rebuilding application
1740 frameworks. Call them libraries, packages, eggs, utilities, or whatever, they're
1741 all just another incomplete rewrite of tools that have been around and
1742 maintained for over half a century. They're easier to use, which is great, but
1743 that user interface (i.e. language syntax and package management) doesn't need
1744 to be divorced from existing functionality. As far as I can figure, it's just
1745 gouche, or somehow seen as less sophisticated and interesting, if a language
1746 keeps C dependencies after a certain point. Almost all languages start out their
1747 life as C programs, and it's considered a major milestone when the language's
1748 compiler can finally compile itself and become self-hosting. All this proves is
1749 that the language can generate a compiler, though. It's a sloppy metric of
1750 progress. It's another major milestone when the language's libraries no longer
1751 have any C library dependencies (i.e. all commonly used APIs for handling i18n,
1752 unicode, hashtables, etcetera, have been reinvented in the new
1753 language). And perhaps its greatest achievement of all is to remove dependence
1754 on libc - the single most rugged and well-tested system interface on the
1755 planet.
1756
1757 What I'd really like to see is a language that