carta-readers 0.0.1

Input-format readers: parse a source format's text into the document model.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
//! Small inline-sequence helpers shared by the line-oriented text readers.

use carta_ast::Inline;

/// Drop leading and trailing whitespace inlines (spaces and soft breaks) from an inline sequence.
pub(crate) fn trim_inline_ends(inlines: &mut Vec<Inline>) {
    while matches!(inlines.first(), Some(Inline::Space | Inline::SoftBreak)) {
        inlines.remove(0);
    }
    while matches!(inlines.last(), Some(Inline::Space | Inline::SoftBreak)) {
        inlines.pop();
    }
}