Socket
Socket
Sign inDemoInstall

@11ty/eleventy-plugin-syntaxhighlight

Package Overview
Dependencies
757
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @11ty/eleventy-plugin-syntaxhighlight

A pack of Eleventy plugins for syntax highlighting using the Liquid templating engine.


Version published
Weekly downloads
10K
decreased by-26.71%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

eleventy-plugin-syntaxhighlight

A pack of Eleventy plugins for syntax highlighting using the Liquid templating engine. No runtime JavaScript here, these highlight transformations are all done at build-time.

Installation

Available on npm.

npm install @11ty/eleventy-plugin-syntaxhighlight --save

Open up your Eleventy config file (probably .eleventy.js) and use addPlugin:

const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
module.exports = function(eleventyConfig) {
  eleventyConfig.addPlugin(syntaxHighlight);
};

If you use the Prism version, you are responsible for including your favorite theme CSS!

Read more about Eleventy plugins.

Usage

Supplies: Two Liquid Tags

  • {% highlight %}: syntax highlights a block of code using PrismJS.
  • {% highlight-plain %}: adds <pre><code> around a block of code and offers the line-highlighting feature set as highlight.

Prism Syntax Highlighter

{% highlight js %}
function myFunction() {
  return true;
}
{% endhighlight %}
// Line highlighting classes (single highlight)
// Adds `highlight-line-active` class to lines 1,3,5 (for line highlighting)
{% highlight js 1,3-5 %}
function myFunction() {
  // …
  return true;
}
{% endhighlight %}
// Line highlighting classes (add and remove)
// Adds `highlight-line-add` class to lines 1,3
// Adds `highlight-line-remove` class to lines 5,6,7,8
{% highlight js 1,3 5-8 %}
function myFunction() {
  // …
  return true;
}
{% endhighlight %}

Plain Code Block

No syntax highlighting here but you do get the line highlighting features shown in the Prism examples above.

{% highlight-plain js %}
{% highlight-plain js 1,3-5 %}
{% highlight-plain js 1,3 5-8 %}

Keywords

FAQs

Last updated on 05 Apr 2018

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc