Fixed #7 and #8
ci/woodpecker/push/ociImagePush Pipeline is running Details

This commit is contained in:
Natty 2024-03-13 14:02:34 +01:00
parent b295c66f0c
commit 799730bedc
Signed by: natty
GPG Key ID: BF6CB659ADEE60EC
1 changed files with 81 additions and 18 deletions

View File

@ -1022,6 +1022,19 @@ impl Context {
let FlankingDelim(closing_tag, closing_rule, ..) = closing_tag.into();
move |input| {
if let FlankingRule::Strict = opening_rule {
let (input, pre) = opt(recognize(tuple((
alphanumeric1_unicode,
opt(tag("\\")),
&opening_tag,
peek(not(alt((space1_unicode, eof)))),
))))(input)?;
if let Some(pre_text) = pre {
return Ok((input, Token::PlainText(pre_text.into_fragment().into())));
}
}
if escape {
if let Ok((input_escaped, (_, mark))) = tuple((tag("\\"), &opening_tag))(input) {
return Ok((
@ -1031,14 +1044,6 @@ impl Context {
}
}
if let FlankingRule::Strict = opening_rule {
let (input, pre) =
opt(recognize(tuple((alphanumeric1_unicode, &opening_tag))))(input)?;
if let Some(pre_text) = pre {
return Ok((input, Token::PlainText(pre_text.into_fragment().into())));
}
}
let begin = input;
let (post_open, _) = opening_tag(input)?;
@ -1047,11 +1052,7 @@ impl Context {
&closing_tag,
))(post_open);
if let Err(nom::Err::Error(nom::error::Error {
input: input_past_err,
..
})) = res
{
if let Err(nom::Err::Error(nom::error::Error { .. })) = res {
let res_fallback = tuple((
many1(tuple((not(&closing_tag), &fallback.matcher_inner))),
&closing_tag,
@ -1059,8 +1060,8 @@ impl Context {
if res_fallback.is_err() {
return Ok((
input_past_err,
Token::PlainText(begin.fragment_between(&input_past_err).into()),
post_open,
Token::PlainText(begin.fragment_between(&post_open).into()),
));
}
@ -1727,8 +1728,6 @@ mod test {
#[test]
fn parse_empty() {
let ctx = Context::default();
assert_eq!(parse_full(""), Token::Sequence(vec![]));
}
@ -1833,6 +1832,14 @@ mod test {
Token::PlainText("_ italic *".into())
);
assert_eq!(
parse_full(r#"long text with a *footnote <b>text</b>"#),
Token::Sequence(vec![
Token::PlainText("long text with a *footnote ".into()),
Token::Bold(Box::new(Token::PlainText("text".into())))
])
);
assert_eq!(
parse_full(r#"*"italic"*"#),
Token::Italic(Box::new(Token::PlainText("\"italic\"".into())))
@ -1879,10 +1886,66 @@ mod test {
assert_eq!(
parse_full("~~*hello\nworld*"),
Token::PlainText("~~*hello\nworld*".into())
Token::Sequence(vec![
Token::PlainText("~~".into()),
Token::Italic(Box::new(Token::PlainText("hello\nworld".into())))
])
)
}
#[test]
fn parse_flanking() {
assert_eq!(
parse_full(r#"aaa*iii*bbb"#),
Token::Sequence(vec![
Token::PlainText("aaa".into()),
Token::Italic(Box::new(Token::PlainText("iii".into()))),
Token::PlainText("bbb".into())
])
);
assert_eq!(
parse_full(r#"aaa_nnn_bbb"#),
Token::PlainText("aaa_nnn_bbb".into())
);
assert_eq!(
parse_full(r#"*iii*"#),
Token::Italic(Box::new(Token::PlainText("iii".into())))
);
assert_eq!(
parse_full(r#"_iii_"#),
Token::Italic(Box::new(Token::PlainText("iii".into())))
);
assert_eq!(
parse_full(r#"aaa*iii*"#),
Token::Sequence(vec![
Token::PlainText("aaa".into()),
Token::Italic(Box::new(Token::PlainText("iii".into()))),
])
);
assert_eq!(
parse_full(r#"*iii*bbb"#),
Token::Sequence(vec![
Token::Italic(Box::new(Token::PlainText("iii".into()))),
Token::PlainText("bbb".into()),
])
);
assert_eq!(
parse_full(r#"aaa_nnn_"#),
Token::PlainText("aaa_nnn_".into())
);
assert_eq!(
parse_full(r#"_nnn_bbb"#),
Token::PlainText("_nnn_bbb".into())
);
}
#[test]
fn parse_complex() {
assert_eq!(