Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,25 @@ fn strip_markdown(text: &str) -> String {
}
}

// Remove block math ($$...$$) and inline math ($...$), but only if not starting with a digit (to avoid stripping prices like $19.99)
let block_math_re = regex::Regex::new(r"\$\$([\s\S]+?)\$\$").unwrap();
result = block_math_re.replace_all(&result, "$1").to_string();
let inline_math_re = regex::Regex::new(r"(^|[^\w$])\$([^\$\n]+)\$").unwrap();
result = inline_math_re
.replace_all(&result, |caps: &regex::Captures<'_>| {
let latex = &caps[2];
if latex
.chars()
.next()
.is_some_and(|ch| ch.is_ascii_digit())
{
caps.get(0).map(|m| m.as_str()).unwrap_or("").to_string()
} else {
format!("{}{}", &caps[1], latex)
}
})
.to_string();

// Remove images ![alt](url) - must come before links
let img_re = regex::Regex::new(r"!\[([^\]]*)\]\([^)]+\)").unwrap();
result = img_re.replace_all(&result, "$1").to_string();
Expand Down
9 changes: 8 additions & 1 deletion src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,11 @@ html.dark {
color: var(--color-text);
}

.prose .tiptap-mathematics-render[data-type="inline-math"] {
display: inline-block;
vertical-align: 0.01em;
}

.prose .tiptap-mathematics-render[data-type="block-math"] {
display: block;
margin: 0.75rem 0;
Expand All @@ -579,7 +584,9 @@ html.dark {
}

.prose
.tiptap-mathematics-render[data-type="block-math"].ProseMirror-selectednode {
.tiptap-mathematics-render[data-type="block-math"].ProseMirror-selectednode,
.prose
.tiptap-mathematics-render[data-type="inline-math"].ProseMirror-selectednode {
outline: 2px solid var(--color-bg-emphasis);
outline-offset: 2px;
border-radius: 0.25rem;
Expand Down
Loading