First we need to install pandoc from their official GitHub:
cd ~/Downloads && wget -N https://github.com/jgm/pandoc/releases/download/3.7.0.2/pandoc-3.7.0.2-1-amd64.deb && \
sudo dpkg -i pandoc-3.7.0.2-1-amd64.deb
Create assets directory for pandoc and put some css files in here:
mkdir -p ~/.local/share/pandoc/ && wget http://a-dma.github.io/gruvbox-css/gruvbox-dark-medium.min.css -O ~/.local/share/pandoc/gruvbox-dark-medium.min.css
Create an executable:
tee ~/.local/bin/md << EOF
pandoc $1 --highlight-style zenburn -s -c ~/.local/share/pandoc/gruvbox-dark-medium.min.css.css -o /tmp/pandocRenderedMarkdown.html
xdg-open /tmp/pandocRenderedMarkdown.html
EOF
Make sure ~/.local/bin
in your PATH
chmod +x ~/.local/bin/md
Create desktop application:
tee ~/.local/share/applications/md.desktop << EOF
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
NoDisplay=true
Exec='/home/$USER/.local/bin/md' %f
Name=Markdown Viever
Comment=Markdown Viever
Categories=Development;Code;
EOF
Finally, edit mimelist:
vi ~/.config/mimeapps.list
Like that:
Confirm that it works:
which md
# ~/.local/bin/md
md README.md
# Should appear in your browser
xdg-open README.md
# Should appear in your browser
Result should be similar to this:
How to use it in NeoVim?
Install NvimTree
Open your project and you will see file tree on the left.
Press s
on any md file and it will be opened in a browser.
Top comments (0)