<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Markdown on wegotoeleven</title><link>http://blog.wegotoeleven.xyz/tags/markdown/</link><description>Recent content in Markdown on wegotoeleven</description><generator>Hugo</generator><language>en-gb</language><lastBuildDate>Mon, 29 Aug 2022 00:00:00 +0000</lastBuildDate><atom:link href="http://blog.wegotoeleven.xyz/tags/markdown/index.xml" rel="self" type="application/rss+xml"/><item><title>Using Markdown to write Documentation</title><link>http://blog.wegotoeleven.xyz/technical/using-markdown-to-write-documentation/</link><pubDate>Mon, 28 Sep 2015 00:00:00 +0000</pubDate><guid>http://blog.wegotoeleven.xyz/technical/using-markdown-to-write-documentation/</guid><description>&lt;p&gt;I absolutely cannot stand writing documentation. Well, that&amp;rsquo;s kind of a lie; I don&amp;rsquo;t mind the actual writing, but I get too hung up on trying to make it look pretty. If you—the reader—write your own, then maybe you&amp;rsquo;ll know what I mean.&lt;/p&gt;
&lt;p&gt;One of the best things about writing docs that&amp;rsquo;ll be hosted on-line is that the format will be based upon the site that it lives in. Take Github for example; all documentation up there looks the same. This is because they&amp;rsquo;re all written in &lt;a href="https://daringfireball.net/projects/markdown/"&gt;Markdown&lt;/a&gt;. Markdown is a language syntax that standardises formatting which allows a writer to focus on the content that&amp;rsquo;s being written. If you&amp;rsquo;ve never seen a Github readme, check out a few:&lt;/p&gt;</description><content:encoded><![CDATA[<p>I absolutely cannot stand writing documentation. Well, that&rsquo;s kind of a lie; I don&rsquo;t mind the actual writing, but I get too hung up on trying to make it look pretty. If you—the reader—write your own, then maybe you&rsquo;ll know what I mean.</p>
<p>One of the best things about writing docs that&rsquo;ll be hosted on-line is that the format will be based upon the site that it lives in. Take Github for example; all documentation up there looks the same. This is because they&rsquo;re all written in <a href="https://daringfireball.net/projects/markdown/">Markdown</a>. Markdown is a language syntax that standardises formatting which allows a writer to focus on the content that&rsquo;s being written. If you&rsquo;ve never seen a Github readme, check out a few:</p>
<ul>
<li><a href="https://github.com/munki/munki/blob/master/README.md">Munki</a></li>
<li><a href="https://github.com/autopkg/autopkg/blob/master/ReadMe.md">Autopkg</a></li>
<li>Docker container for <a href="https://github.com/wegotoeleven/dockerfiles/blob/master/boot2docker-transmission/README.md">Transmission</a></li>
</ul>
<p>This blog is also written in markdown. The CSS on this blog is used to apply styles to the various components of a converted markdown document. I&rsquo;m not going to go into every piece of Markdown syntax as it&rsquo;s not the point of this post, but hopefully you get the idea.</p>
<p>So how cool would it be to leverage this when writing printed documentation?</p>
<p>Let&rsquo;s get one thing straight; Markdown was build for web rendering. So out of the box, there&rsquo;s no easy way to create a document in Markdown, and export to, say, PDF or Word document.</p>
<p>That&rsquo;s where <a href="www.pandoc.org">Pandoc</a> comes in.</p>
<p>Pandoc is a tool that converts files from one markup format to another. It&rsquo;s a downloadable application for <a href="https://github.com/jgm/pandoc/releases/download/1.15.0.6/pandoc-1.15.0.6-osx.pkg">Mac</a>, <a href="https://github.com/jgm/pandoc/releases/download/1.15.0.6/pandoc-1.15.0.6-windows.msi">Windows</a> and <a href="https://github.com/jgm/pandoc/releases/download/1.15.0.6/pandoc-1.15.0.6-1-amd64.deb">Linux</a> that runs in the command line in the format of:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">$ pandoc -f <span class="si">${</span><span class="nv">input</span><span class="p">-format</span><span class="si">}</span> <span class="si">${</span><span class="nv">input</span><span class="p">-file</span><span class="si">}</span> <span class="se">\
</span></span></span><span class="line"><span class="cl">    -t <span class="si">${</span><span class="nv">output</span><span class="p">-format</span><span class="si">}</span> -o <span class="si">${</span><span class="nv">output</span><span class="p">-file</span><span class="si">}</span>
</span></span></code></pre></div><p>As standard, it uses a predefined format when it spits out a Word document, that looks not unlike Word&rsquo;s default normal.dot. However, with the use of the <code>--reference-docx</code> option, you can specify a docx file that contains a custom format in order to format the output of the command.</p>
<p>For example:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">$ pandoc -f markdown ~/Desktop/Documentation.markdown <span class="se">\
</span></span></span><span class="line"><span class="cl">    -t docx -o ~/Desktop/Documentation.docx <span class="se">\
</span></span></span><span class="line"><span class="cl">    --reference-docx ~/Desktop/Reference.docx
</span></span></code></pre></div><p>This will convert the file &ldquo;<code>Documentation.markdown</code>&rdquo; into a Word document called &ldquo;<code>Documentation.docx</code>&rdquo;, using the reference file &ldquo;<code>Reference.docx</code>&rdquo;</p>
<p>So, about these reference docx files. &ldquo;Where can I get them from&rdquo; I hear you shout? Well, I&rsquo;ve been rather unsuccessful in my attempts to find any. <a href="assets/2015-09-28-01.doc">So I made my own!</a> Here&rsquo;s one that looks like a rendered Markdown webpage. Plug this in to the above commands, and your markdown will &ldquo;accurately&rdquo; translate into printed documentation!</p>
<p>If you&rsquo;re a Markdown writer/user, and you have a hard time focusing on content rather than design, give this a go.</p>
]]></content:encoded></item></channel></rss>