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

"link:" does not work with firefox addon #31

Closed zaxebo1 closed 8 years ago

zaxebo1 commented 9 years ago

TL;DR version= "link:" does not goto target document on asccidoctor firefox addon, though it works on chromium and opera addon .

Detail=

Let there be a1.adoc

= This is a1

some text1
link:b1.adoc[Second document]

Let there be b1.adoc

= This is b1

some text2

Now i put a1.adoc and b1.bdoc on apache webserver on another machine2 (IP= 192.168.1.2) in my local network. Then sitting on machine1 (IP=192.168.1.1), i browsed to http://192.168.1.2/a.doc , then in opera and chromium addons for asciidoctor - when i click the link "Second document", then it correctly goes to b1.adoc . BUT when i click the same link "Second document" in firefox, then nothing happens (that is, the browser does not goto b1.adoc

Please correct this bug at earliest(if possible), as my all the documents are interlinked using "link:" and the we always use the inbuilt firefox browser in linux. Thanks in advance

zaxebo1 commented 9 years ago

That is,

link:b1.adoc[Second document] 

^is not working correctly in firefox addon of asciidoctor, though it works correctly in opera and chromium addon of asciidoctor

mojavelinux commented 9 years ago

This traces back to use setting the outfilesuffix to .adoc in the Chrome & Opera extensions, if I remember correctly.

zaxebo1 commented 9 years ago

i could not understand your suggestion. "Is it a bug" OR " i need to do some setting in my own asciidoc document" - in order to get it working?

(this is the most urgent issue for me, as we always use firefox. "If possible , suggest something soon" . Thanks in advance )

mojavelinux commented 9 years ago

I'm saying that I remember having this discussion with @Mogztter while developing the Chrome extension, so likely the fix just needs to be ported. The outfilesuffix attribute needs to be set in the plugin code.

ggrossetie commented 9 years ago

@mojavelinux I think you are right (good memory!) I will do some testing this week-end

mojavelinux commented 9 years ago

:+1:

zaxebo1 commented 9 years ago

thanks to both of you. :+1:

ggrossetie commented 9 years ago

I have a bad news... Mozilla forces me to sanitize the HTML produced by Asciidoctor: https://github.com/asciidoctor/asciidoctor-firefox-addon/blob/master/lib/main.js#L81

The link is correctly converted by Asciidoctor but the href attribute is then removed by the sanitize method.

mojavelinux commented 9 years ago

Right you are! It seems like the sanitizer strips any href that is a relative path. I tried it behind a webserver and the result is still the same. How annoying.

The issue I was talking about is actually different, but related. If you use the interdocument xref (e.g., <<other.adoc#>> then we need to set the outfilesuffix to match the file extension of the current file. Otherwise, it will try to link to a .html file. However, that's pointless to set since the sanitizer is erasing the href anyway.

We need to find out if this is a hard requirement for the add-on because breaking relative links kind of breaks the point of a web browser.

ggrossetie commented 9 years ago

Just read that absolute links are not striped away.

http://stackoverflow.com/questions/12757649/how-to-use-nsiparserutils-inside-firefox-addon-sdk-1-10-main-js

Is there a way to tell Asciidoctor to expand relative paths to absolute paths (using the current directory) ? Le 5 juil. 2015 12:57 AM, "Dan Allen" notifications@github.com a écrit :

Right you are! It seems like the sanitizer strips any href that is a relative path. I tried it behind a webserver and the result is still the same. How annoying.

The issue I was talking about is actually different, but related. If you use the interdocument xref (e.g., <<other.adoc#>> then we need to set the outfilesuffix to match the file extension of the current file. Otherwise, it will try to link to a .html file. However, that's pointless to set since the sanitizer is erasing the href anyway.

We need to find out if this is a hard requirement for the add-on because breaking relative links kind of breaks the point of a web browser.

— Reply to this email directly or view it on GitHub https://github.com/asciidoctor/asciidoctor-firefox-addon/issues/31#issuecomment-118561366 .

mojavelinux commented 9 years ago

Just read that absolute links are not striped away.

From what I remember from my tests, file:// URLs are stripped away no matter what, so I'm not sure if this will solve the problem for a local file preview.

Is there a way to tell Asciidoctor to expand relative paths to absolute paths

Sort of, using the relfileprefix, but you have to set it explicitly. It should cover all the cases of inter-document xrefs, but not sure. See https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/substitutors.rb#L1090

ggrossetie commented 8 years ago

Have this been solved?

No, Mozilla sanitize is too restrictive and I didn't try (yet) Dan's workaround with relfileprefix

What happened with Mozilla's Satanizer? :/

This is evil !

zaxebo1 commented 8 years ago

Wow! Does it mean that - 'this is fixed and working in firefox now' ?

ggrossetie commented 8 years ago

@zaxebo1 Yes, you can manually install the 0.5.0 release: https://github.com/asciidoctor/asciidoctor-firefox-addon/releases/tag/v0.5.0