use scraper::ElementRef;
use crate::context::Context;
use crate::converter::{Action, Rule};
use crate::dom;
#[derive(Debug, Clone, Copy)]
pub(super) struct Strong;
impl Rule for Strong {
fn tags(&self) -> &'static [&'static str] {
&["strong", "b"]
}
fn apply(&self, content: &str, element: &ElementRef<'_>, ctx: &mut Context<'_>) -> Action {
if dom::parent_tag_is(element, "strong") || dom::parent_tag_is(element, "b") {
return Action::Replace(content.to_owned());
}
let trimmed = content.trim();
if trimmed.is_empty() {
return Action::Skip;
}
let delim = ctx.options().strong_delimiter().as_str();
let wrapped = super::wrap_delimiter_per_line(trimmed, delim);
Action::Replace(dom::add_space_if_necessary(element, wrapped))
}
}