pub mod attrs;
pub mod blocks;
pub mod builder;
pub(crate) mod chart;
pub mod citation;
pub(crate) mod diagram;
pub mod error;
pub mod icons;
pub mod inline;
pub mod lint;
pub mod parse;
pub mod render_html;
pub mod render_latex;
pub mod render_md;
pub mod resolve;
pub mod slots;
#[cfg(feature = "pdf")]
pub mod render_pdf;
pub mod render_typst;
#[cfg(feature = "slides")]
pub mod render_slides;
#[cfg(feature = "terminal")]
pub mod render_term;
#[cfg(feature = "native")]
pub mod render_native;
#[cfg(feature = "uniffi")]
pub mod ffi;
#[cfg(feature = "uniffi")]
uniffi::setup_scaffolding!();
#[cfg(feature = "wasm")]
pub mod wasm;
pub mod template;
pub mod types;
pub mod validate;
pub const SURFDOC_CSS: &str = include_str!("../assets/surfdoc.css");
pub use blocks::{parse_schema_field_type, parse_schema_constraint};
pub use builder::SurfDocBuilder;
pub use citation::{
active_style, bibliography_heading, build_context, format_in_text, format_reference,
parse_author, parse_authors, reference_list, reference_list_keyed, Author, CiteContext,
CiteItem, CiteRef, Reference, RefType,
};
pub use error::*;
pub use lint::{
AppliedFix, CheckReport, FixOutcome, LintConfig, LintRule, SkippedFix, apply_fixes,
apply_fixes_once, check, check_with,
};
pub use parse::parse;
pub use template::TemplateContext;
pub use types::*;
pub use render_html::{
PageConfig, SiteConfig, PageEntry, extract_site, humanize_route, render_site_page,
render_site_single_file,
accent_ink_color, contrast_ratio, to_shell_page, HeadIcon, HeadScript,
};
pub use slots::{resolve_slot_markers, IMG_SLOT_PLACEHOLDER_URI};
#[cfg(feature = "slides")]
pub use render_slides::{DeckConfig, SlideEntry, extract_deck, render_deck_html};
#[cfg(feature = "pdf")]
pub use render_pdf::{collect_image_srcs, PdfConfig, PdfError};
impl SurfDoc {
pub fn to_markdown(&self) -> String {
render_md::to_markdown(self)
}
pub fn to_html(&self) -> String {
render_html::to_html(self)
}
pub fn to_html_fragment(&self) -> String {
render_html::to_html_fragment(&self.blocks)
}
pub fn to_html_fragment_with_context(&self, ctx: &TemplateContext) -> String {
let html = self.to_html_fragment();
ctx.resolve(&html)
}
pub fn to_html_page(&self, config: &PageConfig) -> String {
render_html::to_html_page(self, config)
}
pub fn to_html_with_context(&self, ctx: &TemplateContext) -> String {
let html = self.to_html();
ctx.resolve(&html)
}
pub fn to_html_page_with_context(&self, config: &PageConfig, ctx: &TemplateContext) -> String {
let html = self.to_html_page(config);
ctx.resolve(&html)
}
#[cfg(feature = "pdf")]
pub fn to_pdf(
&self,
config: &render_pdf::PdfConfig,
) -> Result<Vec<u8>, render_pdf::PdfError> {
render_pdf::to_pdf(self, config)
}
pub fn to_typst(&self) -> String {
render_typst::to_typst(self)
}
pub fn to_latex(&self) -> String {
render_latex::to_latex(self)
}
#[cfg(feature = "terminal")]
pub fn to_terminal(&self) -> String {
render_term::to_terminal(self)
}
#[cfg(feature = "native")]
pub fn to_native_blocks(&self) -> Vec<render_native::NativeBlock> {
render_native::to_native_blocks(self)
}
pub fn render_profile(&self) -> RenderProfile {
let (doc_type, format) = self
.front_matter
.as_ref()
.map(|fm| (fm.doc_type, fm.format))
.unwrap_or((None, None));
render_profile(doc_type, format)
}
pub fn is_presentation(&self) -> bool {
matches!(self.render_profile(), RenderProfile::Presentation)
}
#[cfg(feature = "slides")]
pub fn to_slides_html(&self) -> String {
render_slides::to_slides_html(self)
}
pub fn to_surf_source(&self) -> String {
builder::to_surf_source(self)
}
pub fn validate(&self) -> Vec<crate::error::Diagnostic> {
validate::validate(self)
}
}