mirror of
https://github.com/ankitects/anki.git
synced 2026-01-13 22:13:58 -05:00
Limit cloze nesting level (#3264)
* Limit cloze nesting level * Break cloze rendering at a lower limit
This commit is contained in:
parent
9ffd0f511a
commit
c9419313de
1 changed files with 9 additions and 5 deletions
|
|
@ -158,11 +158,15 @@ fn parse_text_with_clozes(text: &str) -> Vec<TextOrCloze<'_>> {
|
|||
let mut output = vec![];
|
||||
for token in tokenize(text) {
|
||||
match token {
|
||||
Token::OpenCloze(ordinal) => open_clozes.push(ExtractedCloze {
|
||||
ordinal,
|
||||
nodes: Vec::with_capacity(1), // common case
|
||||
hint: None,
|
||||
}),
|
||||
Token::OpenCloze(ordinal) => {
|
||||
if open_clozes.len() < 3 {
|
||||
open_clozes.push(ExtractedCloze {
|
||||
ordinal,
|
||||
nodes: Vec::with_capacity(1), // common case
|
||||
hint: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
Token::Text(mut text) => {
|
||||
if let Some(cloze) = open_clozes.last_mut() {
|
||||
// extract hint if found
|
||||
|
|
|
|||
Loading…
Reference in a new issue