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
//! Closing the syntax a partially streamed document leaves open.
//!
//! A document arriving a few characters at a time is, most of the time, not
//! valid markdown: `**bold` has no closer yet, `[label](htt` is half a link.
//! Parsed as-is it renders as literal asterisks that turn into bold text one
//! delta later — the flicker that makes streaming markdown look broken.
//!
//! With the `stitch` feature this hands the source to
//! [mdstitch](https://docs.rs/mdstitch) before parsing, which closes those
//! markers. Without the feature it is the identity function, so the rest of
//! the module does not need to know which build it got — only
//! [`preprocessing_available`] does.
use Cow;
/// Close any syntax the source leaves open, so a partial document parses as
/// the document it is becoming.
///
/// Returns the input unchanged (as [`Cow::Borrowed`]) when there is nothing to
/// close, and always when built without the `stitch` feature.
/// Close any syntax the source leaves open, so a partial document parses as
/// the document it is becoming.
///
/// Returns the input unchanged (as [`Cow::Borrowed`]) when there is nothing to
/// close, and always when built without the `stitch` feature.
/// Whether this build can close open syntax — true with the `stitch` feature,
/// false without it, where `close_open_syntax` is the identity.
///
/// Worth surfacing in an app that streams: the difference is visible.