Skip to main content

Crate litedoc_core

Crate litedoc_core 

Source
Expand description

§LiteDoc Core

A deterministic, AI-token-efficient document format parser.

LiteDoc provides an alternative to Markdown with explicit fenced block syntax, making it ideal for AI consumption due to reduced ambiguity and lower token counts.

§Quick Start

use litedoc_core::{Parser, Profile};

let input = "# Hello World\n\nThis is a **paragraph**.";
let mut parser = Parser::new(Profile::Litedoc);
let doc = parser.parse(input).unwrap();

println!("Parsed {} blocks", doc.blocks.len());

§Error Recovery

The parser supports graceful error recovery:

use litedoc_core::{Parser, Profile};

let input = "::unknown\nsome content\n::";
let mut parser = Parser::new(Profile::Litedoc);
let result = parser.parse_with_recovery(input);

// Document is still parsed, errors are collected
println!("Blocks: {}, Errors: {}", result.document.blocks.len(), result.errors.len());

§Profiles

  • Profile::Litedoc - Full native syntax with explicit fencing
  • Profile::Md - CommonMark + GFM subset
  • Profile::MdStrict - CommonMark core only

Re-exports§

pub use ast::Block;
pub use ast::Document;
pub use ast::Inline;
pub use ast::Profile;
pub use error::ParseError;
pub use error::ParseErrorKind;
pub use error::ParseErrors;
pub use parser::ParseResult;
pub use parser::Parser;

Modules§

ast
Abstract Syntax Tree types for LiteDoc documents.
error
inline
Zero-allocation inline parser for LiteDoc
lexer
Line-based lexer with SIMD-accelerated scanning.
parser
Zero-allocation block parser for LiteDoc
span
Source location tracking for AST nodes.