zio.blocks.docs
ZIO Blocks Markdown - A pure Scala GFM library.
This package provides a complete implementation of GitHub Flavored Markdown with a type-safe ADT, strict parser, renderer, and compile-time validated string interpolator.
==Quick Start==
import zio.blocks.docs._
// Parse markdown
val doc = Parser.parse("# Hello *world*")
// Render to string
val md = Renderer.render(doc.toOption.get)
// Use the interpolator
val name = "World"
val greeting = md"# Hello $$name"
==String Interpolator== The md interpolator validates markdown at compile time and supports interpolation of any type with a ToMarkdown instance.
val title = "My Doc"
val count = 42
val doc = md"""
# $$title
There are $$count items.
"""
==Core Types==
- Doc - A complete markdown document
- Block - Block-level elements (headings, paragraphs, lists, etc.)
- Inline - Inline elements (text, emphasis, links, etc.)
- Parser - Strict GFM parser
- Renderer - GFM renderer
==GFM Support== Supports all GitHub Flavored Markdown features including:
- ATX headings, code blocks, thematic breaks
- Block quotes, lists (ordered, unordered, task lists)
- Tables with alignment
- Inline formatting (emphasis, strong, strikethrough, code)
- Links, images, autolinks
- HTML blocks and inline HTML
Attributes
Members list
Type members
Classlikes
Attributes
- Companion
- trait
- Source
- Alignment.scala
- Supertypes
- Self type
-
Alignment.type
Table column alignment in GFM tables.
Table column alignment in GFM tables.
Attributes
- Companion
- object
- Source
- Alignment.scala
- Supertypes
- Known subtypes
An autolink ( or ).
An autolink ( or ).
Value parameters
- isEmail
-
Whether this is an email autolink
- url
-
The URL or email address
Attributes
- Source
- Inline.scala
- Supertypes
-
trait Inlinetrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A block-level markdown element.
A block-level markdown element.
Blocks are the top-level structural elements in a markdown document, such as paragraphs, headings, code blocks, lists, and tables.
Attributes
- Source
- Block.scala
- Supertypes
- Known subtypes
-
class BlockQuoteclass BulletListclass CodeBlockclass Headingclass HtmlBlockclass ListItemclass OrderedListclass Paragraphclass Tableobject ThematicBreakShow all
A block quote (> prefix).
A block quote (> prefix).
Value parameters
- content
-
The blocks within the quote
Attributes
- Source
- Block.scala
- Supertypes
-
trait Blocktrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
An unordered list with bullet markers (-, *, or +).
An unordered list with bullet markers (-, *, or +).
Value parameters
- items
-
The list items
- tight
-
Whether the list is tight (no blank lines between items)
Attributes
- Source
- Block.scala
- Supertypes
-
trait Blocktrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Inline code span (code).
Inline code span (code).
Value parameters
- value
-
The code content
Attributes
- Source
- Inline.scala
- Supertypes
-
trait Inlinetrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A fenced code block.
A fenced code block.
Value parameters
- code
-
The code content
- info
-
Optional language/info string (e.g., "scala", "json")
Attributes
- Source
- Block.scala
- Supertypes
-
trait Blocktrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A GitHub Flavored Markdown document.
A GitHub Flavored Markdown document.
Represents a complete GFM document as a sequence of block elements. Documents can be created by parsing markdown strings or constructed programmatically.
Value parameters
- blocks
-
The sequence of block elements in the document
- metadata
-
Optional metadata (reserved for future use)
Attributes
Emphasized text (text or text).
Emphasized text (text or text).
Value parameters
- content
-
The inline elements to emphasize
Attributes
- Source
- Inline.scala
- Supertypes
-
trait Inlinetrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A hard line break (two spaces or backslash before newline).
A hard line break (two spaces or backslash before newline).
Attributes
- Source
- Inline.scala
- Supertypes
-
trait Singletontrait Producttrait Mirrortrait Inlinetrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
- Self type
-
HardBreak.type
An ATX-style heading (# to ######).
An ATX-style heading (# to ######).
Value parameters
- content
-
The inline elements within the heading
- level
-
The heading level (H1 to H6)
Attributes
- Source
- Block.scala
- Supertypes
-
trait Blocktrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Heading level for ATX-style headings.
Heading level for ATX-style headings.
GFM supports six levels of headings, from H1 (# ) to H6 (###### ).
Value parameters
- value
-
The numeric heading level (1-6)
Attributes
- Companion
- object
- Source
- HeadingLevel.scala
- Supertypes
- Known subtypes
Attributes
- Companion
- class
- Source
- HeadingLevel.scala
- Supertypes
- Self type
-
HeadingLevel.type
Raw HTML block content.
Raw HTML block content.
Value parameters
- content
-
The HTML content
Attributes
- Source
- Block.scala
- Supertypes
-
trait Blocktrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Raw HTML inline content.
Raw HTML inline content.
Value parameters
- content
-
The HTML content
Attributes
- Source
- Inline.scala
- Supertypes
-
trait Inlinetrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Renderer for HTML output.
Renderer for HTML output.
Converts markdown AST elements to HTML5-compliant HTML strings. Provides both full document rendering with DOCTYPE and head/body tags, and fragment rendering for embedding in existing HTML documents.
Attributes
- Source
- HtmlRenderer.scala
- Supertypes
- Self type
-
HtmlRenderer.type
An image.
An image.
Value parameters
- alt
-
The alt text
- title
-
Optional image title
- url
-
The image URL
Attributes
- Source
- Inline.scala
- Supertypes
-
trait Inlinetrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- trait
- Source
- Inline.scala
- Supertypes
- Self type
-
Inline.type
An inline markdown element.
An inline markdown element.
Inline elements are the content within block elements, such as text, emphasis, links, and code spans.
Attributes
- Companion
- object
- Source
- Inline.scala
- Supertypes
- Known subtypes
-
class Autolinkclass Codeclass Emphasisobject HardBreakclass HtmlInlineclass Imageclass Autolinkclass Codeclass Emphasisobject HardBreakclass HtmlInlineclass Imageclass Linkobject SoftBreakclass Strikethroughclass Strongclass Textclass Linkobject SoftBreakclass Strikethroughclass Strongclass TextShow all
A hyperlink.
A hyperlink.
Value parameters
- text
-
The link text
- title
-
Optional link title
- url
-
The link URL
Attributes
- Source
- Inline.scala
- Supertypes
-
trait Inlinetrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A list item, which may be a task list item.
A list item, which may be a task list item.
Value parameters
- checked
-
For task lists: Some(true) for [x], Some(false) for [ ], None for regular items
- content
-
The blocks within the list item
Attributes
- Source
- Block.scala
- Supertypes
-
trait Blocktrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Source
- MdInterpolator.scala
- Supertypes
Attributes
- Source
- MdInterpolatorRuntime.scala
- Supertypes
- Self type
An ordered list with numeric markers (1., 2., etc.).
An ordered list with numeric markers (1., 2., etc.).
Value parameters
- items
-
The list items
- start
-
The starting number
- tight
-
Whether the list is tight (no blank lines between items)
Attributes
- Source
- Block.scala
- Supertypes
-
trait Blocktrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A paragraph containing inline content.
A paragraph containing inline content.
Value parameters
- content
-
The inline elements within the paragraph
Attributes
- Source
- Block.scala
- Supertypes
-
trait Blocktrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A parse error with position information.
A parse error with position information.
Returned when the parser encounters invalid markdown syntax.
Value parameters
- column
-
Column number where the error occurred (1-based)
- input
-
The input line that caused the error
- line
-
Line number where the error occurred (1-based)
- message
-
Human-readable error message
Attributes
- Source
- ParseError.scala
- Supertypes
Parser for GitHub Flavored Markdown.
Parser for GitHub Flavored Markdown.
Provides strict parsing of GFM documents, returning either a parsed Doc or a ParseError with position information.
==Supported Features==
- ATX headings (# to ######)
- Fenced code blocks (
- Thematic breaks (---, ***, ___)
- Block quotes (> prefix)
- Bullet and ordered lists
- Task lists (- [ ] and - [x])
- Tables with alignment
- Inline formatting (emphasis, strong, strikethrough, code)
- Links and images
- Autolinks
- HTML blocks and inline HTML
==Not Supported==
- YAML frontmatter (causes parse error)
- Setext headings (use ATX style)
- Indented code blocks (use fenced)
- Link reference definitions
Attributes
- Source
- Parser.scala
- Supertypes
- Self type
-
Parser.type
Renderer for GitHub Flavored Markdown.
Renderer for GitHub Flavored Markdown.
Converts markdown AST elements back to GFM-compliant markdown strings. The rendered output can be re-parsed to produce an equivalent AST.
Attributes
- Source
- Renderer.scala
- Supertypes
- Self type
-
Renderer.type
A soft line break (single newline).
A soft line break (single newline).
Attributes
- Source
- Inline.scala
- Supertypes
-
trait Singletontrait Producttrait Mirrortrait Inlinetrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
- Self type
-
SoftBreak.type
Strikethrough text (text).
Strikethrough text (text).
Value parameters
- content
-
The inline elements to strike through
Attributes
- Source
- Inline.scala
- Supertypes
-
trait Inlinetrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Strong/bold text (text or text).
Strong/bold text (text or text).
Value parameters
- content
-
The inline elements to make strong
Attributes
- Source
- Inline.scala
- Supertypes
-
trait Inlinetrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A GFM table.
A GFM table.
Value parameters
- alignments
-
Column alignments
- header
-
The header row
- rows
-
The data rows
Attributes
- Source
- Block.scala
- Supertypes
-
trait Blocktrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A row in a GFM table.
A row in a GFM table.
Each cell contains a chunk of inline elements.
Value parameters
- cells
-
The cells in the row, where each cell is a chunk of inline elements
Attributes
- Source
- TableRow.scala
- Supertypes
Renderer for ANSI terminal output.
Renderer for ANSI terminal output.
Converts markdown AST elements to colorful, formatted terminal output using ANSI escape codes. The output is designed to be readable on both light and dark terminal backgrounds.
Attributes
- Source
- TerminalRenderer.scala
- Supertypes
- Self type
-
TerminalRenderer.type
Plain text content.
Plain text content.
Value parameters
- value
-
The text string
Attributes
- Source
- Inline.scala
- Supertypes
-
trait Inlinetrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
A thematic break (---, ***, or ___).
A thematic break (---, ***, or ___).
Attributes
- Source
- Block.scala
- Supertypes
-
trait Singletontrait Producttrait Mirrortrait Blocktrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
- Self type
-
ThematicBreak.type
Attributes
- Companion
- trait
- Source
- ToMarkdown.scala
- Supertypes
- Self type
-
ToMarkdown.type
Type class for converting values to markdown inline elements.
Type class for converting values to markdown inline elements.
Used by the md string interpolator to support interpolation of arbitrary types. Implement this trait for custom types to enable markdown interpolation.
Type parameters
- A
-
The type to convert to markdown
Attributes
- Example
-
case class Person(name: String, age: Int) implicit val personToMarkdown: ToMarkdown[Person] = (p: Person) => Strong(Chunk(Text(p.name))) val person = Person("Alice", 30) val doc = md"# User: $$person" - Companion
- object
- Source
- ToMarkdown.scala
- Supertypes
Extensions
Inherited extensions
Attributes
- Inherited from:
- MdInterpolator
- Source
- MdInterpolator.scala