simov / markdown-viewer

Markdown Viewer / Browser Extension
MIT License
1.05k stars 133 forks source link

Not rendering local .md file despite allowing file:///* URLs and local file URLs #131

Closed Arrow7000 closed 7 months ago

Arrow7000 commented 3 years ago

Hi, thanks for creating this extension!

For some reason this isn't rendering markdown for me.

image

I've allowed both file:///* URLs and access to local file URLs as you can see in the screenshot below.

The file URL is file:///C:/Users/Aron/Google%20Drive/today-scratchpad.md

image

simov commented 3 years ago

Not sure, this should definitely work. Just checked that exact same configuration on Linux and it works. Can you try disabling any/all your other extensions to check if there is incompatibility issues between extensions?

Arrow7000 commented 3 years ago

I'm using Windows 10. I've just rebooted my computer and opened the file in Incognito with all other extensions disabled but it's still not working.

image

However it does work in Firefox where I've installed the same extension, so it seems to be a Chrome-only thing.

simov commented 3 years ago

Wait a sec in this case you have to enable the extension in Incognito Mode. By default all extensions are disabled in Incognito Mode.

Scratch that I see that you have enabled it, and also I just tested it on my end as well.

simov commented 3 years ago

So again, that's pretty weird, I don't have any other report regarding issues with Windows and I don't have a Windows machine around to test. The only thing that I can think of besides incompatibility with other extensions is another program registering the .md file extension.

You can easily test that by setting up some random file extension to your file and updating the path matching regexp for the file:/// origin to match it.

Arrow7000 commented 3 years ago

I'm trying to do that but:

  1. there isn't a option for the file:/// origin, only https://*, http://* and *://*. I'm guessing the *://* is right, but is it?
  2. I'm trying to add a blamd extension but when I refresh the page the entry just disappears, which doesn't seem right. See the gif for a screen recording. The flash is me refreshing the page. The entry just disappears?

Also it wouldn't make sense to me that the problem is another extension having registered the .md extension, since the same thing happened when I had all other extensions disabled, as in my previous comment.

image

Markdown Viewer (1)

simov commented 3 years ago

md

You have to enable the extension for file:/// URLs in order to see that option.

simov commented 3 years ago

Wait a sec, something isn't right with your recording. Certain UI elements are missing. Which version of Chrome do you use? Also which version of the extensions, is it downloaded from Chrome Store?

Arrow7000 commented 3 years ago

I have enabled the extension for file:/// URLs. See the screenshot on my initial comment.

This is on the latest version of Chrome, currently v87.0.4280.66. And yes it's from the Chrome store. I didn't sideload it or anything. The extension is version 3.9.

wngsy commented 3 years ago

I have the same problem on Chrome Version 87.0.4280.141 (Official Build) (64-bit) running on kubuntu. I have also tried disabling extensions. Oddly, it works on Brave Version 1.18.78 Chromium: 87.0.4280.141 (Official Build) (64-bit) running on kubuntu

simov commented 3 years ago

I am using Version 87.0.4280.141 (Official Build) (64-bit) on Ubuntu. It works on Chrome, Chromium, Firefox, Opera and Edge Dev.

wngsy commented 3 years ago

On firefox, it would only force a endless 'save dialog' if I try to open a md file from the file system. I followed a work around found for another 'markdown viewer' to get it to work correctly. https://github.com/KeithLRobertson/markdown-viewer#support-for-local-files-on-linux

Chrome still not rendering. I installed the Kubuntu LTS about 4 weeks ago. Used the chrome deb pkg downloaded from the official google page.

simov commented 3 years ago

Not Firefox, my bad, I'm glad you found the fix for it. Unfortunately I have no idea why Chrome isn't loading local files in case you have both switches regarding this in the extension's settings turned on.

somahargitai commented 3 years ago

I had a similar problem with my README.MD file.

My solution was that in advanced origins I edited the local file match. The default version allows these: \.(?:markdown|mdown|mkdn|md|mkd|mdwn|mdtxt|mdtext|text)(?:#.*|\?.*)?$ But it does not contain MD extensions written with capitals. So I highly recommend you to add it to this list: \.(?:markdown|mdown|mkdn|md|MD|mkd|mdwn|mdtxt|mdtext|text)(?:#.*|\?.*)?$

Maybe it will help others too.

Arrow7000 commented 3 years ago

@somahargitai I'm glad you were able to solve your problem but my file has a lowercase .md extension and still doesn't work. 🤷

SlodeSoft commented 1 year ago

Here add Allow acces to files URLS works for me !

Manage Extension =

image

Arrow7000 commented 1 year ago

@SlodeSoft I've had that option enabled the whole time. See my initial comment. It still doesn't work for me.

nello commented 1 year ago

I've got the same problem, but for me it's even slightly weirder. This extension has been working for me and has abruptly just stopped. No extensions added to Chrome in that time.

simov commented 1 year ago

@nello no recent updates on the extension either. If nothing else works maybe you could try to uninstall/install as a last resort, I read about some issues with the underlying service worker being stuck in manifest v3, which the extension now uses. Just to rule this out.

nello commented 1 year ago

@simov thanks for the really quick response! Killing Chrome and restarting the Mac fixed it for me. Some extensions were working, including an asciidoc one I regularly use, but this one seemed to have run into difficulties. Sorry for the false alarm!!

aidtopia commented 1 year ago

I found it necessary to switch Chrome's "Safe Browsing" level (under "Privacy and Security" settings) from "Enhanced" to "Standard." This is in addition to allowing access to file:// URLs, etc.

I'm not sure when it broke (it's been a while), but, with the Safe Browsing change, I got it working again in Chrome Version 114.0.5735.199 (Official Build) (64-bit) on Windows 10.

Arrow7000 commented 7 months ago

Not sure why I didn't think of doing this sooner but I looked at the service worker devtools and this is the error I get:

Error handling response: TypeError: Cannot read properties of undefined (reading 'http://127.0.0.1:5500')
    at detect (chrome-extension://ckkdlimhmcjmikdlpkmbgfkaikojcbjk/background/detect.js:85:20)
    at chrome-extension://ckkdlimhmcjmikdlpkmbgfkaikojcbjk/background/detect.js:67:15

This is a screenshot of the debugger when I pause on exceptions:

image

It looks like the error occurs because we're indexing into state.origins, even though state doesn't seem to have an origins field at all

image

simov commented 7 months ago

I really don't know how you ended up not having origins object in case that is part of the defaults:

https://github.com/simov/markdown-viewer/blob/1b8221a8fbe53f2e0be9f9af7610e61254a06bb6/background/storage.js#L57-L63

Re-installing the extension should definitely fix this.

Arrow7000 commented 7 months ago

I removed and reinstalled it but it still didn't work – until I clicked the "defaults" button and then suddenly it worked. So it's fixed now, but I don't know why it didn't work right after reinstallation, even when I gave it all the required permissions