I edit Markdown files as part of writing blog posts; as part of my quest to use a Raspberry Pi instead of my computer, I started exploring ways to edit Markdown on the Pi itself. I put this guide together to help anyone else get some ideas of the options for working with Markdown on Raspberry Pi.
Raspberry Pi can be used to view and edit Markdown files using a command line interface or a graphical interface. Supported Markdown tools include mdless, vim, Ghostwriter and Pandoc. These have to be installed before being used on the Raspberry Pi.
|Command Line||Graphical Interface|
Command Line Markdown tools generally don’t have great preview functionality if you want to see what your final product is going to look like, though I’ve still found them useful for getting a quick idea. Graphical tools offer preview of what your Markdown will look like if it’s compiled to a web page or PDF.
This guide looks at how to install the above tools and how to use them to edit Markdown files on a Raspberry Pi.
Ghostwriter is my favourite way to work with Markdown on Raspberry Pi – I’m currently using it to write a book.
Ghostwriter is a Markdown editing tool with a very simple (distraction free) interface, it also offers simple file browsing (good for working on book chapters), live preview, and focus mode (making it even harder to be distracted).
To install Ghostwriter on Raspberry Pi, open up a Terminal and type in the following commands:
sudo add-apt-repository ppa:wereturtle/ppa sudo apt update sudo apt install ghostwriter
These commands add a repository to apt, then tell apt to install Ghostwriter from that repository. If you need more help with the instructions, check out the Ghostwriter Github here.
Once installed, it’s straightforward to open and run Markdown files. I use the command
ghostwriter in the Terminal to open the app, though it should also be available under the Raspberry Pi menu. The menu along the top can be used to open files, toggle preview window, and enter focus mode (where I like to do my serious writing).
If you’re writing a book on your Raspberry Pi, you might also be interested in Pandoc. A guide on using Pandoc to write a book can be found here, alternatively I included Pandoc at the end of this list as an option on how you can output Markdown to another format.
If you’re looking for more info, check out the Ghostwriter website here.
mdless is a simple command line tool that displays formatted Markdown in a terminal. It’s designed to work in a similar way to less, a popular command line tool for viewing plain text in a terminal. Apart from formatting Markdown, mdless helps you scroll through text that takes up more space than the terminal window.
A Raspberry Pi terminal can run mdless to display formatted Markdown in the terminal. Ruby is required to run mdless, and this works on Raspberry Pi. My Pi already had Ruby installed, but I’ve included a step below if yours doesn’t (or if you’re not sure, there’s no harm in attempting to install it again – the package manager will tell you if it’s already there).
To install and run mdless on Raspberry Pi, follow these steps:
- Open up a terminal and type in this command to update the Pi:
sudo apt update && sudo apt upgrade
- Install Ruby if it is not already installed:
sudo apt install ruby-full
- Type in this command to download and install mdless:
sudo gem install mdless
- Use mdless on a Markdown file with this command:
Formatted Markdown will be displayed on the terminal (note in the picture above I made a mistake in the original file by formatting the word ‘bold’ with italics instead of bolding it).
For more information about mdless, check out their website here. If you had trouble installing Ruby, an alternative installation method can be found here (use the Ubuntu steps and adapt it for Pi).
ReText is an editor and previewer of markdown files. It has a simple user interface and runs using Python.
Raspberry Pi can run ReText, and it can be installed using the Python package manager already available on Raspberry Pi (pip).
To install ReText on Raspberry Pi, open up a Terminal type the following command:
pip3 install ReText
This command will install ReText on your Raspberry Pi, as well as any dependencies that are required to run it.
Once installed, you can open ReText on a file using the following command:
I found ReText good for its instant preview feature. As you type markdown into the file you are editing, the preview comes up immediately (unlike mdless where you need to run a separate command on the file to get an idea of what the formatting is like). You can also disable the preview if you find it annoying to read the same thing twice.
If you want to read more about ReText, check out their website here.
Grip is a Markdown preview tool that runs a mini web server on your computer so that you can preview Markdown files using a web browser. It uses the Github API to render the Markdown into HTML (this also means it needs an internet connection to work).
Raspberry Pi can run Grip as it is written in Python. I found the installation very straightforward, though using it is a little more complicated than ReText. Essentially you are turning your Raspberry Pi into a mini web server, and then you have to use a browser (like Chromium) to actually display the Markdown (as Grip converts Markdown to HTML).
To install Grip, open up a Terminal and type in the following command:
pip install grip
To run Grip on a Markdown file, use the following command:
Grip will tell you the address to go to in your web browser to view this file. You can also run Grip a folder and have it serve all the Markdown files in that folder. If you do this, you will need to specify the filename you want to view in your web browser address bar.
Any change you save to the .md file will trigger Grip to update the web page automatically. This live preview is very useful for seeing how changes to your .md file effect the HTML outcome.
Grip has many more options available about how it can serve .md files, and how it can be used in the process of generating Readme files when programming. For more detail on this, check out their website here.
5. Vim, Emacs, and Nano
I group these together as they’re all command-line based text editors that offer Markdown formatting assistance (syntax highlighting). It’s personal taste which one you prefer for Markdown editing (my preference is Vim), though I’ve included below how to get started with all three.
Raspberry Pi supports Vim, Emacs, and Nano, though only Nano is available on a fresh install of the Raspberry Pi Operating System.
Installing these text editors can be done using the package manager, which means the command is (for example):
sudo apt install vim
Each text editor will edit Markdown files as soon as it’s installed, but if you want features specifically for working with Markdown then try this:
- For Vim, plugins are available that support Markdown formatting, a good example is here (if you don’t have a Vim package manager installed, check out the instructions as the end for installing without one).
- For Emacs, a Markdown mode is available that includes preview of Markdown, instructions for downloading and installing can be found here.
- For Nano, Markdown highlighting can be added using the guide here.
Pandoc is a tool that transforms one type of document to another. It supports an extensive list of input and output file formats, and allows you to convert from any of these inputs to any of its outputs. Pandoc supports Markdown as an input format.
Raspberry Pi can use Pandoc to convert a Markdown file into any of the following format:
- Word .docx
(yes you read that right, Pandoc can convert Markdown to PowerPoint, if you want to know more about displaying slides on a Raspberry Pi check out my guide here).
Pandoc is easily installed using apt (
sudo apt install pandoc), and details on how to use it can be found here.