Start of making ignored whitespace a top-level template element to handle it in a more generic fashion.

This commit is contained in:
Tom Alexander 2020-05-03 13:43:49 -04:00
parent b8c59f012b
commit 908ae078b0
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 9 additions and 4 deletions

View File

@ -53,6 +53,11 @@ pub enum Special {
RightCurlyBrace,
}
#[derive(Clone, Debug, PartialEq)]
pub enum IgnoredWhitespace<'a> {
StartOfLine(&'a str),
}
#[derive(Clone, Debug, PartialEq)]
pub struct Comment<'a> {
value: &'a str,
@ -141,6 +146,7 @@ pub struct Template<'a> {
pub enum TemplateElement<'a> {
TESpan(Span<'a>),
TETag(DustTag<'a>),
TEIgnoredWhitespace(IgnoredWhitespace<'a>),
}
/// Any element significant to dust that isn't plain text
@ -478,10 +484,9 @@ fn filter(i: &str) -> IResult<&str, Filter> {
)(i)
}
/// Whitespace at the beginning of lines is ignored so inside a span
/// we are matching a newline character followed by as much contiguous
/// whitespace as possible, all of which will be thrown away by other
/// parsers.
/// Whitespace at the beginning of lines is ignored so we are matching
/// a newline character followed by as much contiguous whitespace as
/// possible, all of which will be thrown away by other parsers.
fn span_end_of_line(i: &str) -> IResult<&str, (&str, &str)> {
tuple((line_ending, multispace0))(i)
}