use crate::ast::RcdataContentType;
use crate::entity::encode::encode_entities;
use crate::tag::TAG_TEXTAREA_END;
use crate::tag::TAG_TITLE_END;
use crate::Cfg;
pub fn minify_rcdata(cfg: &Cfg, out: &mut Vec<u8>, typ: RcdataContentType, text: &[u8]) {
let html = encode_entities(text, false, !cfg.allow_optimal_entities);
let html = match typ {
RcdataContentType::Textarea => &*TAG_TEXTAREA_END,
RcdataContentType::Title => &*TAG_TITLE_END,
}
.replace_all_bytes(&html, &[match typ {
RcdataContentType::Textarea => {
if cfg.allow_optimal_entities {
b"</textarea".as_slice()
} else {
b"</textarea".as_slice()
}
}
RcdataContentType::Title => {
if cfg.allow_optimal_entities {
b"</title".as_slice()
} else {
b"</title".as_slice()
}
}
}]);
out.extend_from_slice(&html);
}