Skip to main content

ASCII Lineart

I have a tendency to create documentation locally using Markdown. The reason(s) why are complicated, and beyond the scope of this post, but this is a conscious choice I've made when i'm creating posts (locally) before I upload them to Confluence (or on my personal site using Nikola).

However, even when I'm doing this, I've found incompatibilities between some of the tools on my system. One example was I created some documentation, but then wanted to include a list of directories (to further explain the documentation). I created my notes in ReText and then used the tree -d command to get a list of directories, redirecting the list to a text file to be included in my text.

This worked well, and in ReText I had to set the directory listing up as pre-formatted text so it would render correctly as a mono-spaced font in my documentation.

However, when I ran the code through pandoc (using the command line pandoc -o readme.html readme.md the code came through as unicode and higher order characters that made the documentation unreadable in a web browser.

Looking carefully at the HTML, it appeared it was only interpreting the resulting output as straight ASCII and the line drawing characters from tree -d seemed to be interpreted as some other higher order character.

On a whim, I checked to see if I could change the characterset for the HTML file by adding the following line into the HTML:

<meta http-equiv="Content-Type" content="text/html;charset=utf-8">

Opening an editor on the HTML file and adding that line at the top ensured that my HTML would render correctly (or at least close enough) when I pasted in the ASCII line art that I was satisfied. Then I could grab the rendered HTML from the file and paste it into a Confluence page. Problem solved!

References:

nikola - https://getnikola.com/

pandoc - http://linux.die.net/man/1/pandoc

retext - http://sourceforge.net/projects/retext/

tree - http://linux.die.net/man/1/tree