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 at the same URL with .md appended. 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

AssetInliner Pennington.Book.Composition

Resolves <img src> values to self-contained data: URIs so the composed book renders offline (Chromium navigates via SetContentAsync with no server to fetch from). Internal sources resolve first from the content-copy map (a content source's own static assets), then from the host web root (wwwroot + RCL static web assets). External http(s) images are left untouched — an offline Chromium simply omits them — and unresolved internal sources are rewritten to an absolute URL so they at least point somewhere real.

Constructors

AssetInliner

#
public AssetInliner(IFileSystem fileSystem, IFileProvider webRoot, CanonicalBaseUrl canonicalBase)

Creates an inliner over the given file system, web-root provider, and canonical base.

Parameters

fileSystem IFileSystem
webRoot IFileProvider
canonicalBase CanonicalBaseUrl

Methods

BuildContentMapAsync

#
public static Task<IReadOnlyDictionary<string, string>> BuildContentMapAsync(IEnumerable<IContentService> services)

Builds the output-path → source-file map from every content service's static-copy declarations. First registration wins on a duplicate output path, mirroring the build's copy pass.

Parameters

services IEnumerable<IContentService>

Returns

Task<IReadOnlyDictionary<string, string>>

Resolve

#
public string Resolve(string src, IReadOnlyDictionary<string, string> contentMap)

Resolves src to a data: URI when the bytes can be found, an absolute URL when an internal source is unresolved, or src unchanged for external images.

Parameters

src string
contentMap IReadOnlyDictionary<string, string>

Returns

string

Pennington.Book.Composition.AssetInliner

namespace Pennington.Book.Composition;

/// Resolves <img src> values to self-contained data: URIs so the composed book renders offline (Chromium navigates via SetContentAsync with no server to fetch from). Internal sources resolve first from the content-copy map (a content source's own static assets), then from the host web root (wwwroot + RCL static web assets). External http(s) images are left untouched — an offline Chromium simply omits them — and unresolved internal sources are rewritten to an absolute URL so they at least point somewhere real.
public class AssetInliner
{
    /// Creates an inliner over the given file system, web-root provider, and canonical base.
    
public AssetInliner(IFileSystem fileSystem, IFileProvider webRoot, CanonicalBaseUrl canonicalBase)
; /// Builds the output-path → source-file map from every content service's static-copy declarations. First registration wins on a duplicate output path, mirroring the build's copy pass.
public static Task<IReadOnlyDictionary<string, string>> BuildContentMapAsync(IEnumerable<IContentService> services)
; /// Resolves src to a data: URI when the bytes can be found, an absolute URL when an internal source is unresolved, or src unchanged for external images.
public string Resolve(string src, IReadOnlyDictionary<string, string> contentMap)
; }