#[cfg(test)]
mod test;
#[macro_use]
mod attributes;
mod builder;
mod context;
mod element;
mod escape;
mod meta;
mod output;
mod random;
mod render;
pub use self::meta::{HtmlMeta, HtmlMetaType};
pub use self::output::HtmlOutput;
#[cfg(test)]
use super::prelude;
use self::attributes::AddedAttributes;
use self::context::HtmlContext;
use crate::data::PageInfo;
use crate::render::{Handle, Render};
use crate::settings::WikitextSettings;
use crate::tree::SyntaxTree;
#[derive(Debug)]
pub struct HtmlRender;
impl Render for HtmlRender {
type Output = HtmlOutput;
fn render(
&self,
tree: &SyntaxTree,
page_info: &PageInfo,
settings: &WikitextSettings,
) -> HtmlOutput {
info!(
"Rendering HTML (site {}, page {}, category {})",
page_info.site.as_ref(),
page_info.page.as_ref(),
match &page_info.category {
Some(category) => category.as_ref(),
None => "_default",
},
);
let mut ctx = HtmlContext::new(
page_info,
&Handle,
settings,
&tree.table_of_contents,
&tree.footnotes,
&tree.bibliographies,
tree.wikitext_len,
);
ctx.html()
.element("wj-body")
.attr(attr!("class" => "wj-body"))
.contents(&tree.elements);
ctx.into()
}
}