@@ 168,9 168,9 @@ Now some more text within the code block</code></pre>
### Raw phrases containing equals signs
-Raw phrases, e.g. `==no **textile**==` can contain double equals signs, as long as they are escaped using backslashes. e.g.
+Raw phrases, e.g. `==no **textile**==` can contain double equals signs, as long as they are escaped using a backslash. e.g.
```textile
-==This is two equals signs: \=\= here are two more: \=\===
+==This is two equals signs: \== here are two more: \====
```
will be rendered as
```
@@ 4,7 4,8 @@ use nom::{
character::complete::{char, line_ending, none_of, satisfy},
combinator::{complete, eof, fail, map, map_res, opt, value},
multi::{
- fold_many1, fold_many_m_n, many0, many0_count, many1_count, many_till,
+ fold_many0, fold_many1, fold_many_m_n, many0, many0_count, many1_count,
+ many_till,
},
sequence::{delimited, preceded, terminated, tuple},
IResult,
@@ 764,16 765,33 @@ fn line_break(input: &str) -> IResult<&str, InlineTag> {
pub fn no_textile(input: &str) -> IResult<&str, InlineTag> {
let (rest, content) = delimited(
tag("=="),
- escaped_transform(
- none_of("\\="),
- '\\',
- alt((value("\\", tag("\\")), value("=", tag("=")))),
+ fold_many0(
+ alt((
+ value("\\", tag("\\\\")),
+ value("==", tag("\\==")),
+ no_textile_content,
+ )),
+ String::new,
+ |mut acc, s| {
+ acc.push_str(s);
+ acc
+ },
),
tag("=="),
)(input)?;
Ok((rest, InlineTag::NoTextile(content)))
}
+fn no_textile_content(input: &str) -> IResult<&str, &str> {
+ let res: IResult<&str, &str> = alt((tag("=="), tag("\\")))(input);
+ if let Err(_) = res {
+ if input != "" {
+ return Ok((&input[1..], &input[0..1]));
+ }
+ }
+ fail(input)
+}
+
fn code(input: &str) -> IResult<&str, InlineTag> {
let (rest, content) = delimited(
char('@'),