Skip to main content

SurfDoc

Struct SurfDoc 

Source
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: String

Original source text that was parsed.

Implementations§

Source§

impl SurfDoc

Source

pub fn to_markdown(&self) -> String

Render this document as standard CommonMark markdown (no :: markers).

Source

pub fn to_html(&self) -> String

Render this document as an HTML fragment with surfdoc-* CSS classes.

Source

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.

Source

pub fn to_html_fragment_with_context(&self, ctx: &TemplateContext) -> String

Render this document’s blocks as bare HTML with template variable interpolation.

Source

pub fn to_html_page(&self, config: &PageConfig) -> String

Render this document as a complete HTML page with SurfDoc discovery metadata.

Source

pub fn to_html_with_context(&self, ctx: &TemplateContext) -> String

Render this document as an HTML fragment with template variable interpolation.

Source

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.

Source

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.

Source

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: paperIEEEtran/two-column article/article; reportarticle 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.

Source

pub fn to_terminal(&self) -> String

Render this document as ANSI-colored terminal text.

Source

pub fn render_profile(&self) -> RenderProfile

The RenderProfile for this document, resolved from its front-matter type: and format: fields (see render_profile).

Source

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.

Source

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.

Source

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).

Source

pub fn validate(&self) -> Vec<Diagnostic>

Validate this document and return any diagnostics.

Trait Implementations§

Source§

impl Clone for SurfDoc

Source§

fn clone(&self) -> SurfDoc

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SurfDoc

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for SurfDoc

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for SurfDoc

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.