38

I've installed the Markdown Viewer Firefox addon, but I cannot get it to work on my Ubuntu installation. Firefox is my browser of choice and I am trying to move to Markdown in Vim as my basic text-writing software. Is there a way I can get this to work?

7 Answers 7

62
+100

Happy to report that I was able to find a solution that I provided here:

https://github.com/Thiht/markdown-viewer/issues/62#issuecomment-277702230

I've also copied it here for reference:

On Linux, you'll need to create a new MIME type here:

~/.local/share/mime/packages/text-markdown.xml

With the following content:

<?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="*.markdown"/>
  </mime-type>
</mime-info>

Then run:

update-mime-database ~/.local/share/mime

4
  • Could you copy it here? meta.stackexchange.com/a/8259/350309
    – Hex
    Commented Feb 6, 2017 at 15:38
  • Thanks! This worked for me in Ubuntu 16.04, Firefox 57.0.3, but only with the Markdown Viewer Webext add-on. With the Markdown Viewer add-on, it just displayed source/plain text.
    – alaferg
    Commented Jan 3, 2018 at 22:30
  • 2
    Worked for me on Ubuntu 17.10 with FF 59.0.1 and the GitLab Markdown Viewer add-on.
    – code_dredd
    Commented Mar 22, 2018 at 15:44
  • 1
    It really helped. For those who get an error that the file is not available for editing, please ensure you create the directories first with "mkdir -p ~/.local/share/mime/packages" and then you create the file. It really works well.
    – itsraghz
    Commented May 14, 2021 at 5:49
11

I had to manually edit my ~/.mozilla/firefox/<PROFILE>/mimeTypes.rdf. This review of the addon says:

For linux users, try to add "md" to .mozilla/*.default/mimeTypes.rdf this line : mdin text/plain section :)

Hmm. I couldn't find a text/plain section, but I found this page is helpful:

If there is not yet an existing RDF node for 'text/plain' add it, and add "md" as a file extension.

<RDF:Description RDF:about="urn:mimetype:text/plain"
       NC:value="text/plain"
       NC:fileExtensions="md"
       NC:description="Text Document">
   <NC:handlerProp RDF:resource="urn:mimetype:handler:text/plain"/>
</RDF:Description>

However, what I ended up doing was:

<RDF:Description RDF:about="urn:mimetype:text/plain; charset=utf8"
               NC:value="text/plain; charset=utf8"
               NC:handleInternal="true"
               NC:description="Markdown Document">
  <NC:fileExtensions>md</NC:fileExtensions>
  <NC:fileExtensions>mkd</NC:fileExtensions>
  <NC:fileExtensions>mdown</NC:fileExtensions>
  <NC:fileExtensions>markdown</NC:fileExtensions>
  <NC:handlerProp RDF:resource="urn:mimetype:handler:text/plain; charset=utf8"/>
</RDF:Description>

It seemed to be the NC:handInternal="true" that did the trick. Interestingly, it seems it does not work with the text/markdown or text/x-markdown MIME types. The charset=utf8 is because I write all my Makefiles in Unicode.

4
  • One have to restart Firefox after modifying the mimeTypes.rdf file for changes to be applied.
    – iurii
    Commented Aug 6, 2014 at 15:37
  • I just installed the Firefox Markdown Viewer on Kubuntu 12.04 and it worked perfectly out of the box. No tweaks required.
    – MountainX
    Commented Jan 17, 2015 at 20:17
  • Did not work for me in Ubuntu 16.04 with FF 54.0. @Brad's solution did work. Commented Aug 11, 2017 at 23:41
  • 1
    @KeithRobertson Yeah, this solution is dated. You see it's from 3-1/2 years ago...
    – Kazark
    Commented Aug 14, 2017 at 17:18
3

I was able to solve the same problem by putting the following line into ~/.mime.types.

text/plain                                   md markdown
0
2

Building on the solution provided by @Brad I fixed the problem for all users on an Ubuntu 16.04 machine, not just the current one:

sudo mkdir -p /usr/local/share/mime/packages
sudo gedit /usr/local/share/mime/packages/text-markdown.xml
sudo update-mime-database /usr/local/share/mime

The file I created is the same as in the solution provided by @Brad -

<?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="*.markdown"/>
  </mime-type>
</mime-info>

Firefox now renders markdown for all users on the machine, rather than offering to download the files.

I'm sure this will work for other flavors and versions of Linux, but I've only tried it on the one I'm using, Ubuntu 16.04 LTS.

1

I tried Kazark's solution with no success. So I restored the mimeTypes.rdf file to the default content and it worked.

To do so:

  • In a terminal: firefox --ProfileManager
  • Create a dummy profile and start Firefox with it
  • Then in ~/.mozilla/firefox/, copy mimeTypes.rdf from *.dummy directory to your profile directory (probably *.default)
  • Restart Firefox and test
0

I installed https://addons.mozilla.org/en-us/firefox/addon/markdown-viewer-webext/ right now. It is a signed Add-on from the official Mozilla Add-ons Repository and it is compatible with multiprocess. Cool. :)

0

to simplify run this in terminal

echo "<?xml version=\"1.0\"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
  <mime-type type=\"text/markdown\">
    <glob pattern=\"*.md\"/>
    <glob pattern=\"*.mkd\"/>
    <glob pattern=\"*.mkdn\"/>
    <glob pattern=\"*.mdwn\"/>
    <glob pattern=\"*.mdown\"/>
    <glob pattern=\"*.markdown\"/>
  </mime-type>
</mime-info>" > ~/.local/share/mime/packages/text-markdown.xml;
update-mime-database ~/.local/share/mime

and in the extension on advance options, allows the file access

take note, I change

<mime-type type="text/plain">

to

<mime-type type="text/markdown">

so you can associate markdown files to open with firefox separately to other text files

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .