Friday, August 16, 2013

Viewing Markdown files in Firefox on Linux

There are Firefox plugins for viewing Markdown files - but neither of the big ones - Markdown Editor and Markdown Viewer - worked at all on my linux distro (Mint 15), even with the mimetypes.rdf workaround. There are of course editors like UberWriter that will do some special formatting of MD files, but none I have found really track well to the actual HTML produced by the browser plugins. Since many of my colleagues use Firefox on Windows where the plugins work, I wanted to know what they would look like. In desperation I hacked a quick and dirty solution using a Python translator, markdown2.
  • first install pip

    sudo apt-get install python-pip
  • install markdown2
    pip install markdown2
  • for me this had already run 'python setup.py install'
    • if it doesn't for you then run manually
  • test at command line - should be available
    markdown2
  • now try all together - assumes firefox is on your path
    markdown2 README.MD > README.html; firefox README.html
  • add as a shell alias - modify ~/.bashrc and add

       function mark() { 
          markdown2 "$@" > "$@".html; 
         firefox "$@".html
       }
    
  • now try
    source ~/.bashrc 
    mark README.MD
    

No comments:

Post a Comment