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

Admonitions breaking rendering? #30

Closed lucascosti closed 9 years ago

lucascosti commented 9 years ago

Whenever I include an admonition (e.g. NOTE: blah blah), the preview in Firefox disappears. :(

The same source seems to work ok in the Chrome extension.

ggrossetie commented 9 years ago

Hello @lucascosti do you have any attributes defined on your document ? Is it a remote or a local document ? With version 0.2.3.1-signed and Firefox 38 (Windows), the following document is working:

= Test

NOTE: This is working !
lucascosti commented 9 years ago

Hi @Mogztter , thanks for the reply. It is a local file, and I do have attributes.

If I remove the attributes, it does continue to render the document after I add an admonition.

Also another issue: unlike the Chrome extension, the 'live' aspect doesn't work in Firefox for me. After I save the source file, I have to manually refresh Firefox to see the changes displayed (whereas Chrome automatically refreshes the changes when the focus shifts to the Chrome window).

I am using 0.2.3.1-signed in Firefox 38.0.1 (Fedora 21).

ggrossetie commented 9 years ago

Could you copy and paste your attributes (or your whole document) beacause I couldn't reproduce this issue... thanks

ggrossetie commented 9 years ago

@lucascosti ping :)

lucascosti commented 9 years ago

Sorry, @Mogztter. A good example of a document that works in the Chrome extension, but not the Firefox one is:

https://github.com/openshift/openshift-docs/blob/3aee2b345cacd82cd8a3ca86827516917c793a95/using_images/xpaas_images/eap.adoc

Admonitions are breaking the rendering, and it seems to be the :icons: attribute that my team uses in our docs.

Although the document renders if I remove the attribute, the 'live' functionality still doesn't work. (I can still manually refresh the page, or set up an automatic refresh, which is what I think the Chrome extension does natively).

mojavelinux commented 9 years ago

Aha. The problem is the combination of the icons and the data-uri. You are asking the processor to read icons from disk and embed them into the document, which isn't going to work in the browser preview. You either need to use icons: font or no icons at all. With Asciidoctor, you almost never want to use the icons attribute by itself unless you really intend to use custom icon files.

lucascosti commented 9 years ago

ah, makes sense. Although I am new to writing for the OpenShift docs team, I assume there are custom icons being used for the end-product (that doc is based on their template). The built version of that file is here: https://docs.openshift.com/enterprise/3.0/using_images/xpaas_images/eap.html

The Chrome extension renders the doc (albeit with broken images for the admonitions) :)

mojavelinux commented 9 years ago

Nope, the published file uses font-based icons. More than likely the build script is overriding the icons attribute, so what we're really looking at is that the source document just has the wrong attribute defined. I also don't recommend setting data-uri in the document itself. This should almost always be a decision of the build script.

Long story, short. I think these two attributes should be removed from the document:

:data-uri:
:icons:

and replaced with:

:icons: font

However, to continue on with this issue, I think the extension (both Chrome and Firefox) should forcefully disable data-uri to avoid this type of problem.

lucascosti commented 9 years ago

Cool, thanks Dan. I'll let the OpenShift guys know that they might want to change their templates.

mojavelinux commented 9 years ago

:+1:

ggrossetie commented 9 years ago

@lucascosti On a side note I got the exact same Yoshi figurine !

@mojavelinux How can I disable an data-uri attribute ? SECURE mode can do that but I don't want to force the user's safe mode

mojavelinux commented 9 years ago

I'm pretty sure if we just add data-uri! to the attributes passed into the API, it will do the trick.

stefanct commented 9 years ago

Sorry to hijack this closed report, but this is way too related to post it somewhere else: what if one actually wants to use the data-uri attribute? After all, that attribute is documented to force embedding of images into the html output (which relieves the user from managing the image files himself).

mojavelinux commented 9 years ago

There's no use case (that I can really see) for using data-uri in the preview extension. It's a flag for bundling and publishing in a build. The preview extension is just displaying the document and there's no need to embed the assets as they are available via linking. Besides, it won't work anyway because it can't read the binary files in JavaScript.