Start of making ignored whitespace a top-level template element to handle it in a more generic fashion.
This commit is contained in:
parent
b8c59f012b
commit
908ae078b0
@ -53,6 +53,11 @@ pub enum Special {
|
|||||||
RightCurlyBrace,
|
RightCurlyBrace,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
|
pub enum IgnoredWhitespace<'a> {
|
||||||
|
StartOfLine(&'a str),
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub struct Comment<'a> {
|
pub struct Comment<'a> {
|
||||||
value: &'a str,
|
value: &'a str,
|
||||||
@ -141,6 +146,7 @@ pub struct Template<'a> {
|
|||||||
pub enum TemplateElement<'a> {
|
pub enum TemplateElement<'a> {
|
||||||
TESpan(Span<'a>),
|
TESpan(Span<'a>),
|
||||||
TETag(DustTag<'a>),
|
TETag(DustTag<'a>),
|
||||||
|
TEIgnoredWhitespace(IgnoredWhitespace<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Any element significant to dust that isn't plain text
|
/// Any element significant to dust that isn't plain text
|
||||||
@ -478,10 +484,9 @@ fn filter(i: &str) -> IResult<&str, Filter> {
|
|||||||
)(i)
|
)(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whitespace at the beginning of lines is ignored so inside a span
|
/// Whitespace at the beginning of lines is ignored so we are matching
|
||||||
/// we are matching a newline character followed by as much contiguous
|
/// a newline character followed by as much contiguous whitespace as
|
||||||
/// whitespace as possible, all of which will be thrown away by other
|
/// possible, all of which will be thrown away by other parsers.
|
||||||
/// parsers.
|
|
||||||
fn span_end_of_line(i: &str) -> IResult<&str, (&str, &str)> {
|
fn span_end_of_line(i: &str) -> IResult<&str, (&str, &str)> {
|
||||||
tuple((line_ending, multispace0))(i)
|
tuple((line_ending, multispace0))(i)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user