Compare commits
4 Commits
129228c5c5
...
a29973a110
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a29973a110 | ||
![]() |
31c782499e | ||
![]() |
b7c7057095 | ||
![]() |
49e3c90a3a |
4
Makefile
4
Makefile
@ -33,6 +33,10 @@ release:
|
||||
clean:
|
||||
> cargo clean
|
||||
|
||||
.PHONY: format
|
||||
format:
|
||||
> $(MAKE) -C docker/cargo_fmt run
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
> cargo test --no-default-features --features compare --no-fail-fast --lib --test test_loader -- --test-threads $(TESTJOBS)
|
||||
|
1
org_mode_samples/object/text_markup/double_star.org
Normal file
1
org_mode_samples/object/text_markup/double_star.org
Normal file
@ -0,0 +1 @@
|
||||
foo ** bar ** baz
|
1
org_mode_samples/object/text_markup/double_tilde.org
Normal file
1
org_mode_samples/object/text_markup/double_tilde.org
Normal file
@ -0,0 +1 @@
|
||||
foo ~~ bar ~~ baz
|
@ -59,6 +59,10 @@ impl<'s> OrgSource<'s> {
|
||||
self.end - self.start
|
||||
}
|
||||
|
||||
pub(crate) fn get_byte_offset(&self) -> usize {
|
||||
self.start
|
||||
}
|
||||
|
||||
pub(crate) fn get_preceding_character(&self) -> Option<char> {
|
||||
self.preceding_character
|
||||
}
|
||||
|
@ -163,8 +163,7 @@ fn text_markup_object<'c>(
|
||||
OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Vec<Object<'s>>>
|
||||
+ 'c {
|
||||
let marker_symbol = marker_symbol.to_owned();
|
||||
move |context, input: OrgSource<'_>| _text_markup_object(context, input, marker_symbol.as_str())
|
||||
move |context, input: OrgSource<'_>| _text_markup_object(context, input, marker_symbol)
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
@ -183,7 +182,7 @@ fn _text_markup_object<'b, 'g, 'r, 's, 'c>(
|
||||
let (remaining, open) = tag(marker_symbol)(remaining)?;
|
||||
let (remaining, _peek_not_whitespace) =
|
||||
peek(verify(anychar, |c| !c.is_whitespace() && *c != '\u{200B}'))(remaining)?;
|
||||
let text_markup_end_specialized = text_markup_end(open.into());
|
||||
let text_markup_end_specialized = text_markup_end(open.into(), remaining.get_byte_offset());
|
||||
let contexts = [
|
||||
ContextElement::ContextObject(marker_symbol),
|
||||
ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
@ -245,7 +244,7 @@ fn _text_markup_string<'b, 'g, 'r, 's, 'c>(
|
||||
let (remaining, open) = tag(marker_symbol)(remaining)?;
|
||||
let (remaining, _peek_not_whitespace) =
|
||||
peek(verify(anychar, |c| !c.is_whitespace() && *c != '\u{200B}'))(remaining)?;
|
||||
let text_markup_end_specialized = text_markup_end(open.into());
|
||||
let text_markup_end_specialized = text_markup_end(open.into(), remaining.get_byte_offset());
|
||||
let contexts = [
|
||||
ContextElement::ContextObject(marker_symbol),
|
||||
ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
@ -316,8 +315,13 @@ fn post<'b, 'g, 'r, 's>(
|
||||
Ok((remaining, ()))
|
||||
}
|
||||
|
||||
fn text_markup_end<'c>(marker_symbol: &'c str) -> impl ContextMatcher + 'c {
|
||||
move |context, input: OrgSource<'_>| _text_markup_end(context, input, marker_symbol)
|
||||
fn text_markup_end<'c>(
|
||||
marker_symbol: &'c str,
|
||||
contents_start_offset: usize,
|
||||
) -> impl ContextMatcher + 'c {
|
||||
move |context, input: OrgSource<'_>| {
|
||||
_text_markup_end(context, input, marker_symbol, contents_start_offset)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
@ -325,7 +329,13 @@ fn _text_markup_end<'b, 'g, 'r, 's, 'c>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
marker_symbol: &'c str,
|
||||
contents_start_offset: usize,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
if input.get_byte_offset() == contents_start_offset {
|
||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||
"Text markup cannot be empty".into(),
|
||||
))));
|
||||
}
|
||||
not(preceded_by_whitespace(false))(input)?;
|
||||
let (remaining, _marker) = terminated(
|
||||
tag(marker_symbol),
|
||||
@ -425,7 +435,7 @@ fn _rematch_text_markup_object<'b, 'g, 'r, 's, 'x>(
|
||||
let (remaining, _) = pre(context, input)?;
|
||||
let (remaining, open) = tag(marker_symbol)(remaining)?;
|
||||
let (remaining, _peek_not_whitespace) = peek(not(multispace1))(remaining)?;
|
||||
let text_markup_end_specialized = text_markup_end(open.into());
|
||||
let text_markup_end_specialized = text_markup_end(open.into(), remaining.get_byte_offset());
|
||||
let parser_context = ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
class: ExitClass::Gamma,
|
||||
exit_matcher: &text_markup_end_specialized,
|
||||
|
Loading…
x
Reference in New Issue
Block a user