1.0.3 • Published 2 years ago

@incodelang/syntax-highlighting v1.0.3

Weekly downloads
-
License
GPL-3.0-only
Repository
github
Last release
2 years ago

@incodelang/syntax-highlighting

This package allows you to highlight a custom programming language on a website.

Installation

Install @incodelang/syntax-highlighting with npm

  npm install @incodelang/syntax-highlighting

Install @incodelang/syntax-highlighting with yarn

  yarn add @incodelang/syntax-highlighting

Usage/Examples

import highlight from '@incodelang/syntax-highlighting'

highlight(
    document.querySelector("code"),
    [
        {
            name: "fn-call",
            match: /x/,
            style: {
                color: '#FFF'
            }
        },
        {
            name: "fn-call2",
            match: /y/,
            style: {
                color: '#222'
            }
        }
        {
            name: "fn-call3",
            match: /z/,
            style: {
                color: '#333'
            }
        }
    ]
)

Each pattern name will generate a CSS-Class with the exact same name and the corresponding style properties. So you can set custom style properties using

.your-papper-name {
    your-css-prop: your-css-value
}

Example:

.fn-call {
    line-height: 1.6;
}

License

GNU General Public License 3.0 only