Pukram formatting
[
](LICENSE-MIT OR LICENSE-APACHE)
A Rust library for combining text formatting styles using bitwise operations. Designed for the pukram markup language.
Features
- Several supported formattings:
*bold*/italic/`monospace`^superscript^|subscript|_underscore_~strikethrough~
- Bitwise operator support (
|,&,^, etc.) - Toggle formats with marker characters
Usage
Basic Formatting
use Formatting;
// Combine formats with bitwise OR
let bold_underscore = BOLD | UNDERSCORE;
let small = TOP | BOTTOM;
Format Checking
let mut fmt = BOLD | ITALIC;
assert!;
assert!;
assert!;
// Remove bold formatting
fmt ^= BOLD;
assert!;
Character-Activated Formatting
let mut fmt = default;
// Toggle formats using marker characters
fmt.apply; // Toggle bold
fmt.apply; // Toggle italic
fmt.apply; // Toggle monospace
// Invalid characters are ignored
assert!; // Returns false
When parsing a text to add formatting, you would usually use this.
Combined Formatting
// Create complex combinations
let warning = BOLD | UNDERSCORE | STRIKETHROUGH;
// Mix with bitwise operations
let modified_warning = warning ^ ;
Documentation
Full API reference available at docs.rs/pukram-formatting.