mirror of
https://github.com/ankitects/anki.git
synced 2026-01-13 14:03:55 -05:00
update imageocclusion.rs
This commit is contained in:
parent
bb363cced6
commit
27182c32e6
1 changed files with 4 additions and 2 deletions
|
|
@ -13,6 +13,7 @@ use nom::character::complete::char;
|
|||
use nom::error::ErrorKind;
|
||||
use nom::sequence::preceded;
|
||||
use nom::sequence::separated_pair;
|
||||
use nom::Parser;
|
||||
|
||||
fn unescape(text: &str) -> String {
|
||||
text.replace("\\:", ":")
|
||||
|
|
@ -22,11 +23,12 @@ pub fn parse_image_cloze(text: &str) -> Option<ImageOcclusionShape> {
|
|||
if let Some((shape, _)) = text.split_once(':') {
|
||||
let mut properties = vec![];
|
||||
let mut remaining = &text[shape.len()..];
|
||||
while let Ok((rem, (name, value))) = separated_pair::<_, _, _, _, (_, ErrorKind), _, _, _>(
|
||||
while let Ok((rem, (name, value))) = separated_pair::<_, _, _, (_, ErrorKind), _, _, _>(
|
||||
preceded(tag(":"), is_not("=")),
|
||||
tag("="),
|
||||
escaped(is_not("\\:"), '\\', char(':')),
|
||||
)(remaining)
|
||||
)
|
||||
.parse(remaining)
|
||||
{
|
||||
remaining = rem;
|
||||
let value = unescape(value);
|
||||
|
|
|
|||
Loading…
Reference in a new issue