<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Eyes-free Linux Ninja! (markdown)</title><link>http://eyesfreelinux.ninja/</link><description></description><atom:link href="http://eyesfreelinux.ninja/categories/markdown.xml" type="application/rss+xml" rel="self"></atom:link><language>en</language><lastBuildDate>Fri, 22 Sep 2017 20:57:18 GMT</lastBuildDate><generator>https://getnikola.com/</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>How to Generate a Table of Contents in a Kramdown Document</title><link>http://eyesfreelinux.ninja/posts/how-to-generate-a-table-of-contents-in-a-kramdown-document.html</link><dc:creator>Mike</dc:creator><description>&lt;div&gt;&lt;p&gt;Here's how to generate a table of contents in &lt;code&gt;kramdown&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;

# Heading
{:.no_toc} 

## Table of Contents
{:.no_toc}

* TOC 
{:toc} 

&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Introduction&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;kramdown gem&lt;/code&gt; converts a kramdown file into html. It generates the id tags for each heading and 
uses them to generate a table of contents for a document. This becomes obvious if you take a file 
written in kramdown and convert it to html.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;kramdown input-file.md &amp;gt; output-file.html
&lt;/pre&gt;


&lt;p&gt;The ids are put on the generated html for all headings.&lt;/p&gt;
&lt;h3&gt;How To Automatically Generate A Table of Contents&lt;/h3&gt;
&lt;p&gt;Typically, you will want to have a numbered list for your table of contents or a bulleted list of 
entries. This is done by either writing &lt;code&gt;1. TOC&lt;/code&gt; or &lt;code&gt;* TOC&lt;/code&gt; at the place in your file where you want 
the table of contents to be located. Underneath this line, specify the
table of contents itself:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;

{:toc}

&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can have either a numbered list of items or a bulleted list, in
the normal way for lists:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;

1. TOC 
{:toc} 

* TOC 
{:toc} 

&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you do not want a heading to be included in the table of 
contents, put:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;

`{:.no_toc}

&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Underneath the entry you want to exclude from the table of contents, often your top-level heading.&lt;/p&gt;
&lt;h3&gt;Notes&lt;/h3&gt;
&lt;p&gt;I have noticed that there is either a bug or an accidental omission in the 
generation of the toc. For example,, given headings like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;

# First level one heading
## First level two heading 
## Second level two heading 
## Third level two heading
# Second level one heading

&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I would expect the second level one heading to be a member of the list of level one headings, but it 
is left hanging in between two lists of second level headings, and is a member of no list. This bug 
makes sub-lists and then a return to a lower level further down impossible.&lt;/p&gt;
&lt;p&gt;So you will need to have all headings which go to make up a table of
contents the same level.&lt;/p&gt;
&lt;p&gt;A bit annoying but it beats constantly scrolling up and down a
document as you write it to try to remember the order of the headings
and their names.&lt;/p&gt;&lt;/div&gt;</description><category>kramdown</category><category>markdown</category><guid>http://eyesfreelinux.ninja/posts/how-to-generate-a-table-of-contents-in-a-kramdown-document.html</guid><pubDate>Sat, 01 Apr 2017 20:15:59 GMT</pubDate></item><item><title>Nikola plugin for kramdown</title><link>http://eyesfreelinux.ninja/posts/kramdown-plugin.html</link><dc:creator>Mike</dc:creator><description>&lt;div&gt;&lt;!--
.. title: Nikola plugin for kramdown
.. slug: kramdown-plugin
.. date: 2016-02-04 17:44:49 UTC
.. tags: kramdown, markdown
.. category: 
.. link: 
.. description: A Nikola plugin for kramdown posts and pages
.. type: text
--&gt;

&lt;p&gt;I’m not surprised that &lt;a href="http://daringfireball.net/"&gt;markdown&lt;/a&gt; has become so successful and ubiquitous.  But one of the 
things I think it lacks is syntax for creating tables.&lt;/p&gt;

&lt;p&gt;For this reason, I have been using a &lt;a href="http://txt2tags.org/"&gt;txt2tags&lt;/a&gt; plugin for a while.  My sites all have a 
lot of tabular data, both as a function of the nature of the sites and also because I just like 
tables.&lt;/p&gt;

&lt;p&gt;But I recently discovered &lt;a href="http://kramdown.gettalong.org/"&gt;kramdown&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;kramdown has a super-set of markdown syntax, including simple, but powerful table-creation syntax.&lt;/p&gt;

&lt;p&gt;So I’ve written a &lt;a href="https://plugins.getnikola.com/"&gt;plugin&lt;/a&gt; for &lt;a href="http://getnikola.com/"&gt;Nikola&lt;/a&gt; along the lines of the txt2tags plugin to 
compile HTML posts and pages from kramdown files.  For which I have started using the .kd extension.&lt;/p&gt;

&lt;p&gt;This post is written in kramdown.&lt;/p&gt;

&lt;p&gt;So this post is somewhat by way of a test of my kramdown plugin for Nikola.&lt;/p&gt;

&lt;h3&gt;Third-level Heading&lt;/h3&gt;

&lt;p&gt;The above heading is marked with two hash characters and in the same way that markdown posts have 
their heading demoted by one level I have done the same with kramdown.&lt;/p&gt;

&lt;p&gt;Here is a table of silly data:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style="text-align: right"&gt;Date&lt;/th&gt;
      &lt;th style="text-align: left"&gt;Weather&lt;/th&gt;
      &lt;th style="text-align: left"&gt;Activity&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style="text-align: right"&gt;01-Feb-2016&lt;/td&gt;
      &lt;td style="text-align: left"&gt;Rain&lt;/td&gt;
      &lt;td style="text-align: left"&gt;Stayed in&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style="text-align: right"&gt;02-Feb-2016&lt;/td&gt;
      &lt;td style="text-align: left"&gt;Dry and cloudy&lt;/td&gt;
      &lt;td style="text-align: left"&gt;Stayed in again&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style="text-align: right"&gt;03-Feb-2016&lt;/td&gt;
      &lt;td style="text-align: left"&gt;Cold, -4C&lt;/td&gt;
      &lt;td style="text-align: left"&gt;Had to go out for most of the day&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style="text-align: right"&gt;04-Feb-2016&lt;/td&gt;
      &lt;td style="text-align: left"&gt;Even colder than yesterday&lt;/td&gt;
      &lt;td style="text-align: left"&gt;Stayed in and wrote a kramdown plugin for Nikola&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h3&gt;Lists&lt;/h3&gt;

&lt;p&gt;Lists are the same as in markdown&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;unordered list item one&lt;/li&gt;
  &lt;li&gt;Unordered list item two&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Links&lt;/h3&gt;

&lt;p&gt;The links in the above text are all done like references are done in markdown, with the actual URI 
of each link at the bottom of the text file.&lt;/p&gt;&lt;/div&gt;</description><category>kramdown</category><category>markdown</category><guid>http://eyesfreelinux.ninja/posts/kramdown-plugin.html</guid><pubDate>Thu, 04 Feb 2016 17:44:49 GMT</pubDate></item><item><title>A Way of Using Include Directives in Markdown Posts and Pages</title><link>http://eyesfreelinux.ninja/posts/a-way-of-using-include-directives-in-markdown-posts-and-pages.html</link><dc:creator>Mike</dc:creator><description>&lt;div&gt;&lt;p&gt;Using an &lt;code&gt;include&lt;/code&gt; directive with Markdown in Nikola Pages&lt;/p&gt;
&lt;p&gt;I love &lt;a href="http://daringfireball.net/"&gt;&lt;code&gt;markdown&lt;/code&gt;&lt;/a&gt;.  I think it's the best thing since sliced-bread.  The ability to write complex 
documents with a simple set of formatting syntax that can then be converted into a raft of other 
formats, possibly with &lt;code&gt;pandoc&lt;/code&gt; is probably the single biggest boost to your productivity you could 
find if you write a lot of documentation.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://getnikola.com/"&gt;Nikola&lt;/a&gt; uses &lt;code&gt;markdown&lt;/code&gt;, among other flavours of 
document formatting such as &lt;code&gt;restructured text&lt;/code&gt; and &lt;code&gt;org-mode&lt;/code&gt; text (an &lt;code&gt;Emacs&lt;/code&gt; major-mode). But my 
choice is usually &lt;code&gt;markdown&lt;/code&gt;.  One thing I thought it was lacking until somebody asked the question 
on the Nikola mailing list was an &lt;code&gt;include&lt;/code&gt; directive similar to that in the C pre-processor.&lt;/p&gt;
&lt;p&gt;What follows is a distillation of the ensuing posts and discussion from the list.&lt;/p&gt;
&lt;p&gt;First install the markdown-include Python package:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;sudo pip install markdown-include
&lt;/pre&gt;


&lt;p&gt;Now modify your &lt;code&gt;conf.py&lt;/code&gt; to add this, there is one 
commented out which looks similar:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;MARKDOWN_EXTENSIONS = ['fenced_code', 'codehilite', 'extra', 'markdown_include.include']
&lt;/pre&gt;


&lt;h2&gt;Embedding &lt;code&gt;include&lt;/code&gt; Directives in Markdown Posts and Pages&lt;/h2&gt;
&lt;p&gt;To include a file in a &lt;code&gt;Markdown&lt;/code&gt; post or page:&lt;/p&gt;
&lt;p&gt;Note the path is relative to where &lt;code&gt;markdown_include&lt;/code&gt; is being called from, not from the directory 
containing the post/page. So something like:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;{!include/md/links.md!
&lt;/pre&gt;


&lt;p&gt;Assuming you have &lt;code&gt;include/md/*&lt;/code&gt; immediately underneath where your &lt;code&gt;conf.py&lt;/code&gt; is, e.g. the root of 
your Nikola site.&lt;/p&gt;
&lt;p&gt;To change the root of files you wish to include, in &lt;code&gt;conf.py&lt;/code&gt; place the following:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;markdown_include.include&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;MarkdownInclude&lt;/span&gt;
&lt;span class="n"&gt;my_include&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;MarkdownInclude&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;configs&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'base_path'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s1"&gt;'/srv/content/'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="c1"&gt;# can also be relative path to conf.py&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;MARKDOWN_EXTENSIONS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'fenced_code'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'codehilite'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'extra'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;my_include&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/pre&gt;


&lt;p&gt;I can't claim any originality for this as it was pulled directly from the Nikola email list.  I'm 
putting it here because it's a subject that is very close to my heart, e.g. modularity.  I've 
already installed the &lt;code&gt;txt2tags&lt;/code&gt; plugin and I'm using &lt;code&gt;t2t&lt;/code&gt; includes to pull-in tables of keyboard 
commands for such things as &lt;code&gt;Emacs&lt;/code&gt; major-mode key-bindings.&lt;/p&gt;
&lt;p&gt;This site seems to be veering slightly away from it's originally intended purpose of gathering into 
one place all kinds of stuff relating to accessibility on the Linux platform and becoming something 
of a personal blog and library archive for snippets of useful stuff.&lt;/p&gt;
&lt;p&gt;Oh well, I guess it's my party...&lt;/p&gt;&lt;/div&gt;</description><category>markdown</category><category>Nikola</category><guid>http://eyesfreelinux.ninja/posts/a-way-of-using-include-directives-in-markdown-posts-and-pages.html</guid><pubDate>Tue, 23 Jun 2015 12:52:50 GMT</pubDate></item><item><title>Emacs markdown-mode</title><link>http://eyesfreelinux.ninja/posts/emacs-markdown-mode.html</link><dc:creator>Mike</dc:creator><description>&lt;div&gt;&lt;p&gt;Emacs (and hence Emacspeak) has an extension for writing and manipulating &lt;strong&gt;markdown&lt;/strong&gt; files.  I use 
&lt;strong&gt;markdown&lt;/strong&gt; for writing the posts and pages for this site and others.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://getnikola.com"&gt;Nikola&lt;/a&gt; can be used with a number of different document &lt;em&gt;compilers&lt;/em&gt;, that is, programs or 
plugins that can take documents authored in one kind of plain-text mark-up and convert it to 
another.&lt;/p&gt;
&lt;p&gt;One of the best of these is &lt;strong&gt;markdown&lt;/strong&gt;.  Using &lt;strong&gt;markdown&lt;/strong&gt; it is possible to write realy quite 
complex content, without the need to add the HTML or other complex mark-up tags that can make it 
difficult to see the wood for the trees.&lt;/p&gt;
&lt;p&gt;Emacs has a &lt;strong&gt;major-mode&lt;/strong&gt; for handling these files.  I have &lt;a href="http://eyesfreelinux.ninja/stories/emacs-markdown-mode-key-bindings.html"&gt;published a page that contains tables 
of all the Emacs key-bindings for markdown-mode&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</description><category>Emacs</category><category>markdown</category><guid>http://eyesfreelinux.ninja/posts/emacs-markdown-mode.html</guid><pubDate>Tue, 26 May 2015 00:23:08 GMT</pubDate></item></channel></rss>