scriptorium/compiler

Compiling means turning post and page content into HTML. By default this content is Markdown that is compiled with Marked.js.

Types

Structure where the compilation results are stored.

pub type CompileDatabase {
  CompileDatabase(
    posts: Dict(PostID, CompiledPost),
    pages: List(CompiledPage),
  )
}

Constructors

  • CompileDatabase(
      posts: Dict(PostID, CompiledPost),
      pages: List(CompiledPage),
    )

A page and its compiled content.

pub type CompiledPage {
  CompiledPage(orig: Page, content: String)
}

Constructors

  • CompiledPage(orig: Page, content: String)

A post and its compiled content.

pub type CompiledPost {
  CompiledPost(orig: Post, content: PostContent)
}

Constructors

  • CompiledPost(orig: Post, content: PostContent)

A function to compile the given string content into an HTML string.

pub type Compiler =
  fn(String, Database) -> String

Compiled post content: strings that contain HTML.

pub type PostContent {
  PostContent(full: String, short: option.Option(String))
}

Constructors

  • PostContent(full: String, short: option.Option(String))

Functions

pub fn compile(
  db: Database,
  compiler: fn(String, Database) -> String,
) -> CompileDatabase

Compile contents of the database using the given compiler.

pub fn compile_pages(
  db: Database,
  compiler: fn(String, Database) -> String,
) -> List(CompiledPage)

Compile all pages in the database using the given compiler.

pub fn compile_posts(
  db: Database,
  compiler: fn(String, Database) -> String,
) -> Dict(BigInt, CompiledPost)

Compile all posts in the database using the given compiler.

pub fn default_compiler(content: String, db: Database) -> String

The default compiler that uses Marked.js with default settings.

Search Document