Skip to content

ikskuh/zig-gemtext

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gemini Text Processor

This is a library and a tool to manipulate gemini text files.

It provides both an easy-to-use API as well as a streaming parser with minimal allocation requirements and a proper separation between temporary allocations required for parsing and allocations for returned text fragments.

The library is thoroughly tested with a lot of gemini text edge cases and all (tested) cases are handled reasonably.

Features

  • Fully spec-compliant gemini text parsing
  • Non-blocking streaming parser
  • Provides both a convenient Zig and C API
  • Rendering to several formats
    • Gemini text
    • HTML
    • Markdown
    • RTF

Example

This is a simple example that parses a gemini file and converts it into a HTML file.

pub fn main() !void {
    var document = try gemtext.Document.parse(
      std.heap.page_allocator,
      std.io.getStdIn().reader(),
    );
    defer document.deinit();

    try gemtext.renderer.html(
      document.fragments.items, 
      std.io.getStdOut().writer(),
    );
}

More examples can be found the the examples folder:

  • gem2html (C, Zig)
  • gem2md (C, Zig)
  • streaming-parser (C, Zig)