atom-asciidoc-preview icon indicating copy to clipboard operation
atom-asciidoc-preview copied to clipboard

Don't allow source-highlighter to crash Asciidoctor.js

Open mojavelinux opened this issue 9 years ago • 4 comments

The source-highlighter attribute should be overridden to prevent Asciidoctor.js from crashing. We should probably just set it to highlight.js explicitly, perhaps with an option in the settings page to disable this feature. We don't want the preview to crash if the value is set to pygments in the document, for instance.

mojavelinux avatar May 03 '15 20:05 mojavelinux

I can the default attributes to

default: 'platform=opal platform-opal env=browser env-browser source-highlighter=highlight.js'

It should be enough, right ?

anthonny avatar May 09 '15 23:05 anthonny

For now, I think that's sufficient.

The correct long-term solution is to do what docgist is doing, which is to parse the document header of AsciiDoc and make a smart decision about which source-highlighter value to pass to the processor when running convert. See https://github.com/asciidoctor/docgist/blob/master/js/docgist.js#L40-L64. This way, you have lots of control over the value.

For the short-term, forcing source-highlighter=highlight.js does solve the issue with crashing.

mojavelinux avatar May 09 '15 23:05 mojavelinux

The downside of the long-term solution is that it does slightly slow down rendering because you visit all the lines twice. However, that's something we'll eventually address in core, so it's not something we should program around.

mojavelinux avatar May 09 '15 23:05 mojavelinux

Ok, i have add : source-highlighter=highlight.js

I keep this issue open as long as a better solution is not implemented

anthonny avatar May 10 '15 01:05 anthonny