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
//! Configuration options that can be applied to [`Extractor`].
//!
//! [`Extractor`]: crate::Extractor
/// Ways of distinguishing front-matter from the rest of the data in some text.
#[derive(Debug)]
#[non_exhaustive]
pub enum Splitter<'opt> {
/// All lines before this line will be treated as front-matter; everything else (including this line) will be
/// returned as data. If there are less lines than specified here, then everything will be treated as front-matter.
LineIndex(usize),
/// All lines before the first line matching this text (ignoring leading and trailing whitespace differences) will
/// be treated as front-matter; everything else (excluding this line, as it is discarded) will be returned as data.
/// If no line is found matching this text, then everything will be treated as front-matter.
DelimiterLine(&'opt str),
/// All lines prefixed with this text, up to (and not including) the first line that is not prefixed, will be
/// treated as front-matter; everything else will be returned as data. If no lines are found with this prefix, then
/// everything will be treated as data. Note that the prefix will _not_ be stripped automatically; use
/// [`Modifier::StripPrefix`] to explicitly strip the prefix.
LinePrefix(&'opt str),
}
/// Modifiers that can be applied to extracted front-matter. Note that these will implicitly normalise newlines to just
/// `\n` (LF).
#[derive(Debug)]
#[non_exhaustive]
pub enum Modifier<'opt> {
/// Strips the given prefix from the start of all front-matter lines.
StripPrefix(&'opt str),
/// Strip leading and trailing whitespace from all front-matter lines.
TrimWhitespace,
/// Strip the first line from the front-matter returned.
StripFirstLine,
/// Strip the last line from the front-matter returned.
StripLastLine,
}