simov / markdown-viewer

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

How to open local markdown file in firefox59.0.1 #54

Closed HeJiaJunPan closed 1 year ago

HeJiaJunPan commented 6 years ago

When I disable the extension, the browser can open the local file. However, after the extension is enabled, the file content is no longer displayed, let alone render the markdown document.

How do i set it up on firefox?Is the installation document more detailed?

HeJiaJunPan commented 6 years ago

I am a Chinese user and cannot use youtube.

The video content is also not very user-friendly.

simov commented 6 years ago

Firefox does not support rendering of markdown documents, that's why file rendering is not supported in Markdown Viewer for Firefox.

HeJiaJunPan commented 6 years ago

@simov What is the method of compromise?

Markdown Viewer Webext works fine on firefox

simov commented 6 years ago

No, it does not work for file URLs.

From the first comment:

Note that the author notes that the extension only works "if the content is plain text". That means your browser needs to be rendering the file in a tab already, just without rendering the markdown elements. If it's downloading it instead, the suggestion from 7cac17 below, to add a MIME type for markdown files, worked for me (I'm also on Ubuntu).

Related to this https://github.com/KeithLRobertson/markdown-viewer/issues/2#issuecomment-321940542

njnygaard commented 6 years ago

This plugin works for me in FF 59.0.2: https://github.com/painyeph/GitLabMarkdownViewer

I would venture a guess that it has to do with:

  "content_scripts": [
    {
      "matches": ["file:///*.md", "file:///*.markdown"],
      "js": ["js/markdown-it.min.js",
             "js/highlight.pack.min.js",
             "js/katex.min.js",
             "js/texmath.js",
             "js/main.js"
             ]
    }
],

I would submit a PR, but I don't really know how to browser extensions. Do you have recommendations on tutorials? I'd have to try chrome and ff.

simov/markdown-viewer is superior because of the themes, so I would like to contribute here if possible.

simov commented 6 years ago

@njnygaard the extension you are linking to doesn't work with file URLs, for example file:///some/path/file.md. Check out the screencast https://youtu.be/c7Lb_Y092ok where I'm showing a simple file server running on localhost that you can use to access your markdown files.

njnygaard commented 6 years ago

That's a great idea with the local file server, that will solve my cross platform problem too.

On my system, opening file:/// with the linked extension seems to work fine...

image
simov commented 6 years ago

That's interesting, it doesn't work on my end on Linux.

njnygaard commented 6 years ago

Okay good to know. Yeah I would be frustrated if I tried it and it failed when I switched to my personal computer.

I'm linking the gist from your video in case anyone else comes across this: https://gist.github.com/simov/4e4bb0a1ecbb45b92e23608388e60909

That file server is exactly what I need, I didn't know there was an npm package to view files. Perfect solution for me. Thanks!

gotjen commented 3 years ago

@njnygaard, would you explain to the lay person how to use this code to start a webserver? How do I set up that js to run passively, not have to launch it every time?

// server.js
var express = require('express')
var serveIndex = require('serve-index')
var serveStatic = require('serve-static')

var app = express()

app.use(serveStatic('/home/s'))
app.use('/', serveIndex('/home/s', {'icons': true, view: 'details'}))

app.listen(8001)
simov commented 3 years ago

It depends on your operating system. On Linux I'm using systemd, quick search on Google shows that the equivalent of that on Mac OS is launchctl.

simov commented 1 year ago

I have created a separate documentation file regarding issues and their workarounds in Firefox including information about how can you render local file:/// URLs on Linux.

Let me know if you find anything missing, but for now I am closing this issue as it contains a lot of obsolete and incorrect statements about certain issues.