strip xml tags from the markdown source

This commit is contained in:
yggverse 2026-03-13 20:41:51 +02:00
parent b6b8f96bba
commit 563b228e9e
3 changed files with 10 additions and 4 deletions

7
Cargo.lock generated
View file

@ -23,6 +23,7 @@ dependencies = [
"regex",
"rusqlite",
"sourceview5",
"strip-tags",
"syntect",
]
@ -1369,6 +1370,12 @@ version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
[[package]]
name = "strip-tags"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecd2b127e68202f5f285a116f616d5d11735cca5e4befaea0347becd445b05b2"
[[package]]
name = "syn"
version = "2.0.117"

View file

@ -42,6 +42,7 @@ plurify = "0.2.0"
r2d2 = "0.8.10"
r2d2_sqlite = "0.32.0"
regex = "1.12.3"
strip-tags = "0.1.0"
syntect = "5.2.0"
# development

View file

@ -14,6 +14,7 @@ use gtk::{
use gutter::Gutter;
use sourceview::prelude::{ActionExt, ActionMapExt, DisplayExt, ToVariant};
use std::{cell::Cell, collections::HashMap, rc::Rc};
use strip_tags::*;
use tags::Tags;
pub struct Markdown {
@ -39,9 +40,6 @@ impl Markdown {
// * maybe less expensive than update entire HashMap by iter
let hover: Rc<Cell<Option<TextTag>>> = Rc::new(Cell::new(None));
// Init code features
//let mut code = None;
// Init colors
// @TODO use accent colors in adw 1.6 / ubuntu 24.10+
let link_color = (
@ -54,7 +52,7 @@ impl Markdown {
// Init new text buffer
let buffer = TextBuffer::new(Some(&TextTagTable::new()));
buffer.set_text(markdown);
buffer.set_text(&strip_tags(markdown)); // @TODO extract `<img>` tags?
// Init main widget
let text_view = {