Fast and safe sillycode parsing and rendering libraries for both Rust and JavaScript/TypeScript.
Each library implementation provides functionality to parse sillycode markup into structured parts and render them as HTML. For more information on sillycode and its syntax, see the sillycode guide.
npm install sillycode
[dependencies]
sillycode = "0.0.5"
import { parse, render } from 'sillycode';
const input = "[b]Hello[/b] [:)]";
const parts = parse(input);
const html = render(parts, false);
console.log(html);
use sillycode::{parse, render};
let input = "[b]Hello[/b] [:)]";
let parts = parse(input);
let html = render(parts, false);
println!("{}", html);
For comprehensive information, including type definitions, for the JS/TS API, visit sillycode.netlify.app.
parse(input: string): Part[] - Parse sillycode markup into structured partsrender(parts: Part[], isEditor?: boolean, emoteSrcPrefix?: string): string - Render parts to HTMLlength(parts: Part[]): number - Calculate display length of partsreverse($root: HTMLElement): string - Extract sillycode markup from DOM elementsdiff($expected: HTMLElement, $actual: HTMLElement): boolean - Efficiently diff and update DOM treesNote that, unlike the JavaScript version, the Rust version doesn't support customizing the emote source prefix. Consider using a simple string replace instead.
parse(input: &str) -> Vec<Part> - Parse sillycode markup into structured partsrender(parts: impl IntoIterator<Item = Part>, is_editor: bool) -> String - Render parts to HTMLlength(parts: &[Part]) -> usize - Calculate display length of partsPart - Enum for all parsed parts (text, style, emote, color, etc.)StyleKind - Enum for style types (bold, italic, underline, etc.)EmoteKind - Enum for emote types (smile, sad, etc.)Color - Type alias for color stringsMade with ❤ by Lua (foxgirl.dev) :3c
This project is licensed under MIT. More info in the LICENSE file.