no sync needed
This commit is contained in:
parent
13d7b54c27
commit
7f3434b7c1
1 changed files with 8 additions and 12 deletions
|
@ -10,8 +10,6 @@ use serde::{Deserialize, Deserializer};
|
|||
use std::fmt::Debug;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Metadata for blog posts
|
||||
#[derive(Content, Debug, Default, Deserialize)]
|
||||
|
@ -413,12 +411,12 @@ fn check_code<'a>(root: &'a AstNode<'a>, blacklist: &[String]) -> bool {
|
|||
|
||||
/// Check if html contains maths
|
||||
fn check_math(html: &str) -> bool {
|
||||
let math_detected = Arc::new(AtomicBool::new(false));
|
||||
let mut math_detected = false;
|
||||
|
||||
let _ = HtmlRewriter::new(
|
||||
Settings {
|
||||
element_content_handlers: vec![element!("span[data-math-style]", |_| {
|
||||
math_detected.store(true, Ordering::SeqCst);
|
||||
math_detected = true;
|
||||
|
||||
Ok(())
|
||||
})],
|
||||
|
@ -428,7 +426,7 @@ fn check_math(html: &str) -> bool {
|
|||
)
|
||||
.write(html.as_bytes());
|
||||
|
||||
math_detected.load(Ordering::SeqCst)
|
||||
math_detected
|
||||
}
|
||||
|
||||
/// Change class of languages for hljs detection
|
||||
|
@ -444,7 +442,7 @@ fn hljs_replace<'a>(root: &'a AstNode<'a>, mermaid_str: &str) {
|
|||
|
||||
/// Obfuscate email if email found
|
||||
fn mail_obfuscation(html: &str) -> (String, bool) {
|
||||
let modified = Arc::new(AtomicBool::new(false));
|
||||
let mut modified = false;
|
||||
|
||||
let data_attr = "title";
|
||||
|
||||
|
@ -453,7 +451,7 @@ fn mail_obfuscation(html: &str) -> (String, bool) {
|
|||
html,
|
||||
RewriteStrSettings {
|
||||
element_content_handlers: vec![element!("a[href^='mailto:']", |el| {
|
||||
modified.store(true, Ordering::SeqCst);
|
||||
modified = true;
|
||||
|
||||
// Get mail address
|
||||
let link = el.get_attribute("href").unwrap();
|
||||
|
@ -473,9 +471,7 @@ fn mail_obfuscation(html: &str) -> (String, bool) {
|
|||
)
|
||||
.unwrap();
|
||||
|
||||
let is_modified = modified.load(Ordering::SeqCst);
|
||||
|
||||
if is_modified {
|
||||
if modified {
|
||||
// Remove old data email if exists
|
||||
(
|
||||
rewrite_str(
|
||||
|
@ -501,9 +497,9 @@ fn mail_obfuscation(html: &str) -> (String, bool) {
|
|||
},
|
||||
)
|
||||
.unwrap(),
|
||||
is_modified,
|
||||
modified,
|
||||
)
|
||||
} else {
|
||||
(new_html, is_modified)
|
||||
(new_html, modified)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue