brief-core 0.3.0

Compiler library for the Brief markup language: lexer, parser, AST, HTML/LLM emitters, formatter, and Markdown-to-Brief converter.
Documentation

brief-core

The reference compiler for the Brief markup language: lexer, parser, AST, HTML and LLM emitters, formatter, and a Markdown-to-Brief converter — all as a single library crate.

Brief is a writer-first markup format designed to be both human-pleasant and LLM-friendly. The format spec doubles as a quickstart and lives in LearnXinYminutes.brf.

Use it from Rust

use brief::config::Config;
use brief::emit::html;
use brief::lexer::lex;
use brief::parser::parse;
use brief::resolve::resolve;
use brief::shortcode::Registry;
use brief::span::SourceMap;
use brief::validate::{ValidateOpts, validate};

let src = SourceMap::new("hello.brf", "# Hello\nworld\n".to_string());
let tokens = lex(&src).expect("lex");
let (mut doc, mut diags) = parse(tokens, &src);
let registry = Registry::default();
resolve(&mut doc, &registry, &mut diags);
validate(&doc, ValidateOpts::default(), &mut diags);
let rendered = html::render(&doc, &Config::default());
println!("{}", rendered);

Convert Markdown to Brief:

use brief::convert::convert;

let result = convert("# Hello\n\nworld\n", "hello.md");
println!("{}", result.source);

What's in the box

Public modules: ast, config, convert, diag, emit, fmt, inline, lexer, minify, parser, project, resolve, shortcode, span, token, validate, watch.

CLI tooling

The brief CLI, the brief-web static-site generator, and the brief-lsp language server live in sibling crates in the upstream repository. They are not yet published to crates.io.

License

MIT. See the LICENSE file in the upstream repository.