use crate::{
analysis::events::tags::{OverrideTag, TagDiagnostic},
Result,
};
#[cfg(feature = "plugins")]
use crate::plugin::ExtensionRegistry;
use alloc::{string::String, vec::Vec};
#[derive(Debug, Clone)]
pub struct TextAnalysis<'a> {
pub(super) plain_text: String,
pub(super) char_count: usize,
pub(super) line_count: usize,
pub(super) has_bidi_text: bool,
pub(super) has_complex_unicode: bool,
pub(super) override_tags: Vec<OverrideTag<'a>>,
pub(super) parse_diagnostics: Vec<TagDiagnostic<'a>>,
}
impl<'a> TextAnalysis<'a> {
pub fn analyze(text: &'a str) -> Result<Self> {
#[cfg(feature = "plugins")]
return Self::analyze_with_registry(text, None);
#[cfg(not(feature = "plugins"))]
return Self::analyze_impl(text);
}
#[cfg(feature = "plugins")]
pub fn analyze_with_registry(
text: &'a str,
registry: Option<&ExtensionRegistry>,
) -> Result<Self> {
Self::analyze_impl_with_registry(text, registry)
}
#[cfg(not(feature = "plugins"))]
fn analyze_impl(text: &'a str) -> Result<Self> {
Self::analyze_impl_with_registry(text)
}
}