oak-notedown

Crates.iooak-notedown
lib.rsoak-notedown
version0.0.1
created_at2025-10-22 04:31:56.202668+00
updated_at2026-01-23 04:42:35.719749+00
descriptionHigh-performance incremental Markdown parser for the oak ecosystem with flexible configuration, optimized for documentation and content creation.
homepagehttps://github.com/ygg-lang/oaks
repositoryhttps://github.com/ygg-lang/oaks
max_upload_size
id1894941
size104,990
FuckQQ (fqq)

documentation

https://docs.rs/oak-notedown

README

Oak Notedown Parser

Crates.io Documentation

High-performance incremental Notedown parser for the oak ecosystem with flexible configuration, optimized for document processing and rendering.

🎯 Overview

Oak Notedown is a robust parser for Notedown, designed to handle complete Notedown syntax including modern features. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for document processing and rendering.

✨ Features

  • Complete Notedown Syntax: Supports all Notedown features including modern specifications
  • Full AST Generation: Generates comprehensive Abstract Syntax Trees
  • Lexer Support: Built-in tokenization with proper span information
  • Error Recovery: Graceful handling of syntax errors with detailed diagnostics

🚀 Quick Start

Basic example:

use oak_notedown::{NotedownLexer, NotedownLanguage};
use oak_core::{Lexer, Source};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let language = NotedownLanguage::default();
    let lexer = NotedownLexer::new(&language);
    let source = Source::new(r#"
# Hello, Notedown!

This is a **paragraph** with *emphasis*.

## Features

- Lists
- Code blocks
- And more!
    "#);
    
    let result = lexer.tokenize(&source);
    println!("Parsed Notedown successfully.");
    Ok(())
}

📋 Parsing Examples

Document Parsing

use oak_notedown::{NotedownLexer, NotedownLanguage};
use oak_core::{Lexer, Source};

let language = NotedownLanguage::default();
let lexer = NotedownLexer::new(&language);
let source = Source::new(r#"
# My Document

This is a simple document.
"#);

let result = lexer.tokenize(&source);
println!("Document parsed successfully.");

Heading Parsing

use oak_notedown::{NotedownLexer, NotedownLanguage};
use oak_core::{Lexer, Source};

let language = NotedownLanguage::default();
let lexer = NotedownLexer::new(&language);
let source = Source::new(r#"
## My Heading

Some content here.
"#);

let result = lexer.tokenize(&source);
println!("Heading parsed successfully.");

🔧 Advanced Features

Token-Level Parsing

use oak_notedown::{NotedownLexer, NotedownLanguage};
use oak_core::{Lexer, Source};

let language = NotedownLanguage::default();
let lexer = NotedownLexer::new(&language);
let source = Source::new("# Heading\n\nParagraph text");
let result = lexer.tokenize(&source);
println!("Token parsing completed.");

Error Handling

use oak_notedown::{NotedownLexer, NotedownLanguage};
use oak_core::{Lexer, Source};

let language = NotedownLanguage::default();
let lexer = NotedownLexer::new(&language);
let source = Source::new(r#"
# Heading

This is a paragraph
## Another heading
# Unclosed heading
"#);

let result = lexer.tokenize(&source);
if let Some(errors) = result.errors() {
    println!("Parse errors found: {:?}", errors);
} else {
    println!("Parsed successfully.");
}

🏗️ AST Structure

The parser generates a comprehensive AST with the following main structures:

  • Document: Root container for Notedown documents
  • Heading: Heading elements with levels (1-6)
  • Paragraph: Text paragraphs
  • List: Ordered and unordered lists
  • CodeBlock: Fenced code blocks
  • Inline: Emphasis, strong, links, and inline code

📊 Performance

  • Streaming: Parse large Notedown files without loading entirely into memory
  • Incremental: Re-parse only changed sections
  • Memory Efficient: Smart AST node allocation
  • Fast Recovery: Quick error recovery for better IDE integration

🔗 Integration

Oak Notedown integrates seamlessly with:

  • Static Site Generators: Convert Notedown to HTML for websites
  • Documentation Tools: Process and render Notedown documentation
  • Content Management: Handle user-generated Notedown content
  • IDE Support: Language server protocol compatibility
  • Blog Platforms: Parse and render blog posts in Notedown

📚 Examples

Check out the examples directory for comprehensive examples:

  • Complete Notedown document parsing
  • Heading and list analysis
  • Code transformation
  • Integration with development workflows

🤝 Contributing

Contributions are welcome!

Please feel free to submit pull requests at the project repository or open issues.

Commit count: 80

cargo fmt