Prosody.TextParser (Prosody v1.1.0)

Copy Markdown View Source

Plain text content parser for the Prosody content analysis library. This module provides fallback behaviour for plain text content or unknown markup formats.

Summary

Functions

Parse plain text content (from String.t/0) into linear Prosody.block/0 entries. Returns {:ok, blocks} or {:error, reason}.

Parse plain text content (from String.t/0) into linear Prosody.block/0 entries. Returns blocks or raises an error.

Functions

parse(content, opts \\ [])

Parse plain text content (from String.t/0) into linear Prosody.block/0 entries. Returns {:ok, blocks} or {:error, reason}.

Options

  • :strip_frontmatter (default: true): Whether to strip YAML frontmatter.

Examples

iex> Prosody.TextParser.parse("Hello world!")
{:ok, [
  %{type: :text, content: "Hello world!", language: nil, metadata: %{}}
]}

iex> Prosody.TextParser.parse("Text with code blocks")
{:ok, [
  %{type: :text, content: "Text with code blocks", language: nil, metadata: %{}}
]}

parse!(content, opts \\ [])

Parse plain text content (from String.t/0) into linear Prosody.block/0 entries. Returns blocks or raises an error.

Options

  • :strip_frontmatter (default: true): Whether to strip YAML frontmatter.

Examples

iex> Prosody.TextParser.parse!("Hello world!")
[%{type: :text, content: "Hello world!", language: nil, metadata: %{}}]

iex> Prosody.TextParser.parse!("Text with code blocks")
[%{type: :text, content: "Text with code blocks", language: nil, metadata: %{}}]