Compare commits

..

No commits in common. "969054590117200b1de4ceb13ec3df1865f9b26c" and "565978225a57d0dcd11aaafc3d74abf403a1bffa" have entirely different histories.

4 changed files with 18 additions and 31 deletions

View File

@ -63,7 +63,6 @@ pub(crate) fn broken_end<'b, 'g, 'r, 's>(
match paragraph.children.first_mut() { match paragraph.children.first_mut() {
Some(Object::PlainText(plain_text)) => { Some(Object::PlainText(plain_text)) => {
plain_text.source = input.get_until_end_of_str(plain_text.source).into(); 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) => { Some(obj) => {
panic!("Unhandled first object type inside bullshitium {:?}", obj); panic!("Unhandled first object type inside bullshitium {:?}", obj);

View File

@ -6,20 +6,20 @@ use nom::character::complete::anychar;
use nom::character::complete::line_ending; use nom::character::complete::line_ending;
use nom::character::complete::space0; use nom::character::complete::space0;
use nom::character::complete::space1; use nom::character::complete::space1;
use nom::combinator::consumed;
use nom::combinator::eof; use nom::combinator::eof;
use nom::combinator::not; use nom::combinator::not;
use nom::combinator::opt; use nom::combinator::opt;
use nom::combinator::peek; use nom::combinator::peek;
use nom::combinator::recognize; use nom::combinator::recognize;
use nom::multi::many0;
use nom::multi::many_till; use nom::multi::many_till;
use nom::sequence::preceded;
use nom::sequence::tuple; use nom::sequence::tuple;
use super::affiliated_keyword::parse_affiliated_keywords; use super::affiliated_keyword::parse_affiliated_keywords;
use super::greater_block::leading_blank_lines_end;
use super::org_source::OrgSource; use super::org_source::OrgSource;
use super::paragraph::empty_paragraph;
use super::util::maybe_consume_trailing_whitespace_if_not_exiting; use super::util::maybe_consume_trailing_whitespace_if_not_exiting;
use crate::context::bind_context;
use crate::context::parser_with_context; use crate::context::parser_with_context;
use crate::context::ContextElement; use crate::context::ContextElement;
use crate::context::ExitClass; use crate::context::ExitClass;
@ -28,6 +28,7 @@ use crate::context::RefContext;
use crate::error::CustomError; use crate::error::CustomError;
use crate::error::Res; use crate::error::Res;
use crate::parser::element_parser::element; use crate::parser::element_parser::element;
use crate::parser::util::blank_line;
use crate::parser::util::exit_matcher_parser; use crate::parser::util::exit_matcher_parser;
use crate::parser::util::get_consumed; use crate::parser::util::get_consumed;
use crate::parser::util::immediate_in_section; use crate::parser::util::immediate_in_section;
@ -35,6 +36,7 @@ use crate::parser::util::start_of_line;
use crate::types::DynamicBlock; use crate::types::DynamicBlock;
use crate::types::Element; use crate::types::Element;
use crate::types::Keyword; use crate::types::Keyword;
use crate::types::Paragraph;
#[cfg_attr( #[cfg_attr(
feature = "tracing", feature = "tracing",
@ -79,25 +81,23 @@ where
let element_matcher = parser_with_context!(element(true))(&parser_context); let element_matcher = parser_with_context!(element(true))(&parser_context);
let exit_matcher = parser_with_context!(exit_matcher_parser)(&parser_context); let exit_matcher = parser_with_context!(exit_matcher_parser)(&parser_context);
not(exit_matcher)(remaining)?; not(exit_matcher)(remaining)?;
let contents_begin = remaining; let (remaining, leading_blank_lines) = opt(consumed(tuple((
let blank_line_context = ContextElement::ExitMatcherNode(ExitMatcherNode { blank_line,
class: ExitClass::Alpha, many0(preceded(not(exit_matcher), blank_line)),
exit_matcher: &leading_blank_lines_end, ))))(remaining)?;
}); let leading_blank_lines =
let blank_line_context = parser_context.with_additional_node(&blank_line_context); leading_blank_lines.map(|(source, (first_line, _remaining_lines))| {
Element::Paragraph(Paragraph::of_text(source.into(), first_line.into()))
let (remaining, leading_blank_lines) = });
opt(bind_context!(empty_paragraph, &blank_line_context))(remaining)?;
let (remaining, (mut children, _exit_contents)) = let (remaining, (mut children, _exit_contents)) =
many_till(element_matcher, exit_matcher)(remaining)?; many_till(element_matcher, exit_matcher)(remaining)?;
if let Some(lines) = leading_blank_lines { if let Some(lines) = leading_blank_lines {
children.insert(0, Element::Paragraph(lines)); children.insert(0, lines);
} }
let contents = get_consumed(contents_begin, remaining);
let (remaining, _end) = dynamic_block_end(&parser_context, remaining)?; let (remaining, _end) = dynamic_block_end(&parser_context, remaining)?;
let (remaining, post_blank) = let (remaining, _trailing_ws) =
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?; maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
let source = get_consumed(input, remaining); let source = get_consumed(input, remaining);
Ok(( Ok((
@ -111,12 +111,6 @@ where
block_name: name.into(), block_name: name.into(),
parameters: parameters.map(|val| val.into()), parameters: parameters.map(|val| val.into()),
children, children,
contents: if contents.len() > 0 {
Some(Into::<&str>::into(contents))
} else {
None
},
post_blank: post_blank.map(Into::<&str>::into),
}, },
)) ))
} }

View File

@ -339,7 +339,7 @@ fn _greater_block_end<'b, 'g, 'r, 's, 'c>(
feature = "tracing", feature = "tracing",
tracing::instrument(ret, level = "debug", skip(_context)) tracing::instrument(ret, level = "debug", skip(_context))
)] )]
pub(crate) fn leading_blank_lines_end<'b, 'g, 'r, 's, 'c>( fn leading_blank_lines_end<'b, 'g, 'r, 's, 'c>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, OrgSource<'s>> { ) -> Res<OrgSource<'s>, OrgSource<'s>> {

View File

@ -87,8 +87,6 @@ pub struct DynamicBlock<'s> {
pub block_name: &'s str, pub block_name: &'s str,
pub parameters: Option<&'s str>, pub parameters: Option<&'s str>,
pub children: Vec<Element<'s>>, pub children: Vec<Element<'s>>,
pub contents: Option<&'s str>,
pub post_blank: Option<&'s str>,
} }
#[derive(Debug)] #[derive(Debug)]
@ -245,15 +243,11 @@ impl<'s> StandardProperties<'s> for DynamicBlock<'s> {
} }
fn get_contents<'b>(&'b self) -> Option<&'s str> { fn get_contents<'b>(&'b self) -> Option<&'s str> {
self.contents todo!()
} }
fn get_post_blank(&self) -> PostBlank { fn get_post_blank(&self) -> PostBlank {
self.post_blank todo!()
.map(|text| text.lines().count())
.unwrap_or(0)
.try_into()
.expect("Too much post-blank to fit into a PostBlank.")
} }
} }