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

@dschulmeis/ls-plugin-highlight.js

v2.0.6

Published

lecture-slides.js plugin: syntax highlighting with highlight.js

Downloads

3

Readme

lecture-slides.js: Syntax Highlighting Plugin

Description

This plugin adds the ability to have source code examples with syntax highlighting to @dschulmeis/lecture-slides.js or @dschulmeis/mini-tutorial.js. Thanks to highlight.js examples can use almost any programming language without much effort.

Screenshot

Installation

  1. Add the plugin to your project: $ npm add --save-dev @dschulmeis/ls-plugin-highlight.js
  2. Import it in the index.js file
  3. Import the needed languages that come with highlight.js
  4. Use the HTML tags below in your presentation

Example for @dschulmeis/lecture-slides.js:

import SlideshowPlayer from "@dschulmeis/lecture-slides.js";

import LS_Plugin_HighlightJS from "@dschulmeis/ls-plugin-highlight.js";
import HLJS_Language_XML from 'highlight.js/lib/languages/xml';
import "highlight.js/styles/atom-one-light.css";

window.addEventListener("load", () => {
    let player = new SlideshowPlayer({
        plugins: {
            HighlightJs: new LS_Plugin_HighlightJS({
                languages: {
                    xml: HLJS_Language_XML,
                },
            }),
        }
    });

    player.start();
});

Example for @dschulmeis/mini-tutorial.js:

import MiniTutorial from "@dschulmeis/mini-tutorial.js";

import LS_Plugin_HighlightJS from "@dschulmeis/ls-plugin-highlight.js";
import HLJS_Language_XML from 'highlight.js/lib/languages/xml';
import "highlight.js/styles/atom-one-light.css";

window.addEventListener("load", () => {
    let mt = new MiniTutorial({
        plugins: [
            new LS_Plugin_HighlightJS({
                languages: {
                    xml: HLJS_Language_XML,
                },
            }),
        ]
    });

    mt.start();
});

The constructor of the plugin takes an optional configuration object with the following properties:

  • languages: Languages to be registered with language.js. Please note, that by default no language is supported, unless it is imported from the highlight.js module and provided here. This is intentional to keep the download size small. Default: {}

  • highlightJs: Configuration value for the configure() method from hightligh.js. Default: {ignoreUnescapedHTML: true}

  • highlightAll: Automatically highlight all <pre><code> blocks found in the HTML document. Default: false

Usage

  • <source-code language="..."> for complete code blocks
  • <src-code language="..."> for inline code snippets

For example like in the screenshot above:

<section data-title="How It Looks Like">
    <article>
        <source-code language="python">
        def main():
            """
            Main procedure of this example program.
            """
            pass

        if __name__ == "__main__":
            main()
        </source-code>

        <p>
            Here you can see, how a python module can check whether it is merely
            imported or run as a program. When run as a program,
            <src-code language="python">__name__ == "__main__"</src-code>
            will be <src-code language="python">true</src-code> and the
            <src-code language="python">main()</src-code>-function will be called.
        </p>
    </article>
    <aside>
        ...
    </aside>
</section>

If the highlightAll option is set, <pre><code> blocks can be used, as is usual for highlight.js:

<pre>
    <code class="python">
        if __name__ == "__main__":
            print("Hello, World!");
    </code>
</pre>

Copyright

lecture-slides.js: https://www.github.com/DennisSchulmeister/lecture-slides.js mini-tutorial.js: https://www.github.com/DennisSchulmeister/mini-tutorial.js ls-plugin-highlight.js: https://github.com/DennisSchulmeister/ls-plugin-highlight.js © 2017 – 2022 Dennis Schulmeister-Zimolong [email protected] Licensed under the 2-Clause BSD License.