asciidoctor / asciidoctor-firefox-addon

:wolf: An add-on for Mozilla Firefox that converts AsciiDoc files to HTML directly in the browser using Asciidoctor.js.
https://addons.mozilla.org/en-US/firefox/addon/asciidoctorjs-live-preview/
MIT License
32 stars 9 forks source link

does not honor `/text/asciidoc` mime-type #42

Closed getreu closed 7 years ago

getreu commented 8 years ago

Re: Mimetype for Asciidoc In reply to this post by Hocdoc

According to this RfC 6648 http://www.rfc-editor.org/bcp/bcp178.txt

The /etc/mime.types entry should be:

 text/asciidoc                                  adoc asciidoc

There is an issue with the firefox plug-in. Once the new mime type enabled, the plugin does not render any more. Chrome and chromium do.

ggrossetie commented 8 years ago

Hello @getreu,

According to this RfC 6648 http://www.rfc-editor.org/bcp/bcp178.txt

I'm not familiar with RFC but this page is more about deprecating parameters starting with "X-", where the "X" is commonly understood to stand for "eXperimental" or "eXtension"... no ?

There is an issue with the firefox plug-in. Once the new mime type enabled, the plugin does not render any more. Chrome and chromium do.

This is strange because we are not using (at least explicitly) the MIME type to decide if we must convert the content or not. In fact we are checking two things:

  1. check that document.location is ending with .asciidoc, .adoc, .ad or .asc OR containing .asciidoc?, .adoc?, .ad? or .asc?
  2. check that document.contentType is not HTML

https://github.com/asciidoctor/asciidoctor-firefox-addon/blob/master/data/asciidocify.js#L12

I will try to reproduce this issue, the only thing I have to do is add text/asciidoc adoc asciidoc in /etc/mime.types and try to load a local file named test.adoc ? Could you tell me which version of Firefox/Iceweasel are you using ?

Thanks

getreu commented 8 years ago

I will try to reproduce this issue, the only thing I have to do is add text/asciidoc adoc asciidoc in /etc/mime.types and try to load a local file named test.adoc ? Yes that's all. Could you tell me which version of Firefox/Iceweasel are you using ? iceweasel 38.5.0

getreu commented 8 years ago

I remember now: firefox wants to save the adoc file on disk ...

ggrossetie commented 8 years ago

I don't know how to handle this issue because as soon as you define a MIME type, Firefox tries to find a plugin (not an add-on) to "open" the file. As there's no AsciiDoc plugin, Firefox tries to download the file.

I think only plugin can define "MIME type" and AFAIK there's no way to tell Firefox to do nothing :disappointed:

I've never create a plugin for Firefox so if someone want to give it a try, here is the documentation: https://developer.mozilla.org/en-US/docs/Plugins/Guide/Plug-in_Development_Overview

As a workaround, you need to remove this line from /etc/mime.types

maxandersen commented 8 years ago

I bumped into this while working on gdoc2adoc and wanted to force google to save with .adoc extension rather than .adoc.txt.

Worked around this limitation in Firefox by installing https://addons.mozilla.org/En-us/firefox/addon/open-in-browser/ which allow me to choose to open .adoc with mimetype text/adoc in browser anyway.

ggrossetie commented 8 years ago

Thanks for sharing.

ggrossetie commented 7 years ago

Since the Firefox and the Chrome extension had merged, I'm closing this issue (because this issue is specific to Firefox).

@getreu If you reproduce this issue with the latest version on Firefox 57, please open a new issue here: https://github.com/asciidoctor/asciidoctor-chrome-extension/issues