pub struct SurfDoc {
pub front_matter: Option<FrontMatter>,
pub blocks: Vec<Block>,
pub source: String,
}Expand description
A parsed SurfDoc document.
Fields§
§front_matter: Option<FrontMatter>Parsed YAML front matter, if present.
blocks: Vec<Block>Ordered sequence of blocks in the document body.
source: StringOriginal source text that was parsed.
Implementations§
Source§impl SurfDoc
impl SurfDoc
Sourcepub fn to_markdown(&self) -> String
pub fn to_markdown(&self) -> String
Render this document as standard CommonMark markdown (no :: markers).
Sourcepub fn to_html(&self) -> String
pub fn to_html(&self) -> String
Render this document as an HTML fragment with surfdoc-* CSS classes.
Sourcepub fn to_html_fragment(&self) -> String
pub fn to_html_fragment(&self) -> String
Render this document’s blocks as bare HTML without page chrome.
Unlike [to_html()], this does not scan for ::site/::style overrides,
extract nav blocks, or apply auto-section wrapping. Each block is rendered
individually and joined with newlines.
Use this for streaming, chat rendering, or embedding individual blocks where the caller controls the CSS context.
Sourcepub fn to_html_fragment_with_context(&self, ctx: &TemplateContext) -> String
pub fn to_html_fragment_with_context(&self, ctx: &TemplateContext) -> String
Render this document’s blocks as bare HTML with template variable interpolation.
Sourcepub fn to_html_page(&self, config: &PageConfig) -> String
pub fn to_html_page(&self, config: &PageConfig) -> String
Render this document as a complete HTML page with SurfDoc discovery metadata.
Sourcepub fn to_html_with_context(&self, ctx: &TemplateContext) -> String
pub fn to_html_with_context(&self, ctx: &TemplateContext) -> String
Render this document as an HTML fragment with template variable interpolation.
Sourcepub fn to_html_page_with_context(
&self,
config: &PageConfig,
ctx: &TemplateContext,
) -> String
pub fn to_html_page_with_context( &self, config: &PageConfig, ctx: &TemplateContext, ) -> String
Render this document as a complete HTML page with template variable interpolation.
Sourcepub fn to_typst(&self) -> String
pub fn to_typst(&self) -> String
Render this document as Typst markup text.
The output is a valid .typ file that can be compiled by Typst.
paper/report documents use academic templates (IEEE/ACM/article and
MLA/APA/Chicago); all other documents use the generic SurfDoc layout.
Sourcepub fn to_latex(&self) -> String
pub fn to_latex(&self) -> String
Render this document as a complete LaTeX (.tex) document string.
The output target is selected by the document’s RenderProfile:
paper → IEEEtran/two-column article/article; report →
article configured for MLA/APA/Chicago; everything else → a plain
article. Citations and the reference list are produced by the citation
engine in the active style. The .tex is deterministic and compilable.
Sourcepub fn to_terminal(&self) -> String
pub fn to_terminal(&self) -> String
Render this document as ANSI-colored terminal text.
Sourcepub fn render_profile(&self) -> RenderProfile
pub fn render_profile(&self) -> RenderProfile
The RenderProfile for this document, resolved from its front-matter
type: and format: fields (see render_profile).
Sourcepub fn is_presentation(&self) -> bool
pub fn is_presentation(&self) -> bool
Whether this document should render as a presentation deck — true for
type: deck, type: slides, and type: presentation. Callers that
auto-dispatch output should route these documents to Self::to_slides_html.
Sourcepub fn to_slides_html(&self) -> String
pub fn to_slides_html(&self) -> String
Render this document as a complete, self-contained HTML presentation deck.
Slides are first-class the same way Website is: a ::deck/::slide
block family rendered via a dedicated renderer. If the document has no
explicit deck/slides, every #/## heading becomes a slide
(Presentation Mode). type: presentation (alongside deck/slides) is
recognized as this slides path via Self::is_presentation. Requires
the slides feature.
Sourcepub fn to_surf_source(&self) -> String
pub fn to_surf_source(&self) -> String
Serialize this document back to valid .surf format text.
The output can be parsed again with [parse] to produce an equivalent
document (round-trip).
Sourcepub fn validate(&self) -> Vec<Diagnostic>
pub fn validate(&self) -> Vec<Diagnostic>
Validate this document and return any diagnostics.