simov / markdown-viewer

Markdown Viewer / Browser Extension
MIT License
1.11k stars 137 forks source link

Rendering does not work on Firefox #213

Open rovf opened 1 year ago

rovf commented 1 year ago

I have installed the Addon "simov/markdown-viewer" on Firefox 113.0.1, running on MacOS 12.6.5

When opening a MD-file (name: playground.md) using File/Open, I get two options:

Since I don't want to store the file (after all, it is on disk already), and I happen to have MarkEdit installed (version 1.6.2), I used the latter. MarkEdit is then started and the file loaded, but not rendered (MarkEdit does not support a preview).

simov commented 1 year ago

Can you verify that the local file access is enabled for the extension in the advanced options page?

It should look like this if enabled correctly: Screenshot from 2023-05-24 13-54-50

In case the box is highlighted with a red color then click on the refresh button.

If all looks good then maybe you are having some mime type misconfiguration issues on your machine. I don't have any other reports of local file URLs not loading on MacOS as that is a known issue on linux for example.

rovf commented 1 year ago

It looks the same. Actually, thes settings were already the default. BTW, I found that the Chrome version for this extension suffers a similar problem. The difference is that the Firefox extension starts the App "MarkEdit" to show the file, while the Chrome version simply shows the unrendered file in a browser tab.

simov commented 1 year ago

That's even more strange, can you verify that all of the points outlined here are looking good on Chrome on your end?

roberto-red commented 1 year ago

Same behaviour here:

Opening a .md file stored on disk using its file:/// URL shows the plain text. Nothing in the console.

Interestingly, the favicon is replaced by the Markdown Viewer icon: Screenshot 2023-05-25 at 16 15 20

Edit: whoops, I toggled the HTML/Markdown button in the extension panel and it seems to work now. Sorry!

rovf commented 1 year ago

whoops, I toggled the HTML/Markdown button in the extension panel and it seems to work now.

Where is this panel? Do you mean in the Preferences of Firefox? I don't see such a button there.

roberto-red commented 1 year ago

I mean the webextension preferences, right in the Firefox toolbar:

Screenshot 2023-05-25 at 16 29 22

rovf commented 1 year ago

Ah, the first time I noticed this panel! But it did not help: I toggled the settings to HTML and back to MARKDOWN, and still when I open a .md file, Firefox starts the program MarkEdit for me, loaded with this file.

rovf commented 1 year ago

That's even more strange, can you verify that all of the points outlined here are looking good on Chrome on your end?

Found it! "Allow access to file URLs" was turned off. Now I turned it on, and it works in Chrome!! Only Firefox does not work yet....

simov commented 1 year ago

@rovf most likely an external application (MarkEdit) has updated your mime types config file for Firefox on MacOS resulting in Firefox no longer rendering it as plain text by default and instead showing that popup to either download it or open it with an external app. This would explain why the extension works for some users (roberto-red) on MacOS, but not for others as in your case.

As mentioned earlier, on Linux it is the other way around - access to local files does not work by default and therefore it is a known issue. I'm assuming that updating the mime types for Firefox on MacOS should be similar, but there is no way for me to validate that. Also, it seems other people on the internet are having similar issue but I couldn't find a definitive answer either.

rovf commented 1 year ago

How can I check the mime type? I did on the command line a file --mime *md, and for all md files it shows text/plain. Could it be that Firefox on MacOS has its own idea on how it handles such a file .... maybe based on the file extension?

roberto-red commented 1 year ago

@rovf Have you already checked your auto-open preferences on Firefox? Maybe that's where MarkEdit is configured to be triggered. Just guessing!

rovf commented 1 year ago

Ah, it associates the action "MarkEdit" with files of extension .md

What value should I set this association? I have the choices:

Since the first three choices are obviously wrong, I tried the last one. This opened a file browser, but I don't know which file (application) I should choose here. After all, MarkdownViewer is not an external application, but a browser extension.

simov commented 1 year ago

As far as I know that configuration is for unknown file types to Firefox, meaning files that it does not know how to render. By default markdown files should be rendered as plain text, meaning the browser knows how to render them even if it is a plain text only. Most likely MarkEdit has updated the internal mime type settings file that Firefox uses.

On Linux in particular that file can be located like this: Screenshot from 2023-05-26 13-42-23

But I don't know where a similar file can be found on MacOS and what are the contents of it.

peter-lyons-kehl commented 1 year ago

Unfortunately, the current Firefox ext. version 5.1 doesn't work (at least with file://) on current Firefox 116.0.2 on Manjaro Linux. It shows the Markdown source as plain text. I did follow all 3 methods from https://github.com/simov/markdown-viewer/blob/main/firefox.md, restarted Firefox after each, double-checked... "Markdown" is selected, file access granted...

Then I've installed https://addons.mozilla.org/en-US/firefox/addon/markdown-viewer-webext/ = https://github.com/Cimbali/markdown-viewer#support-for-local-files-on-linux. It works (at least with file://) with the exact Firefox settings.

Anyway, thank you. Hope this helps.

azuledu commented 10 months ago

https://github.com/simov/markdown-viewer/blob/main/firefox.md

cweiske commented 6 months ago

Related Firefox bug report: Bug 1319262: Mime type text/markdown is downloaded instead of displayed