This documentation is also published as Markdown for efficient machine reading: the whole site is indexed at /llms.txt, and every page has a clean Markdown copy under /_llms/. These are generated from the same source and cost far fewer tokens to read than this rendered HTML.

Skip to main content Skip to navigation

BookComposer Pennington.Book.Composition

Composes one self-contained book document from a navigation tree and the projected pages under it.

Each page is normalized exactly like llms.txt — its post-pipeline HTML is converted to markdown (HtmlToMarkdownConverter) and re-rendered through the shared MarkdownPipeline, which re-highlights fences and normalizes alerts/tabs regardless of which content service produced the page. The result is wrapped into chapter/page sections, prefixed with a cover and a page-numbered table of contents, and emitted with the print stylesheet and the paged.js polyfill inlined so the document renders offline (no server, no external assets).

Constructors

BookComposer

#
public BookComposer(MarkdownPipeline pipeline, CanonicalBaseUrl canonicalBase, PenningtonOptions penn, TranslationOptions translations, LocalizationOptions localization)

Creates a composer that re-renders through pipeline, absolutizes out-of-book links against canonicalBase, titles the cover from penn, and localizes book chrome strings through translations for the locale resolved against localization.

Parameters

pipeline MarkdownPipeline
canonicalBase CanonicalBaseUrl
penn PenningtonOptions
translations TranslationOptions
localization LocalizationOptions

Methods

Compose

#
public string Compose(BookDefinition book, ImmutableList<NavigationTreeItem> tree, IReadOnlyDictionary<string, RenderedPage> pageByPath, string additionalCss, Func<string, string> resolveImageSrc, bool monochrome = false, BookStamp stamp = null)

Composes the full HTML document for book from tree (already scoped to the book) and pageByPath (the projected pages keyed by trimmed canonical path). A tree wrapped in the book's own index node is unwrapped first (UnwrapBookRoot) so the index's children become the chapters. When monochrome is set, a grayscale override stylesheet is appended after the built-in one; additionalCss is appended last (so it still wins), and resolveImageSrc inlines image sources to data: URIs. stamp supplies provenance (version, date, locale) for the cover version line and the colophon page; when null both are omitted and the document language falls back to the default locale.

Parameters

book BookDefinition
tree ImmutableList<NavigationTreeItem>
pageByPath IReadOnlyDictionary<string, RenderedPage>
additionalCss string
resolveImageSrc Func<string, string>
monochrome bool
stamp BookStamp

Returns

string

Pennington.Book.Composition.BookComposer

namespace Pennington.Book.Composition;

/// Composes one self-contained book document from a navigation tree and the projected pages under it. Each page is normalized exactly like llms.txt — its post-pipeline HTML is converted to markdown (HtmlToMarkdownConverter) and re-rendered through the shared MarkdownPipeline, which re-highlights fences and normalizes alerts/tabs regardless of which content service produced the page. The result is wrapped into chapter/page sections, prefixed with a cover and a page-numbered table of contents, and emitted with the print stylesheet and the paged.js polyfill inlined so the document renders offline (no server, no external assets).
public class BookComposer
{
    /// Creates a composer that re-renders through pipeline, absolutizes out-of-book links against canonicalBase, titles the cover from penn, and localizes book chrome strings through translations for the locale resolved against localization.
    
public BookComposer(MarkdownPipeline pipeline, CanonicalBaseUrl canonicalBase, PenningtonOptions penn, TranslationOptions translations, LocalizationOptions localization)
; /// Composes the full HTML document for book from tree (already scoped to the book) and pageByPath (the projected pages keyed by trimmed canonical path). A tree wrapped in the book's own index node is unwrapped first (UnwrapBookRoot) so the index's children become the chapters. When monochrome is set, a grayscale override stylesheet is appended after the built-in one; additionalCss is appended last (so it still wins), and resolveImageSrc inlines image sources to data: URIs. stamp supplies provenance (version, date, locale) for the cover version line and the colophon page; when null both are omitted and the document language falls back to the default locale.
public string Compose(BookDefinition book, ImmutableList<NavigationTreeItem> tree, IReadOnlyDictionary<string, RenderedPage> pageByPath, string additionalCss, Func<string, string> resolveImageSrc, bool monochrome = false, BookStamp stamp = null)
; }