Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
asciidoctor-highlight.js
Advanced tools
Asciidoctor.js extension for highlighting code in build time using Highlight.js
This project provides an Asciidoctor.js extension for highlighting source listing blocks using highlight.js right during document conversion (instead of in browser on client-side as the built-in highlight.js support).
It supports all Asciidoctor features such as
callouts,
passthroughs
inside a code and all other substitutions, except highlighting of
specified lines (attribute highlight
).
Node.js >=8.10 [1]
@asciidoctor/core >=2.0.0 <2.3.0
highlight.js >=10.7.0 <12.0.0
Install asciidoctor-highlight.js from npmjs.com:
npm install --save asciidoctor-highlight.js
Assign highlightjs-ext
to the source-highlighter
attribute in your
document’s header or via Asciidoctor.js parameters.
Using global extensions registry.
// Load asciidoctor.js and asciidoctor-highlight.js.
const asciidoctor = require('@asciidoctor/core')()
const highlightJsExt = require('asciidoctor-highlight.js')
// Register the extension into global registry.
highlightJsExt.register(asciidoctor.Extensions)
// Convert the content to HTML.
const content = `
[source, js]
console.log('Hello, world!')
`
const html = asciidoctor.convert(content, {
attributes: { 'source-highlighter': 'highlightjs-ext' },
})
console.log(html)
Using custom extensions registry.
// Load asciidoctor.js and asciidoctor-highlight.js.
const asciidoctor = require('@asciidoctor/core')()
const highlightJsExt = require('asciidoctor-highlight.js')
// Register the extension into custom registry.
const registry = asciidoctor.Extensions.create()
highlightJsExt.register(registry)
// Convert the content to HTML.
const content = `
[source, js]
console.log('Hello, world!')
`
const html = asciidoctor.convert(content, {
'extension_registry': registry,
attributes: { 'source-highlighter': 'highlightjs-ext' },
})
console.log(html)
You can further customize the source block output with additional highlight.js attributes:
source-language
. It can be any language name or alias supported by
highlight.js, none
to skip highlighting, or auto
to use
highlight.js’s auto-detection. The default is none
.This project is licensed under MIT License. For the full text of the license, see the LICENSE file.
FAQs
Asciidoctor.js extension for highlighting code in build time using Highlight.js
The npm package asciidoctor-highlight.js receives a total of 776 weekly downloads. As such, asciidoctor-highlight.js popularity was classified as not popular.
We found that asciidoctor-highlight.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.