sita 0.1.0

Sita: static site generator (SSG) for Markdown and HTML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Markdown matter using HTML, JSON, TOML, YAML.

use std::any::Any;
use crate::errors::*;

pub trait MatterParserTrait<STATE> {
    fn as_any(&self) -> &dyn Any;
    fn parse_mix_text_to_content_text_and_matter_text(&self, mix_text: &str) -> Result<(String, String)>;
    fn parse_mix_text_to_content_text_and_state(&self, mix_text: &str) -> Result<(String, STATE)> {
        if let Ok((content_text, matter_text)) = self.parse_mix_text_to_content_text_and_matter_text(mix_text) {
            if let Ok(state) = self.parse_matter_text_to_state(&matter_text) {
                return Ok((content_text, state));
            }
        }
        Err("Failed to parse mix text to content text and state.".into())
    }
    fn parse_matter_text_to_state(&self, matter_text: &str) -> Result<STATE>;
}