cirru-color
v0.2.4
Published
cirru highlighting as HTML
Downloads
28
Readme
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