Compare commits
No commits in common. "5a8159eed73327df95fb16a219d4608fa6070cf3" and "33ca43ca408844ccc495e5f6a027dd3ebdbea446" have entirely different histories.
5a8159eed7
...
33ca43ca40
@ -1,4 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
|||||||
* foo
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
: foo
|
|
||||||
:
|
|
||||||
: bar
|
|
@ -1,6 +0,0 @@
|
|||||||
1. foo
|
|
||||||
#+begin_src text
|
|
||||||
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
2. baz
|
|
@ -1,3 +0,0 @@
|
|||||||
<<FOO>> bar
|
|
||||||
|
|
||||||
[[FOO][baz]]
|
|
@ -1,5 +0,0 @@
|
|||||||
* foo
|
|
||||||
|
|
||||||
** bar
|
|
||||||
|
|
||||||
* baz
|
|
@ -285,7 +285,7 @@ where
|
|||||||
pub(crate) fn compare_children<'b, 's, 'x, RC>(
|
pub(crate) fn compare_children<'b, 's, 'x, RC>(
|
||||||
source: &'s str,
|
source: &'s str,
|
||||||
emacs: &'b Token<'s>,
|
emacs: &'b Token<'s>,
|
||||||
rust_children: &'x [RC],
|
rust_children: &'x Vec<RC>,
|
||||||
child_status: &mut Vec<DiffEntry<'b, 's>>,
|
child_status: &mut Vec<DiffEntry<'b, 's>>,
|
||||||
this_status: &mut DiffStatus,
|
this_status: &mut DiffStatus,
|
||||||
message: &mut Option<String>,
|
message: &mut Option<String>,
|
||||||
|
@ -27,7 +27,7 @@ pub(crate) fn record_event(event_type: EventType, input: OrgSource<'_>) {
|
|||||||
pub fn report(original_document: &str) {
|
pub fn report(original_document: &str) {
|
||||||
let mut db = GLOBAL_DATA.lock().unwrap();
|
let mut db = GLOBAL_DATA.lock().unwrap();
|
||||||
let db = db.get_or_insert_with(HashMap::new);
|
let db = db.get_or_insert_with(HashMap::new);
|
||||||
let mut results: Vec<_> = db.iter().collect();
|
let mut results: Vec<_> = db.iter().map(|(k, v)| (k, v)).collect();
|
||||||
results.sort_by_key(|(_k, v)| *v);
|
results.sort_by_key(|(_k, v)| *v);
|
||||||
// This would put the most common at the top, but that is a pain when there is already a lot of output from the parser.
|
// This would put the most common at the top, but that is a pain when there is already a lot of output from the parser.
|
||||||
// results.sort_by(|(_ak, av), (_bk, bv)| bv.cmp(av));
|
// results.sort_by(|(_ak, av), (_bk, bv)| bv.cmp(av));
|
||||||
|
@ -84,7 +84,7 @@ pub(crate) fn broken_end<'b, 'g, 'r, 's>(
|
|||||||
Paragraph::of_text(
|
Paragraph::of_text(
|
||||||
input.get_until(remaining).into(),
|
input.get_until(remaining).into(),
|
||||||
body,
|
body,
|
||||||
if !body.is_empty() { Some(body) } else { None },
|
if body.len() > 0 { Some(body) } else { None },
|
||||||
post_blank.map(Into::<&str>::into),
|
post_blank.map(Into::<&str>::into),
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
@ -145,7 +145,7 @@ pub(crate) fn broken_dynamic_block<'b, 'g, 'r, 's>(
|
|||||||
Paragraph::of_text(
|
Paragraph::of_text(
|
||||||
input.get_until(remaining).into(),
|
input.get_until(remaining).into(),
|
||||||
body,
|
body,
|
||||||
if !body.is_empty() { Some(body) } else { None },
|
if body.len() > 0 { Some(body) } else { None },
|
||||||
post_blank.map(Into::<&str>::into),
|
post_blank.map(Into::<&str>::into),
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
|
@ -3,7 +3,6 @@ use std::path::Path;
|
|||||||
use nom::combinator::all_consuming;
|
use nom::combinator::all_consuming;
|
||||||
use nom::combinator::opt;
|
use nom::combinator::opt;
|
||||||
use nom::multi::many0;
|
use nom::multi::many0;
|
||||||
use nom::InputTake;
|
|
||||||
|
|
||||||
use super::headline::heading;
|
use super::headline::heading;
|
||||||
use super::in_buffer_settings::apply_in_buffer_settings;
|
use super::in_buffer_settings::apply_in_buffer_settings;
|
||||||
@ -196,9 +195,9 @@ fn _document<'b, 'g, 'r, 's>(
|
|||||||
zeroth_section,
|
zeroth_section,
|
||||||
children,
|
children,
|
||||||
contents: if contents.len() > 0 {
|
contents: if contents.len() > 0 {
|
||||||
Into::<&str>::into(contents)
|
Some(Into::<&str>::into(contents))
|
||||||
} else {
|
} else {
|
||||||
Into::<&str>::into(remaining.take(0))
|
None
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
|
@ -14,7 +14,7 @@ use nom::InputTake;
|
|||||||
|
|
||||||
use super::affiliated_keyword::parse_affiliated_keywords;
|
use super::affiliated_keyword::parse_affiliated_keywords;
|
||||||
use super::org_source::OrgSource;
|
use super::org_source::OrgSource;
|
||||||
use super::util::maybe_consume_trailing_whitespace_if_not_exiting;
|
use super::util::maybe_consume_trailing_whitespace_if_not_exiting_mid_line;
|
||||||
use super::util::org_line_ending;
|
use super::util::org_line_ending;
|
||||||
use crate::context::parser_with_context;
|
use crate::context::parser_with_context;
|
||||||
use crate::context::RefContext;
|
use crate::context::RefContext;
|
||||||
@ -48,11 +48,8 @@ where
|
|||||||
),
|
),
|
||||||
))(remaining)?;
|
))(remaining)?;
|
||||||
|
|
||||||
let post_blank_begin = remaining;
|
let (remaining, post_blank) =
|
||||||
let (remaining, _first_line_break) = org_line_ending(remaining)?;
|
maybe_consume_trailing_whitespace_if_not_exiting_mid_line(context, remaining)?;
|
||||||
let (remaining, _additional_post_blank) =
|
|
||||||
maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?;
|
|
||||||
let post_blank = get_consumed(post_blank_begin, remaining);
|
|
||||||
let source = get_consumed(input, remaining);
|
let source = get_consumed(input, remaining);
|
||||||
let mut value = Vec::with_capacity(remaining_lines.len() + 1);
|
let mut value = Vec::with_capacity(remaining_lines.len() + 1);
|
||||||
value.push(Into::<&str>::into(first_line));
|
value.push(Into::<&str>::into(first_line));
|
||||||
@ -66,11 +63,7 @@ where
|
|||||||
affiliated_keywords,
|
affiliated_keywords,
|
||||||
),
|
),
|
||||||
value,
|
value,
|
||||||
post_blank: if post_blank.len() > 0 {
|
post_blank: post_blank.map(Into::<&str>::into),
|
||||||
Some(Into::<&str>::into(post_blank))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
@ -79,8 +72,8 @@ where
|
|||||||
fn fixed_width_area_line<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
fn fixed_width_area_line<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||||
start_of_line(input)?;
|
start_of_line(input)?;
|
||||||
let (remaining, _) = tuple((space0, tag(":")))(input)?;
|
let (remaining, _) = tuple((space0, tag(":")))(input)?;
|
||||||
if let Ok((_remain, _line_break)) = org_line_ending(remaining) {
|
if let Ok((remain, _line_break)) = org_line_ending(remaining) {
|
||||||
return Ok((remaining, remaining.take(0)));
|
return Ok((remain, remaining.take(0)));
|
||||||
}
|
}
|
||||||
let (remaining, _) = tag(" ")(remaining)?;
|
let (remaining, _) = tag(" ")(remaining)?;
|
||||||
let (remaining, value) = recognize(many_till(anychar, peek(org_line_ending)))(remaining)?;
|
let (remaining, value) = recognize(many_till(anychar, peek(org_line_ending)))(remaining)?;
|
||||||
|
@ -46,7 +46,7 @@ pub(crate) fn target<'b, 'g, 'r, 's>(
|
|||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
let (remaining, _) = tag(">>")(remaining)?;
|
let (remaining, _) = tag(">>")(remaining)?;
|
||||||
let (remaining, post_blank) =
|
let (remaining, _trailing_whitespace) =
|
||||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||||
let source = get_consumed(input, remaining);
|
let source = get_consumed(input, remaining);
|
||||||
|
|
||||||
@ -55,7 +55,6 @@ pub(crate) fn target<'b, 'g, 'r, 's>(
|
|||||||
Target {
|
Target {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
value: body.into(),
|
value: body.into(),
|
||||||
post_blank: post_blank.map(Into::<&str>::into),
|
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,13 @@ fn element_trailing_whitespace<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, O
|
|||||||
alt((eof, recognize(many0(blank_line))))(input)
|
alt((eof, recognize(many0(blank_line))))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
|
fn element_trailing_whitespace_mid_line<'s>(
|
||||||
|
input: OrgSource<'s>,
|
||||||
|
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||||
|
alt((eof, recognize(many0(blank_line))))(input)
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(ret, level = "debug", skip(context))
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
@ -114,6 +121,22 @@ pub(crate) fn maybe_consume_trailing_whitespace_if_not_exiting<'b, 'g, 'r, 's>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(
|
||||||
|
feature = "tracing",
|
||||||
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
|
)]
|
||||||
|
pub(crate) fn maybe_consume_trailing_whitespace_if_not_exiting_mid_line<'b, 'g, 'r, 's>(
|
||||||
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
|
input: OrgSource<'s>,
|
||||||
|
) -> Res<OrgSource<'s>, Option<OrgSource<'s>>> {
|
||||||
|
if context.should_consume_trailing_whitespace() && exit_matcher_parser(context, input).is_err()
|
||||||
|
{
|
||||||
|
Ok(opt(element_trailing_whitespace_mid_line)(input)?)
|
||||||
|
} else {
|
||||||
|
Ok((input, None))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
tracing::instrument(ret, level = "debug", skip(context))
|
tracing::instrument(ret, level = "debug", skip(context))
|
||||||
|
@ -17,7 +17,7 @@ pub struct Document<'s> {
|
|||||||
pub path: Option<PathBuf>,
|
pub path: Option<PathBuf>,
|
||||||
pub zeroth_section: Option<Section<'s>>,
|
pub zeroth_section: Option<Section<'s>>,
|
||||||
pub children: Vec<Heading<'s>>,
|
pub children: Vec<Heading<'s>>,
|
||||||
pub contents: &'s str,
|
pub contents: Option<&'s str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -64,11 +64,14 @@ impl<'s> StandardProperties<'s> for Document<'s> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_contents<'b>(&'b self) -> Option<&'s str> {
|
fn get_contents<'b>(&'b self) -> Option<&'s str> {
|
||||||
Some(self.contents)
|
self.contents
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_post_blank(&self) -> PostBlank {
|
fn get_post_blank(&self) -> PostBlank {
|
||||||
0
|
self.into_iter()
|
||||||
|
.last()
|
||||||
|
.map(|child| child.get_post_blank())
|
||||||
|
.unwrap_or(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,11 +103,16 @@ impl<'s> StandardProperties<'s> for Heading<'s> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_post_blank(&self) -> PostBlank {
|
fn get_post_blank(&self) -> PostBlank {
|
||||||
|
self.children
|
||||||
|
.last()
|
||||||
|
.map(|child| child.get_post_blank())
|
||||||
|
.unwrap_or(
|
||||||
self.post_blank
|
self.post_blank
|
||||||
.map(|text| text.lines().count())
|
.map(|text| text.lines().count())
|
||||||
.unwrap_or(0)
|
.unwrap_or(0)
|
||||||
.try_into()
|
.try_into()
|
||||||
.expect("Too much post-blank to fit into a PostBlank.")
|
.expect("Too much post-blank to fit into a PostBlank."),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +266,6 @@ pub struct LineBreak<'s> {
|
|||||||
pub struct Target<'s> {
|
pub struct Target<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
pub value: &'s str,
|
pub value: &'s str,
|
||||||
pub post_blank: Option<&'s str>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -924,15 +923,11 @@ impl<'s> StandardProperties<'s> for Target<'s> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_contents<'b>(&'b self) -> Option<&'s str> {
|
fn get_contents<'b>(&'b self) -> Option<&'s str> {
|
||||||
None
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_post_blank(&self) -> PostBlank {
|
fn get_post_blank(&self) -> PostBlank {
|
||||||
self.post_blank
|
todo!()
|
||||||
.map(|post_blank| post_blank.chars().count())
|
|
||||||
.unwrap_or(0)
|
|
||||||
.try_into()
|
|
||||||
.expect("Too much post-blank to fit into a PostBlank.")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1014,13 +1009,11 @@ impl<'s> StandardProperties<'s> for PlainText<'s> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_contents<'b>(&'b self) -> Option<&'s str> {
|
fn get_contents<'b>(&'b self) -> Option<&'s str> {
|
||||||
// This field does not actually exist in emacs for plaintext
|
todo!()
|
||||||
Some(self.source)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_post_blank(&self) -> PostBlank {
|
fn get_post_blank(&self) -> PostBlank {
|
||||||
// This field does not actually exist in emacs for plaintext
|
todo!()
|
||||||
0
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user