Skip to main content

markdown_syntax/
lib.rs

1#![doc = include_str!("../README.md")]
2#![no_std]
3#![deny(missing_docs)]
4
5extern crate alloc;
6
7mod compare;
8mod decode;
9mod entities;
10mod gemoji;
11mod leaves;
12mod memo;
13#[cfg(test)]
14mod test_support;
15mod unicode_letters;
16mod unicode_punctuation;
17
18pub mod ast;
19pub mod diagnostic;
20#[cfg(feature = "html")]
21pub mod html;
22pub mod parse;
23pub mod serialize;
24pub mod span;
25pub mod validate;
26
27pub use ast::*;
28pub use diagnostic::{Diagnostic, DiagnosticCode, DiagnosticSeverity};
29#[cfg(feature = "html")]
30pub use html::{HtmlError, HtmlOptions, SafeRawHtmlForm, TasklistAttrOrder};
31pub use parse::{
32    parse, parse_inline, Definitions, InlineOutput, InlineSource, InlineToken, ParseOutput,
33    TokenRole,
34};
35pub use serialize::{BulletMarker, LineEnding, OrderedDelimiter, SerializeError, SerializeOptions};
36pub use span::{LineIndex, LinePosition, Span};
37
38/// Not part of the public API: the tree comparison that round-trip checks use,
39/// exported so the crate's integration tests compare trees the same way.
40#[doc(hidden)]
41pub mod __private {
42    pub use crate::compare::normalized_blocks;
43    pub use crate::parse::inline_spans_to_source;
44
45    /// How many top-level blocks `to_markdown` writes canonically because,
46    /// written partly from the source, they would read back as something
47    /// else.
48    pub fn rewritten_blocks(document: &crate::Document) -> usize {
49        document
50            .write(&crate::SerializeOptions::default())
51            .map_or(0, |(_, rewritten)| rewritten)
52    }
53}
54
55/// Common imports for working with `markdown-syntax`: `use
56/// markdown_syntax::prelude::*;` brings the AST, diagnostics, the parse
57/// entry points, and serialize/span types (plus the HTML renderer under the
58/// `html` feature) into scope.
59pub mod prelude {
60    pub use crate::ast::*;
61    pub use crate::diagnostic::{Diagnostic, DiagnosticCode, DiagnosticSeverity};
62    #[cfg(feature = "html")]
63    pub use crate::html::{HtmlError, HtmlOptions, SafeRawHtmlForm, TasklistAttrOrder};
64    pub use crate::parse::{
65        parse, parse_inline, Definitions, InlineOutput, InlineSource, InlineToken, ParseOutput,
66        TokenRole,
67    };
68    pub use crate::serialize::{
69        BulletMarker, LineEnding, OrderedDelimiter, SerializeError, SerializeOptions,
70    };
71    pub use crate::span::{LineIndex, LinePosition, Span};
72}