mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
fix: cloze_numbers_in_string treating {{c0::}}
as valid (#3059)
* fix: cloze_numbers_in_string treating `{{c0::}}` as valid * Update rslib/src/cloze.rs Co-authored-by: Abdo <abdo@abdnh.net> --------- Co-authored-by: Abdo <abdo@abdnh.net>
This commit is contained in:
parent
057733d02e
commit
1bd6d2883e
1 changed files with 5 additions and 1 deletions
|
@ -417,7 +417,7 @@ pub fn cloze_numbers_in_string(html: &str) -> HashSet<u16> {
|
|||
fn add_cloze_numbers_in_text_with_clozes(nodes: &[TextOrCloze], set: &mut HashSet<u16>) {
|
||||
for node in nodes {
|
||||
if let TextOrCloze::Cloze(cloze) = node {
|
||||
if !(cloze.image_occlusion().is_some() && cloze.ordinal == 0) {
|
||||
if cloze.ordinal != 0 {
|
||||
set.insert(cloze.ordinal);
|
||||
add_cloze_numbers_in_text_with_clozes(&cloze.nodes, set);
|
||||
}
|
||||
|
@ -471,6 +471,10 @@ mod test {
|
|||
cloze_numbers_in_string("{{c2::te}}{{c1::s}}t{{"),
|
||||
vec![1, 2].into_iter().collect::<HashSet<u16>>()
|
||||
);
|
||||
assert_eq!(
|
||||
cloze_numbers_in_string("{{c0::te}}s{{c2::t}}s"),
|
||||
vec![2].into_iter().collect::<HashSet<u16>>()
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
expand_clozes_to_reveal_latex("{{c1::foo}} {{c2::bar::baz}}"),
|
||||
|
|
Loading…
Reference in a new issue