use crate::content::Content;
use crate::language::Language;
pub mod helm;
pub struct CustomParser {
pub languages: &'static [Language],
pub validator: fn(&Content) -> bool,
pub transformer: fn(&Content) -> Option<Content>,
}
impl CustomParser {
pub(crate) fn validate(&self, content: &Content) -> bool {
(self.validator)(content)
}
pub(crate) fn transform(&self, content: &Content) -> Option<Content> {
(self.transformer)(content)
}
}
static ALL: &[CustomParser] = &[helm::PARSER];
pub fn for_language(language: Language) -> impl Iterator<Item = &'static CustomParser> {
ALL.iter()
.filter(move |custom_parser| custom_parser.languages.contains(&language))
}