npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

asciidoctor-highlight.js

v0.4.0

Published

Asciidoctor.js extension for highlighting code in build time using Highlight.js

Downloads

4,359

Readme

= Asciidoctor Highlight.js :npm-name: asciidoctor-highlight.js :gh-name: jirutka/{npm-name}

ifdef::env-github[] image:https://github.com/{gh-name}/workflows/CI/badge.svg[CI Status, link=https://github.com/{gh-name}/actions?query=workflow%3A%22CI%22] image:https://img.shields.io/npm/v/{npm-name}.svg?style=flat[npm Version, link="https://www.npmjs.org/package/{npm-name}"] endif::env-github[]

This project provides an https://asciidoctor.org/docs/asciidoctor.js[Asciidoctor.js] extension for highlighting source listing blocks using https://highlightjs.org[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 http://asciidoctor.org/docs/user-manual/#callouts[callouts], http://asciidoctor.org/docs/user-manual/#passthroughs[passthroughs] inside a code and all other substitutions, except highlighting of specified lines (attribute highlight).

== Requirements

  • https://nodejs.org/[Node.js] >=8.10 footnote:[Node versions older than 12.0.0 are not tested since 0.4.0.]
  • https://www.npmjs.com/package/@asciidoctor/core[@asciidoctor/core] >=2.0.0 <2.3.0
  • https://www.npmjs.com/package/highlight.js[highlight.js] >=10.7.0 <12.0.0

== Installation

Install {npm-name} from npmjs.com:

[source, sh, subs="+attributes"] npm install --save {npm-name}

== Usage

Assign highlightjs-ext to the source-highlighter attribute in your document’s header or via Asciidoctor.js parameters.

=== Node.js

.Using global extensions registry [source, js, subs="+attributes"]

// Load asciidoctor.js and {npm-name}. const asciidoctor = require('@asciidoctor/core')() const highlightJsExt = require('{npm-name}')

// 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 [source, js, subs="+attributes"]

// Load asciidoctor.js and {npm-name}. const asciidoctor = require('@asciidoctor/core')() const highlightJsExt = require('{npm-name}')

// 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)

=== Attributes

You can further customize the source block output with additional highlight.js attributes:

highlightjs-default-lang:: Controls the default source code language for fallback when the language is not specified in a source block or with attribute 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.

== License

This project is licensed under http://opensource.org/licenses/MIT/[MIT License]. For the full text of the license, see the link:LICENSE[LICENSE] file.