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