markdown-viewer icon indicating copy to clipboard operation
markdown-viewer copied to clipboard

How to open local markdown file in firefox59.0.1

Open HeJiaJunPan opened this issue 7 years ago • 11 comments
trafficstars

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 avatar Mar 28 '18 05:03 HeJiaJunPan

I am a Chinese user and cannot use youtube.

The video content is also not very user-friendly.

HeJiaJunPan avatar Mar 28 '18 05:03 HeJiaJunPan

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

simov avatar Mar 28 '18 10:03 simov

@simov What is the method of compromise?

Markdown Viewer Webext works fine on firefox

HeJiaJunPan avatar Mar 28 '18 12:03 HeJiaJunPan

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

simov avatar Mar 28 '18 12:03 simov

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.

njnygaard avatar Apr 25 '18 15:04 njnygaard

@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.

simov avatar Apr 25 '18 16:04 simov

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

njnygaard avatar Apr 25 '18 16:04 njnygaard

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

simov avatar Apr 25 '18 16:04 simov

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!

njnygaard avatar Apr 25 '18 16:04 njnygaard

@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)

gotjen avatar Dec 12 '20 21:12 gotjen

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 avatar Dec 12 '20 21:12 simov

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.

simov avatar Mar 18 '23 09:03 simov