1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! Parser for the Mosaic source language (`.mos`).
//!
//! See manifest §3 (language design) and §6 stages 1–2 (parse + lower).
//! Currently covers:
//!
//! - `= Heading` / `== Subheading` / `=== Subsubheading`,
//! - paragraphs (newline-joined non-empty line groups),
//! - inline `*emphasis*`, `**strong**`, and `` `inline code` ``,
//! - `#set name(...)` blocks, recorded with span and name but interpreted
//! later by the evaluator,
//! - `#image(...)` and `#figure(...)` directives, sharing the same
//! `key: value` body grammar as `#set` plus an optional leading
//! positional string literal (`#image("path.png")`),
//! - raw `#pre[[...]]` and `#code[[...]]` long-bracket blocks,
//! - `<label>` attached to the preceding block (trailing on a heading or
//! leading on a paragraph), and `@label` cross-references as inline
//! [`InlineKind::Reference`] runs (manifest §3.3 and the MVP 1
//! resolver).
//!
//! Anything outside that subset is preserved as text and a recoverable
//! diagnostic is emitted; the parser never panics on user input
//! (manifest §31).
use Path;
pub use ;
use Parser;
/// Parse a Mosaic source string. Always returns a [`ParseResult`]; the
/// parser is recoverable per manifest §6 stage 1.
///
/// # Examples
///
/// ```
/// use std::path::Path;
///
/// use mos_parse::{InlineKind, Item, parse};
///
/// let result = parse("= Hello\n", Path::new("main.mos"));
///
/// assert!(!result.has_errors());
/// assert!(matches!(result.tree.items[0], Item::Heading { .. }));
/// let Item::Heading { inlines, .. } = &result.tree.items[0] else {
/// unreachable!();
/// };
/// assert_eq!(inlines[0].kind, InlineKind::Text);
/// ```