mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Limit cloze nesting level (#3264)
* Limit cloze nesting level * Break cloze rendering at a lower limit
This commit is contained in:
parent
e985fec9c4
commit
daf5f68fd5
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![];
|
let mut output = vec![];
|
||||||
for token in tokenize(text) {
|
for token in tokenize(text) {
|
||||||
match token {
|
match token {
|
||||||
Token::OpenCloze(ordinal) => open_clozes.push(ExtractedCloze {
|
Token::OpenCloze(ordinal) => {
|
||||||
ordinal,
|
if open_clozes.len() < 3 {
|
||||||
nodes: Vec::with_capacity(1), // common case
|
open_clozes.push(ExtractedCloze {
|
||||||
hint: None,
|
ordinal,
|
||||||
}),
|
nodes: Vec::with_capacity(1), // common case
|
||||||
|
hint: None,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
Token::Text(mut text) => {
|
Token::Text(mut text) => {
|
||||||
if let Some(cloze) = open_clozes.last_mut() {
|
if let Some(cloze) = open_clozes.last_mut() {
|
||||||
// extract hint if found
|
// extract hint if found
|
||||||
|
|
Loading…
Reference in a new issue