prism-js 0.1.2

rust bindings for prism.js syntax highlighting library
Documentation
  • Coverage
  • 50%
    3 out of 6 items documented2 out of 3 items with examples
  • Size
  • Source code size: 587.44 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 291.34 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2m 54s Average build duration of successful builds.
  • all releases: 2m 54s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • FraserLee/prism-rs
    1 1 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • FraserLee

prism-rs

Rust bindings for Prism syntax highlighting.

Usage

[dependencies]
prism-js = "0.1"
use prism_js::{init, highlight}

let mut context = init();

let lang = "haskell";
let code = r#"
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
main = print $ take 100 fibs
"#;

let html = highlight(&mut context, code, lang);
println!("{}", html.unwrap());

which outputs:

<span class="token hvariable">fibs</span> <span class="token operator">=</span>
<span class="token number">0</span> <span class="token operator">:</span> <span
class="token number">1</span> <span class="token operator">:</span> <span
class="token builtin">zipWith</span> <span class="token
punctuation">(</span><span class="token operator">+</span><span class="token
punctuation">)</span> <span class="token hvariable">fibs</span> <span
class="token punctuation">(</span><span class="token builtin">tail</span> <span
class="token hvariable">fibs</span><span class="token punctuation">)</span>
<span class="token hvariable">main</span> <span class="token operator">=</span>
<span class="token builtin">print</span> <span class="token operator">$</span>
<span class="token builtin">take</span> <span class="token number">100</span>
<span class="token hvariable">fibs</span>