Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

asciidoctor-prism-extension

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asciidoctor-prism-extension

Highlight Asciidoc code listings with Prism.js, server side, with no front-end dependencies.

  • 2.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
222
increased by9.36%
Maintainers
1
Weekly downloads
 
Created
Source

asciidoctor-prism-extension .github/workflows/test.yml

Highlight Asciidoc code listings with Prism.js, server side, with no front-end dependencies.

This module is intended to be used with Asciidoctor.js, and Node.js (v10+). It adds a new syntax highlighter, to be used when converting Asciidoc to HTML5 documents. The syntax highlighting happens during the document conversion.

Example of rendered code listing

Install

$ npm install @asciidoctor/core asciidoctor-prism-extension

Configure

Register the extension

const asciidoctor = require('@asciidoctor/core')();
const prismExtension = require('asciidoctor-prism-extension');

asciidoctor.SyntaxHighlighter.register('prism', prismExtension);

Change the rendering

This extension relies on Asciidoc attributes to affect the theme and the highlighted syntaxes.

= Document
:source-highlighter: prism
:prism-languages: bash,docker,jsx

...
AttributeDefaultPossible values
prism-themeprism.cssAny filename in this list.
prism-languagesasciidoc,bash,json,markdown,typescript,yamlAny supported language.

Theme can be disabled with the negated attribute (! character):

= Document
:source-highlighter: prism
:prism-theme!:
:prism-languages: bash,docker,jsx

...

Render document

Then you convert as usual:

asciidoctor.convertFile('document.adoc', {
  to_file: 'document.html',
  backend: 'html5'
});

Note: attributes can be specified at this stage too. Have a look at Asciidoctor.js API to learn more about it.

Use

Author your documents as you would regularly do. The second argument of a code listing hints the language to the syntax highlighter.

In the following example, yaml is going to be used to colour the output:

[source,yaml]
.example.yml
----
language: node_js
node_js: node

script: npm test
----

About

Prism

Prism is a highly configurable syntax highlighter.

License

MIT.

Keywords

FAQs

Package last updated on 18 Feb 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc