pub mod attr;
pub mod property;
pub mod tag;
mod charsets;
mod convert;
mod css;
mod document;
mod dom;
mod encode;
mod fragment;
mod introspect;
mod link;
mod mathml;
mod rules;
mod typed;
pub use self::document::{html_document, html_document_for_bundle};
pub use self::dom::*;
pub use self::encode::{HtmlOptions, html, html_in_bundle};
pub use self::introspect::HtmlIntrospector;
pub use self::link::create_link_anchors;
pub use self::rules::{html_mathml_body, html_span_filled, register};
use ecow::EcoString;
use typst_library::Category;
use typst_library::foundations::{Content, Module, Scope};
use typst_library::introspection::Location;
use typst_macros::elem;
pub fn module() -> Module {
let mut html = Scope::deduplicating();
html.start_category(Category::Html);
html.define_elem::<HtmlElem>();
html.define_elem::<FrameElem>();
crate::typed::define(&mut html);
Module::new("html", html)
}
#[elem(name = "elem")]
pub struct HtmlElem {
#[required]
pub tag: HtmlTag,
#[fold]
pub attrs: HtmlAttrs,
#[internal]
#[parse(Some(css::Properties::default()))]
pub css: css::Properties,
#[positional]
pub body: Option<Content>,
#[internal]
#[synthesized]
pub parent: Location,
#[internal]
#[ghost]
pub role: Option<EcoString>,
}
impl HtmlElem {
pub fn with_attr(mut self, attr: HtmlAttr, value: impl Into<EcoString>) -> Self {
self.attrs
.as_option_mut()
.get_or_insert_with(Default::default)
.push(attr, value);
self
}
pub fn with_optional_attr(
self,
attr: HtmlAttr,
value: Option<impl Into<EcoString>>,
) -> Self {
if let Some(value) = value { self.with_attr(attr, value) } else { self }
}
}
#[elem]
pub struct FrameElem {
#[positional]
#[required]
pub body: Content,
}