Compare commits
No commits in common. "33ca43ca408844ccc495e5f6a027dd3ebdbea446" and "969054590117200b1de4ceb13ec3df1865f9b26c" have entirely different histories.
33ca43ca40
...
9690545901
@ -81,7 +81,7 @@ pub(crate) fn broken_end<'b, 'g, 'r, 's>(
|
||||
|
||||
Ok((
|
||||
remaining,
|
||||
Paragraph::of_text(
|
||||
Paragraph::of_text_full(
|
||||
input.get_until(remaining).into(),
|
||||
body,
|
||||
if body.len() > 0 { Some(body) } else { None },
|
||||
@ -124,7 +124,6 @@ pub(crate) fn broken_dynamic_block<'b, 'g, 'r, 's>(
|
||||
match paragraph.children.first_mut() {
|
||||
Some(Object::PlainText(plain_text)) => {
|
||||
plain_text.source = input.get_until_end_of_str(plain_text.source).into();
|
||||
paragraph.contents = Some(input.get_until_end_of_str(plain_text.source).into());
|
||||
}
|
||||
Some(obj) => {
|
||||
panic!("Unhandled first object type inside bullshitium {:?}", obj);
|
||||
@ -135,18 +134,14 @@ pub(crate) fn broken_dynamic_block<'b, 'g, 'r, 's>(
|
||||
};
|
||||
Ok((remaining, paragraph))
|
||||
} else {
|
||||
let (remaining, post_blank) =
|
||||
let (remaining, _trailing_ws) =
|
||||
maybe_consume_trailing_whitespace_if_not_exiting(context, lead_in_remaining)?;
|
||||
|
||||
let body = Into::<&str>::into(input.get_until(lead_in_remaining));
|
||||
|
||||
Ok((
|
||||
remaining,
|
||||
Paragraph::of_text(
|
||||
input.get_until(remaining).into(),
|
||||
body,
|
||||
if body.len() > 0 { Some(body) } else { None },
|
||||
post_blank.map(Into::<&str>::into),
|
||||
input.get_until(lead_in_remaining).into(),
|
||||
),
|
||||
))
|
||||
}
|
||||
|
@ -67,7 +67,6 @@ fn _heading<'b, 'g, 'r, 's>(
|
||||
let section_matcher = bind_context!(section, context);
|
||||
let heading_matcher = bind_context!(heading(pre_headline.star_count), context);
|
||||
let (contents_begin, _) = opt(many0(blank_line))(remaining)?;
|
||||
let maybe_post_blank = get_consumed(remaining, contents_begin);
|
||||
let (remaining, maybe_section) =
|
||||
opt(map(section_matcher, DocumentElement::Section))(remaining)?;
|
||||
let (remaining, _ws) = opt(tuple((start_of_line, many0(blank_line))))(remaining)?;
|
||||
@ -84,8 +83,7 @@ fn _heading<'b, 'g, 'r, 's>(
|
||||
}
|
||||
children.insert(0, section);
|
||||
}
|
||||
let has_children = !children.is_empty();
|
||||
let remaining = if !has_children {
|
||||
let remaining = if children.is_empty() {
|
||||
// Support empty headings
|
||||
let (remain, _ws) = many0(blank_line)(remaining)?;
|
||||
remain
|
||||
@ -121,11 +119,6 @@ fn _heading<'b, 'g, 'r, 's>(
|
||||
} else {
|
||||
None
|
||||
},
|
||||
post_blank: if has_children {
|
||||
None
|
||||
} else {
|
||||
Some(Into::<&str>::into(maybe_post_blank))
|
||||
},
|
||||
},
|
||||
))
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ pub(crate) fn empty_paragraph<'b, 'g, 'r, 's>(
|
||||
let source = get_consumed(input, remaining);
|
||||
Ok((
|
||||
remaining,
|
||||
Paragraph::of_text(
|
||||
Paragraph::of_text_full(
|
||||
Into::<&str>::into(source),
|
||||
Into::<&str>::into(first_line_with_spaces),
|
||||
Some(Into::<&str>::into(first_line_with_spaces)),
|
||||
@ -116,7 +116,7 @@ pub(crate) fn empty_paragraph<'b, 'g, 'r, 's>(
|
||||
let source = get_consumed(input, remaining);
|
||||
Ok((
|
||||
remaining,
|
||||
Paragraph::of_text(
|
||||
Paragraph::of_text_full(
|
||||
Into::<&str>::into(source),
|
||||
Into::<&str>::into(first_line),
|
||||
Some(Into::<&str>::into(first_line)),
|
||||
|
@ -36,7 +36,6 @@ pub struct Heading<'s> {
|
||||
pub deadline: Option<Timestamp<'s>>,
|
||||
pub closed: Option<Timestamp<'s>>,
|
||||
pub contents: Option<&'s str>,
|
||||
pub post_blank: Option<&'s str>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -106,13 +105,7 @@ impl<'s> StandardProperties<'s> for Heading<'s> {
|
||||
self.children
|
||||
.last()
|
||||
.map(|child| child.get_post_blank())
|
||||
.unwrap_or(
|
||||
self.post_blank
|
||||
.map(|text| text.lines().count())
|
||||
.unwrap_or(0)
|
||||
.try_into()
|
||||
.expect("Too much post-blank to fit into a PostBlank."),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,21 @@ impl<'s> Paragraph<'s> {
|
||||
/// Generate a paragraph of the passed in text with no additional properties.
|
||||
///
|
||||
/// This is used for elements that support an "empty" content like greater blocks.
|
||||
pub(crate) fn of_text(
|
||||
pub(crate) fn of_text(source: &'s str, body: &'s str) -> Self {
|
||||
// TODO: This should be replaced with of_text_full.
|
||||
Paragraph {
|
||||
source,
|
||||
contents: None,
|
||||
post_blank: None,
|
||||
affiliated_keywords: AffiliatedKeywords::default(),
|
||||
children: vec![Object::PlainText(PlainText { source: body })],
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate a paragraph of the passed in text with no additional properties.
|
||||
///
|
||||
/// This is used for elements that support an "empty" content like greater blocks.
|
||||
pub(crate) fn of_text_full(
|
||||
source: &'s str,
|
||||
body: &'s str,
|
||||
contents: Option<&'s str>,
|
||||
|
Loading…
x
Reference in New Issue
Block a user