cirru-color

0.2.4 • Public • Published

Cirru Color

Syntax highlighting tool inspired by Pygements

Demo http://repo.cirru.org/cirru-color/

It's mainly based on my PR on pygments for adding Cirru highlighting.

Usage

npm install cirru-color

Highlight code:

import {generateHtml} from 'cirru-color'
html = generateHtml 'cirru code'

Styles in /assets/cirru.css.

Or just parsing:

import {parse} from 'cirru-color'
tokens = parse 'cirru code'

valid types here are:

whitespace
func
para
punc
dollar
string
string-text
escape
escape-text

for code:

print $ unwrap $

it returns:

[
  [
    {
      "type": "func",
      "text": "print"
    },
    {
      "type": "whitespace",
      "text": " "
    },
    {
      "type": "dollar",
      "text": "$"
    },
    {
      "type": "whitespace",
      "text": " "
    },
    {
      "type": "func",
      "text": "unwrap"
    },
    {
      "type": "whitespace",
      "text": " "
    },
    {
      "type": "dollar",
      "text": "$"
    }
  ]
]

License

MIT

/cirru-color/

    Package Sidebar

    Install

    npm i cirru-color

    Weekly Downloads

    7

    Version

    0.2.4

    License

    MIT

    Unpacked Size

    19.5 kB

    Total Files

    14

    Last publish

    Collaborators

    • jiyinyiyong