-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
How to override listing/source block default syntax highlighting via highlightjs 11 #606
Comments
This "feature" has been removed from Highlight.js 11: |
In my opinion, you should create a custom syntax highlighter for Highlight.js or use/create a new syntax highlighter adapter for Prism: https://docs.asciidoctor.org/asciidoctor/latest/syntax-highlighting/custom/#new which seems to support this feature: https://prismjs.com/plugins/keep-markup/ |
Thank you for the suggestion. I am trying to understand the source code enough to get things going. If you don't mind, I have a question regarding the file //asciidocParser.js
class AsciidocParser {
constructor(extensionUri, apsArbiter = null, errorCollection = null) {
this.errorCollection = errorCollection;
this.apsArbiter = apsArbiter;
/*...*/
}
} I am not sure what this is for. And further down in the file, there is this function: confirmAsciidoctorExtensionsTrusted() {
return __awaiter(this, void 0, void 0, function* () {
/*...*/
return this.apsArbiter.confirmAsciidoctorExtensionsTrustMode(extensionsCount);
}); I am confused as to how the |
asciidoctor-vscode/src/asciidocEngine.ts Line 28 in e6035b2
|
Are we able use a syntax highlight adapter within the I see there is a npm package called asciidoctor-prism-extension. I installed that within the I then tried to register it the same way I registered the module.exports = require('asciidoctor-emoji'); However, this same method didn't work for enabling the Is there anything I can change the |
Yes it's possible but you will need to hook on the /* global Opal */
const PrismExtension = require('asciidoctor-prism-extension')
// fixme: add additional Prism languages...
Prism.languages.python = /* ... */
// fixme: add KeepMarkup plugin
Prism.plugins.KeepMarkup = /* ... */
module.exports.register = function register (_) {
Opal.Asciidoctor.SyntaxHighlighter.register('prism', PrismExtension)
} Don't forget to include a Prism theme in your custom stylesheet and set the
|
Description
Previously in version 2.9.8, I was able to "override" syntax highlighting within source blocks by using text spans and built-in roles. For example, when I wrote this in my asciidoc:
this would be the resulting output in 2.9.8 (the bottom block in the picture uses aforementioned asciidoc source code):

However, now I am using version 3.0.1 and this doesn't occur anymore. In fact, when inspecting the text in the rendered preview using developer tools, it appears that the text-spans are just swallowed up:
3.0.1 rendering of syntax highlighting

(when inspecting the elements of the second block):

I know previously in 2.9.8 I had
asciidoc.use_asciidoctor_js: false
in my JSON config, and now it is completely irrelevant (i.e. you must use asciidoctor_js), so I believe it might be a limitation of asciidoctor_js.Is there actually a way to get the desired behavior with this newer version, or is it a limitation?
System Information
Version: 1.69.1 (Universal)
Commit: b06ae3b2d2dbfe28bca3134cc6be65935cdfea6a
Date: 2022-07-12T08:21:51.333Z
Electron: 18.3.5
Chromium: 100.0.4896.160
Node.js: 16.13.2
V8: 10.0.139.17-electron.0
OS: Darwin arm64 21.4.0
To Reproduce
Steps to reproduce the issue:
testing_file.adoc
inside the workspace.The text was updated successfully, but these errors were encountered: