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

@clarle/metalsmith-prism

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@clarle/metalsmith-prism

Syntax highlighting for Metalsmith HTML templates using Prism.js (with line numbers)

  • 2.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-25%
Maintainers
1
Weekly downloads
 
Created
Source

metalsmith-prism

Syntax highlighting for Metalsmith HTML templates using Prism.js

License NPM Dependency Status Linux Passing Windows Passing

The main difference between this package and Availity/metalsmith-prism is the support for line numbers, without any browser-side JavaScript. It's a bit of a hack, so use at your own risk.

Quickstart

  • Install metalsmith-prism
  npm install @clarle/metalsmith-prism --save-dev
  • Add language definition to code block
<code class="language-css">p { color: red }</code>
  • Add metalsmith-prism plugin to metalsmith
var metalsmith = require('metalsmith');
var metalsmithPrism = require('@clarle/metalsmith-prism');
metalsmith(__dirname)
  .use(metalsmithPrism())
  .build();
var metalsmith = require('metalsmith');
var markdown = require('metalsmith-markdown');
var metalsmithPrism = require('@clarle/metalsmith-prism');
metalsmith(__dirname)
  // Custom langPrefix option needed as markdown uses 'lang-' by default:
  .use(markdown( { langPrefix: 'language-' } ))
  .use(metalsmithPrism())
  .build();

Language support

Supports all programming languages that have a corresponding Prism.js component file. Component files are found in the Prism.js components directory.

JSON

JSON syntax highlighting is enhanced using the following syntax definition

Prism.languages.json = {
  'keys': /".+"(?=:)/g,
  'boolean': /\b(true|false)/g,
  'punctuation': /({|}|:|\[|\]|,)/g,
  'keyword': /\b(null)\b/g
}
<code class="language-json">
{
    ping: "pong"
}
</code>

Options

decode (optional)
  • Always decode the html entities when processing language of type markup
Metalsmith(__dirname)
  .use(metalsmithPrism({
    decode: true
  }))
json (optional)
  • Supply custom JSON syntax definition
Metalsmith(__dirname)
  .use(metalsmithPrism({
    json: {
      'keys': /".+"(?=:)/g,
      'boolean': /\b(true|false)/g,
      'punctuation': /({|}|:|\[|\]|,)/g,
      'keyword': /\b(null)\b/g
    }
  }))
lineNumbers (optional)
  • Appends class line-numbers to parent <pre> tag if present
Metalsmith(__dirname)
  .use(metalsmithPrism({
    lineNumbers: true
  }))

Authors

Robert McGuinness

Disclaimer

Open source software components distributed or made available in the Availity Materials are licensed to Company under the terms of the applicable open source license agreements, which may be found in text files included in the Availity Materials.

Code and documentation copyright 2016 Availity, LLC. Code released under the MIT license.

Keywords

FAQs

Package last updated on 10 Apr 2016

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