mirror of
https://github.com/ankitects/anki.git
synced 2026-01-13 14:03:55 -05:00
add strip_clozes fn
This commit is contained in:
parent
7720c7de1a
commit
f62ac3eb6f
1 changed files with 7 additions and 0 deletions
|
|
@ -25,6 +25,9 @@ use crate::latex::contains_latex;
|
|||
use crate::template::RenderContext;
|
||||
use crate::text::strip_html_preserving_entities;
|
||||
|
||||
static CLOZE: LazyLock<Regex> =
|
||||
LazyLock::new(|| Regex::new(r"(?s)\{\{c\d+::(.*?)(::.*?)?\}\}").unwrap());
|
||||
|
||||
static MATHJAX: LazyLock<Regex> = LazyLock::new(|| {
|
||||
Regex::new(
|
||||
r"(?xsi)
|
||||
|
|
@ -453,6 +456,10 @@ pub fn cloze_number_in_fields(fields: impl IntoIterator<Item: AsRef<str>>) -> Ha
|
|||
set
|
||||
}
|
||||
|
||||
pub(crate) fn strip_clozes(text: &str) -> Cow<'_, str> {
|
||||
CLOZE.replace_all(text, "$1")
|
||||
}
|
||||
|
||||
fn strip_html_inside_mathjax(text: &str) -> Cow<str> {
|
||||
MATHJAX.replace_all(text, |caps: &Captures| -> String {
|
||||
format!(
|
||||
|
|
|
|||
Loading…
Reference in a new issue