mapitman / mdview

Convert markdown to HTML and launch it in a browser.
MIT License
25 stars 8 forks source link

Add option to select temporary directory for output. #8

Closed PaulSchulz closed 4 years ago

PaulSchulz commented 4 years ago

Thank you for this software. mdview 1.3.0 from Mark Pitman (markpitman) installed

On Ubuntu 20.04, running 'mdview README.md', creates a temporary file in $HOME/snap/mdview/common For some reason: 1) A popup asks whether mdview should be allowed to create this file. This is a little annoying but OK. 2) chromium-browser refuses to open the generated html file.

I would prefer the temporary files went into /tmp (system temp, which is what the documentation appears to suggest), or allow this to be set when called. (eg. with a -t option)

The workaround at this stage is to use the same '-o' output option for all the md file I wish to format.

mapitman commented 4 years ago

I have a feeling that behavior is because it is running as a confined snap. Probably a security reason that snap disallows reading files from other snap's directories. I'll take a look and see what can be done. Thanks for taking the time to submit an issue!

mapitman commented 4 years ago

I'm looking at this today and trying to figure out a way to fix this.

There are multiple issues here.

  1. Chromium-Browser is also a snap package and does not have access to either the temp directory that mdview writes to when it is installed as a snap nor to /tmp
  2. A confined snap can't write to /tmp

For the short term, if you have Go installed, you can do the following:

sudo snap remove mdview
go get github.com/mapitman/mdview

Restart your terminal before trying to use it. I'm still going to try to figure out how to make it work as a snap when your default browser is also a snap.

mapitman commented 4 years ago

There will be a new snap release shortly, 1.4.0. I can't do anything about the prompt to allow writing the file. That is a security "feature" of snaps. But I was able to make it now work with a snapped browser, like Chromium.