Implement the new fields for lesser block.
This commit is contained in:
@@ -80,22 +80,28 @@ where
|
||||
let object_matcher = parser_with_context!(standard_set_object)(&parser_context);
|
||||
let exit_matcher = parser_with_context!(exit_matcher_parser)(&parser_context);
|
||||
// Check for a completely empty block
|
||||
let (remaining, children) = match consumed(many_till(blank_line, exit_matcher))(remaining) {
|
||||
Ok((remaining, (whitespace, (_children, _exit_contents)))) => (
|
||||
remaining,
|
||||
vec![Object::PlainText(PlainText {
|
||||
source: whitespace.into(),
|
||||
})],
|
||||
),
|
||||
Err(_) => {
|
||||
let (remaining, (children, _exit_contents)) =
|
||||
many_till(object_matcher, exit_matcher)(remaining)?;
|
||||
(remaining, children)
|
||||
}
|
||||
};
|
||||
let (remaining, contents, children) =
|
||||
match consumed(many_till(blank_line, exit_matcher))(remaining) {
|
||||
Ok((remaining, (whitespace, (_children, _exit_contents)))) => (
|
||||
remaining,
|
||||
whitespace,
|
||||
if whitespace.len() > 0 {
|
||||
vec![Object::PlainText(PlainText {
|
||||
source: whitespace.into(),
|
||||
})]
|
||||
} else {
|
||||
Vec::new()
|
||||
},
|
||||
),
|
||||
Err(_) => {
|
||||
let (remaining, (contents, (children, _exit_contents))) =
|
||||
consumed(many_till(object_matcher, exit_matcher))(remaining)?;
|
||||
(remaining, contents, children)
|
||||
}
|
||||
};
|
||||
let (remaining, _end) = lesser_block_end_specialized(&parser_context, remaining)?;
|
||||
|
||||
let (remaining, _trailing_ws) =
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
Ok((
|
||||
@@ -108,6 +114,8 @@ where
|
||||
),
|
||||
data: parameters.map(Into::<&str>::into),
|
||||
children,
|
||||
contents: Into::<&str>::into(contents),
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
},
|
||||
))
|
||||
}
|
||||
@@ -144,7 +152,7 @@ where
|
||||
let (remaining, contents) = parser_with_context!(text_until_exit)(&parser_context)(remaining)?;
|
||||
let (remaining, _end) = lesser_block_end_specialized(&parser_context, remaining)?;
|
||||
|
||||
let (remaining, _trailing_ws) =
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
Ok((
|
||||
@@ -156,6 +164,7 @@ where
|
||||
affiliated_keywords,
|
||||
),
|
||||
contents: contents.into(),
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
},
|
||||
))
|
||||
}
|
||||
@@ -205,7 +214,7 @@ where
|
||||
let (remaining, contents) = text_until_exit(&parser_context, remaining)?;
|
||||
let (remaining, _end) = lesser_block_end_specialized(&parser_context, remaining)?;
|
||||
|
||||
let (remaining, _trailing_ws) =
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
let (switches, number_lines, preserve_indent, retain_labels, use_labels, label_format) = {
|
||||
@@ -237,6 +246,7 @@ where
|
||||
use_labels,
|
||||
label_format,
|
||||
value: Into::<&str>::into(contents),
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
},
|
||||
))
|
||||
}
|
||||
@@ -279,7 +289,7 @@ where
|
||||
let (remaining, contents) = text_until_exit(&parser_context, remaining)?;
|
||||
let (remaining, _end) = lesser_block_end_specialized(&parser_context, remaining)?;
|
||||
|
||||
let (remaining, _trailing_ws) =
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
Ok((
|
||||
@@ -293,6 +303,7 @@ where
|
||||
export_type: export_type.map(Into::<&str>::into),
|
||||
data: parameters.map(Into::<&str>::into),
|
||||
value: Into::<&str>::into(contents),
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
},
|
||||
))
|
||||
}
|
||||
@@ -334,7 +345,7 @@ where
|
||||
let (remaining, contents) = text_until_exit(&parser_context, remaining)?;
|
||||
let (remaining, _end) = lesser_block_end_specialized(&parser_context, remaining)?;
|
||||
|
||||
let (remaining, _trailing_ws) =
|
||||
let (remaining, post_blank) =
|
||||
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
let source = get_consumed(input, remaining);
|
||||
let (switches, number_lines, preserve_indent, retain_labels, use_labels, label_format) = {
|
||||
@@ -372,6 +383,7 @@ where
|
||||
use_labels,
|
||||
label_format,
|
||||
value: Into::<&str>::into(contents),
|
||||
post_blank: post_blank.map(Into::<&str>::into),
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user