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
pub use Url;
pub use ParseError;
pub use CosyParserExtension;
/// Parses an input string into a [`ast::Document`] AST.
///
/// This is the main entry point of the parser. It processes the entire input
/// string and returns a [`ast::Document`] (a thin newtype around
/// `Vec<Block<E::Output>>`).
///
/// The function supports extensibility through the [`CosyParserExtension`] trait,
/// allowing users to define custom syntax for brackets.
///
/// # Arguments
///
/// * `input` - The Cosense/Scrapbox markup string to parse.
/// * `extension` - An implementation of [`CosyParserExtension`]. Use `&()` if
/// no custom extensions are needed. In that case `E::Output` is `()`,
/// producing a `Document<()>`.
///
/// # Errors
///
/// Returns a [`ParseError`] if the input cannot be parsed. In practice the
/// built-in parser is infallible for any UTF-8 input (unknown syntax is
/// treated as plain text), so errors only arise from custom extensions.
///
/// # Examples
///
/// ```rust
/// use cosy;
///
/// let result = cosy::parse("[* Bold text] and [https://example.com Link]", &());
/// assert!(result.is_ok());
/// ```