Hide cw pictures behind a summary/details (#483)
* Hide cw pictures behind a summary/details * refactor md_to_html a bit and add cw support * use random id for cw checkbox
This commit is contained in:
@@ -19,7 +19,7 @@ lazy_static! {
|
||||
static ref CLEAN: Builder<'static> = {
|
||||
let mut b = Builder::new();
|
||||
b.add_generic_attributes(iter::once("id"))
|
||||
.add_tags(&["iframe", "video", "audio"])
|
||||
.add_tags(&["iframe", "video", "audio", "label", "input"])
|
||||
.id_prefix(Some("postcontent-"))
|
||||
.url_relative(UrlRelative::Custom(Box::new(url_add_prefix)))
|
||||
.add_tag_attributes(
|
||||
@@ -27,7 +27,23 @@ lazy_static! {
|
||||
["width", "height", "src", "frameborder"].iter().cloned(),
|
||||
)
|
||||
.add_tag_attributes("video", ["src", "title", "controls"].iter())
|
||||
.add_tag_attributes("audio", ["src", "title", "controls"].iter());
|
||||
.add_tag_attributes("audio", ["src", "title", "controls"].iter())
|
||||
.add_tag_attributes("label", ["for"].iter())
|
||||
.add_tag_attributes("input", ["type", "checked"].iter())
|
||||
.add_allowed_classes("input", ["cw-checkbox"].iter())
|
||||
.add_allowed_classes("span", ["cw-container", "cw-text"].iter())
|
||||
.attribute_filter(|elem, att, val| match (elem, att) {
|
||||
("input", "type") => Some("checkbox".into()),
|
||||
("input", "checked") => Some("checked".into()),
|
||||
("label", "for") => {
|
||||
if val.starts_with("postcontent-cw-") {
|
||||
Some(val.into())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
_ => Some(val.into()),
|
||||
});
|
||||
b
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user