Handle zero-width space in text markup.
This commit is contained in:
parent
ad4ef50669
commit
728a79f9a4
@ -1 +1,4 @@
|
|||||||
foo ==>bar=.
|
foo ==>bar=.
|
||||||
|
|
||||||
|
# This uses a zero-width space to escape the equals signs to make the verbatim not end.
|
||||||
|
=lorem == ipsum=
|
||||||
|
@ -231,7 +231,8 @@ fn _text_markup_string<'b, 'g, 'r, 's, 'c>(
|
|||||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||||
let (remaining, _) = pre(context, input)?;
|
let (remaining, _) = pre(context, input)?;
|
||||||
let (remaining, open) = tag(marker_symbol)(remaining)?;
|
let (remaining, open) = tag(marker_symbol)(remaining)?;
|
||||||
let (remaining, _peek_not_whitespace) = peek(not(multispace1))(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());
|
||||||
let parser_context = ContextElement::ExitMatcherNode(ExitMatcherNode {
|
let parser_context = ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||||
class: ExitClass::Gamma,
|
class: ExitClass::Gamma,
|
||||||
|
@ -127,15 +127,14 @@ pub fn start_of_line<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> {
|
|||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn preceded_by_whitespace<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> {
|
pub fn preceded_by_whitespace<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> {
|
||||||
let preceding_character = input.get_preceding_character();
|
let preceding_character = input.get_preceding_character();
|
||||||
match preceding_character {
|
if !preceding_character
|
||||||
Some('\n') | Some('\r') | Some(' ') | Some('\t') => {}
|
.map(|c| c.is_whitespace() || c == '\u{200B}') // 200B = Zero-width space
|
||||||
// If None, we are at the start of the file which is not allowed
|
.unwrap_or(false)
|
||||||
None | Some(_) => {
|
{
|
||||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||||
"Not preceded by whitespace.".into(),
|
"Not preceded by whitespace.".into(),
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
};
|
|
||||||
Ok((input, ()))
|
Ok((input, ()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user