Bosse_B
Posts: 981
Joined: Thu Jan 30, 2014 9:53 am

How to display markdown document with rendering on RPi4?

Tue Jun 30, 2020 8:39 am

I am keeping development notes in readme.md files and on Windows (using Firefox) I can easily read these with the formatting shown by opening the file using FireFox. I have installed the addon "Markdown viewer webext" into Firefox.

Now I am moving development onto the RPi4 itself and it would be very handy if I could read the document there too, but the Chromium browser on RPi is not capable of doing that out of the box.
And if I go to the settings/extensions it does not find anything when searching for markdown.

So what are my alternatives to get rendering of md documents working on RPi4?
Installing Firefox? Is that even possible?

UPDATE:

I found that one could install firefox-esr via the command line, so I did that.
Then I also installed the same markdown extension as is used on my Windows machine.
I also synced my FF account so I got all the bookmarks transferred etc.
But when I use the File/Open dialog to select the readme.md file it is NOT displayed as on Windows.
Instead FF offers to open it in a text editor, which is not what I want.
How can this be fixed on Raspbian?
Bo Berglund
Sweden

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26665
Joined: Sat Jul 30, 2011 7:41 pm

Re: How to display markdown document with rendering on RPi4?

Tue Jun 30, 2020 9:16 am

You could try Visual Studio Code - that runs on a Pi4 and has a Markdown viewer extension.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

User avatar
Botspot
Posts: 1264
Joined: Thu Jan 17, 2019 9:47 pm
Location: Texas
Contact: Website

Re: How to display markdown document with rendering on RPi4?

Tue Jun 30, 2020 4:02 pm

Would installing a native markdown viewer work?
See this link for suggestions: https://softwarerecs.stackexchange.com/q/17714
I've developed the most intuitive RaspiOS img editor on the planet.
With a GUI similar to Gparted, managing imgs and sd cards is a breeze!
Boot it in a VM, Flash from the Internet at top speed, Mount (to drop in files), Shrink/Expand, Repair, and more.
https://github.com/Botspot/Pi-Power-Tools
> 400 users! 8-)

User avatar
scruss
Posts: 3218
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: How to display markdown document with rendering on RPi4?

Tue Jun 30, 2020 5:03 pm

No matter what editor you use, you'll need something to render the md to HTML:

Code: Select all

sudo apt install cmark markdown
There are lots of flavours of Markdown: cmark is now more common, but markdown is Gruber's original Perl script.

The editor I use has a preview/render option, which drops a copy of the rendered text int the default browser.. Your workflow may be different, but you'll almost definitely need markdown and/or cmark.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

Bosse_B
Posts: 981
Joined: Thu Jan 30, 2014 9:53 am

Re: How to display markdown document with rendering on RPi4?

Tue Jun 30, 2020 6:21 pm

Thanks for the suggestions!
Regarding markdown I see it displayed properly on Github (the readme files there are usually md).
We also use Visual SVN as the subversion server and in its browsing interface (a bit more decorated than Apache Svn's built-in) whenever one reaches a folder with a readme file it is rendered completely.
I realize this is server side rendering, but I found this Firefox markdown extension that works fine also if the readme.md file is opened in FireFox using a file:// url, so then Firefox (or rather its extension) does the work and the file displays OK.

Regarding Visual Studio, I have not used it since 20 years back when we stopped using Visual Basic....
We now use Delphi or FreePascal and other tools but not VS.

So I guess a standalone markdown viewer on Raspbian would be what I have to test then.

Just a question regarding the FireFox extension:
How come it installs without any errors on Firefox in Raspbian, but then whenever the target URL is an md file it pops up the dialog box asking what it should do next.
And the alternatives do not include "render using extension" or similar. Just open text editor or save to file...
RPiFireFoxOpenDialog.png
RPiFireFoxOpenDialog.png (46.36 KiB) Viewed 141 times
Bo Berglund
Sweden

Bosse_B
Posts: 981
Joined: Thu Jan 30, 2014 9:53 am

Re: How to display markdown document with rendering on RPi4?

Tue Jun 30, 2020 6:40 pm

OK, solved!

I went to the extension author's homepage and found this:
Installing on Linux

Firefox on Linux may not know how to handle markdown files by default (see #2). A workaround for this is to add a new MIME type for markdown file extensions. Add the following XML to ~/.local/share/mime/packages/text-markdown.xml:

Code: Select all

<?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
  <mime-type type="text/plain">
    <glob pattern="*.md"/>
    <glob pattern="*.mkd"/>
    <glob pattern="*.mkdn"/>
    <glob pattern="*.mdwn"/>
    <glob pattern="*.mdown"/>
    <glob pattern="*.markdown"/>
  </mime-type>
</mime-info>
Then run

Code: Select all

$ update-mime-database ~/.local/share/mime
Once I had done this the Readme.md file rendered OK in FireFox!

Case solved!
Works on my RPi4 with Raspbian Buster :)
Bo Berglund
Sweden

Return to “General discussion”