<?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! (Nikola)</title><link>http://eyesfreelinux.ninja/</link><description></description><atom:link href="http://eyesfreelinux.ninja/categories/nikola.xml" type="application/rss+xml" rel="self"></atom:link><language>en</language><lastBuildDate>Fri, 22 Sep 2017 20:57:19 GMT</lastBuildDate><generator>https://getnikola.com/</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><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>Nikola plugins</title><link>http://eyesfreelinux.ninja/posts/nikola-plugins.html</link><dc:creator>Mike</dc:creator><description>&lt;div&gt;&lt;p&gt;I have installed a couple of &lt;code&gt;plugins&lt;/code&gt; to help with &lt;a href="http://getnikola.com/"&gt;Nikola&lt;/a&gt; page and post authoring.&lt;/p&gt;
&lt;p&gt;These plugins are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;orgmode&lt;/li&gt;
&lt;li&gt;txt2tags&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;The &lt;code&gt;orgmode&lt;/code&gt; Plugin&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;orgmode&lt;/code&gt; plugin uses &lt;code&gt;Emacs&lt;/code&gt; in batch mode to provide a means of authoring Nikola posts and 
stories in &lt;code&gt;.org&lt;/code&gt; files for conversion into HTML.&lt;/p&gt;
&lt;p&gt;To install it:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;nikola plugin -i orgmode
&lt;/pre&gt;


&lt;p&gt;You will get a directory under your Nikola site:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;plugins/orgmode
&lt;/pre&gt;


&lt;p&gt;In this directory there are a number of files.&lt;/p&gt;
&lt;p&gt;Providing you have version 8.0 or above of &lt;code&gt;Emacs&lt;/code&gt; orgmode installed you will not need to do 
anything with the &lt;code&gt;init.el&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;Pay careful attention to the &lt;code&gt;conf.py.sample&lt;/code&gt; file and add the code-fragments to the 
&lt;code&gt;COMPILERS =&lt;/code&gt;, &lt;code&gt;POSTS =&lt;/code&gt; and &lt;code&gt;PAGES =&lt;/code&gt; entries in your &lt;code&gt;conf.py&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Once that is working correctly then:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;nikola new_post -f orgmode -t "post title"
&lt;/pre&gt;


&lt;p&gt;Should create a &lt;code&gt;post-title.org&lt;/code&gt; file in your &lt;code&gt;./posts&lt;/code&gt; directory which you can edit using 
&lt;code&gt;Emacs&lt;/code&gt; or &lt;code&gt;Emacspeak&lt;/code&gt; and get all the benefits of &lt;code&gt;orgmode&lt;/code&gt; power.&lt;/p&gt;
&lt;h2&gt;The &lt;code&gt;txt2tags&lt;/code&gt; Plugin&lt;/h2&gt;
&lt;p&gt;For this, first you will have to install &lt;code&gt;txt2tags&lt;/code&gt;.  On &lt;strong&gt;Debian&lt;/strong&gt; or &lt;strong&gt;Ubuntu&lt;/strong&gt; you can do this 
like this:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;sudo apt-get install txt2tags
&lt;/pre&gt;


&lt;p&gt;Now install the Nikola plugin:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;nikola plugin -i txt2tags
&lt;/pre&gt;


&lt;p&gt;Again you will need to edit your &lt;code&gt;conf.py&lt;/code&gt; file and change the &lt;code&gt;POSTS =&lt;/code&gt;, &lt;code&gt;PAGES = and&lt;/code&gt;COMPILERS =` entries.&lt;/p&gt;
&lt;p&gt;You can see how to by looking at values for other file types.&lt;/p&gt;
&lt;p&gt;Now doing this:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;nikola new_post -f txt2tags -t "post title"
&lt;/pre&gt;


&lt;p&gt;Will give you a &lt;code&gt;post-title.t2t&lt;/code&gt; file in your posts directory.&lt;/p&gt;
&lt;p&gt;Why did I install &lt;code&gt;txt2tags&lt;/code&gt;?&lt;/p&gt;
&lt;p&gt;Because one of the great things &lt;code&gt;txt2tags&lt;/code&gt; does that &lt;code&gt;markdown&lt;/code&gt; does not is tables.  And another 
great thing, and what made me install it, is the ability to give &lt;code&gt;include&lt;/code&gt; directives in 
&lt;code&gt;txt2tags&lt;/code&gt; files.&lt;/p&gt;
&lt;p&gt;If you put this string in your &lt;code&gt;.t2t&lt;/code&gt; file:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c"&gt;%!include: filename.t2t&lt;/span&gt;
&lt;/pre&gt;


&lt;p&gt;When the page is rendered, the file willbe included.  It does not have to be a &lt;code&gt;.t2t&lt;/code&gt; file that is 
included.  But the parent file &lt;strong&gt;will&lt;/strong&gt; be rendered with the &lt;code&gt;txt2tags&lt;/code&gt; &lt;code&gt;compiler&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;It was using the &lt;code&gt;txt2tags&lt;/code&gt; plugin and syntax that I created the pages that show tables of 
reference data such as &lt;code&gt;markdown-mode&lt;/code&gt; commands for Emacs.  By including files in &lt;code&gt;txt2tags&lt;/code&gt; syntax 
that are converted to HTML tables on the fly.&lt;/p&gt;
&lt;p&gt;Why not just embed the files?  Well this way I can use all kinds of jiggery-pokery including &lt;code&gt;sed&lt;/code&gt; 
and &lt;code&gt;grep&lt;/code&gt; commands to generate the &lt;code&gt;.t2t&lt;/code&gt; table files from &lt;code&gt;Emacs&lt;/code&gt; key-bindings harvested 
automatically.&lt;/p&gt;
&lt;p&gt;Very neat.&lt;/p&gt;&lt;/div&gt;</description><category>Nikola</category><guid>http://eyesfreelinux.ninja/posts/nikola-plugins.html</guid><pubDate>Tue, 26 May 2015 10:59:07 GMT</pubDate></item></channel></rss>