MindAttic.Export
MindAttic.Export
The one place a MindAttic application turns data into a user-facing file.
- Manuscripts: books and documents rendered to
.docx,.epub,.pdf,.txtand.md. The book path is the Prose house style (6"×9" KDP trim, Garamond), migrated verbatim from Prose and verified byte-for-byte against the whole GLMZ corpus. The document path (US Letter, page-numbered contents, headings, tables, lists, block quotes, LaTeX math, hanging-indent references) serves reports and academic work. - Reports: a single Markdown report exported as
.mdplus.txt/.docx/.pdf/.epubrenders (ReportExporter). - Artifacts: any other file an app produces (JSON, CSV, HTML, recordings, zip bundles) written through
ArtifactWriter: sanitized names, atomic writes, UTF-8 without BOM by default, and an explicit policy for an existing file (archive, uniquify, overwrite or fail).
Everything follows the MindAttic house rules: archive, never delete; whole-number versions; the CLI and the library register the same DI graph.
Scope
The complete product, built and planned, is specified in docs/SPEC.md; the current finish line is docs/RELEASE.md. MS-42 ships figure-complete documents as 7.0.0; MS-160 then renders nested lists as real nested lists and finishes the product as 8.0.0.
Consumers
| Consumer | Uses |
|---|---|
| Prose | Book export (--export-node, --preview), book reports (--export-book-report), the shared ProseInline parser, path and archive helpers
|
| SyntheticExchangeTheory | The dissertation (export.json → mindattic-export)
|
| AutoWebNav, KdpPublish, Automata, JobHunt, Tutor, MindAttic.Ideas, IdiotProof, MediaButler, OpenCredentials | Artifact writes (recordings, data exports, bundles, reports) |
Library
using MindAttic.Export;
using MindAttic.Export.Markdown;
// A Markdown document to a versioned bundle: "<Name> V<N>.{docx,pdf,txt,md}".
var manuscript = MarkdownManuscriptReader.ReadFiles(files, new ManuscriptInfo { Title = "Synthetic Exchange Theory", Author = "Ryan DeBraal" });
var result = await new ManuscriptExporter().ExportBundleAsync(manuscript, new BundleRequest
{
Directory = @"D:\Projects\MindAttic\ePub\MindAttic\SET",
FileBaseName = "SET",
Formats = [ExportFormat.Docx, ExportFormat.Pdf, ExportFormat.Txt, ExportFormat.Md],
Options = ExportOptions.Document
});
// Any artifact, written atomically with a timestamped name.
await ArtifactWriter.WriteJsonAsync(downloads,
ArtifactNames.Timestamped("KdpPublish-session", DateTime.Now, "json", kind: "autowebnav-recording"), recording,
options: new ArtifactOptions { Existing = ExistingArtifact.Overwrite });
| Namespace | Contents |
|---|---|
MindAttic.Export.Model
|
Manuscript, Chapter, blocks (paragraph, sub-heading, heading, tenet, marker, list, quote, table, math, rule, image), glossary
|
MindAttic.Export.Renderers
|
DocxRenderer, EpubRenderer, PdfRenderer, TextRenderer, MarkdownRenderer
|
MindAttic.Export.Markdown
|
MarkdownManuscriptReader (chapters, document blocks, math; report mode)
|
MindAttic.Export.Images
|
IImageResolver, DefaultImageResolver (files, data: URIs), ImageLayout (natural size, fit, SVG to PNG)
|
MindAttic.Export.Text
|
ProseInline (the inline-markup parser shared with the Prose editor), LatexMath
|
MindAttic.Export.Paths
|
ExportPaths (file-name sanitising, bundle names), ExportArchive (archive, never delete; versions)
|
MindAttic.Export.Metadata
|
ReadingInfo (description.txt reading-time line, keywords.txt)
|
MindAttic.Export.Artifacts
|
ArtifactWriter, ArtifactOptions, ArtifactNames
|
Figures
A paragraph that is nothing but a Markdown image () is a figure (ImageBlock). DOCX and PDF embed it, centered and scaled down (never up) to fit the text block, at the natural size the file declares: SVG width/height in any CSS unit (else its viewBox in CSS pixels), PNG and JPEG at their stored dpi (96 when absent). SVG stays vector in both: PDF draws it, and DOCX stores the SVG with a PNG rendering as the fallback for readers that cannot draw SVG. Markdown writes the image back; TXT and EPUB print [Figure: Alt text]. A figure that cannot be resolved prints the same line in DOCX and PDF instead of vanishing. Captions are ordinary paragraphs around the image (APA: a bold Figure N line and an italic title above it).
Sources are resolved at render time by ExportOptions.ImageResolver. The default reads paths (relative ones against the Markdown file's own directory), file: URIs and data: URIs (base64 or percent-encoded); it never downloads http(s): sources. To keep images in an application store, for example as base64 rows in MindAttic.Storage, write  and chain a resolver in front of the default:
sealed class MediaImageResolver(IMediaStore media) : IImageResolver
{
public ImageData? Resolve(ImageBlock image)
{
if (!image.Source.StartsWith("media:") || !Guid.TryParse(image.Source[6..], out var uid)) return null;
// Renderers are synchronous.
if (media.GetAsync(uid).GetAwaiter().GetResult() is not { } found) return null;
using (found.Content) using (var bytes = new MemoryStream())
{
found.Content.CopyTo(bytes);
return ImageData.FromBytes(bytes.ToArray());
}
}
}
var options = ExportOptions.Document with { ImageResolver = new DefaultImageResolver(new MediaImageResolver(media)) };
CLI
mindattic-export --config export.json [--out <dir>] [--formats docx,epub,pdf,txt,md] [--version N] [--no-archive]
export.json names the title page, the Markdown sources (wildcards read in ordinal order), the output folder, the formats and the page profile (letter or trade). See SyntheticExchangeTheory/export.json for a complete example. Set "firstHeadingIsTitle": true for a single paper (a journal manuscript, a report): the first # heading becomes the title and the rest is one continuous document, with its sections as headings and no chapter page breaks. A document with a single # chapter keeps that heading in the .docx (only Prose books drop a lone chapter heading, ExportOptions.OmitSingleChapterHeading), and an EPUB with no chapters still gets a valid one-entry contents nav pointing at the title page.
Build, test, pack
dotnet build dotnet test dotnet pack MindAttic.Export/MindAttic.Export.csproj -c Release -o artifacts
Consumers take the package through C:\LocalNuGet or their own lib/local-packages folder. Package versions are pinned to Prose's (DocumentFormat.OpenXml 3.3.0, QuestPDF 2026.5.0, Markdig 1.1.2) so a consumer resolves one version of each. Targets net9.0 and net10.0.
Verifying a renderer change
The book path must stay byte-identical to Prose's pre-migration output:
- The legacy-equivalence tests (
MindAttic.Export.Tests/Legacy*) render hundreds of generated manuscripts with frozen copies of the original Prose code and with the library, and compare. - Against real books:
prose --export-node --id <book> --preview <dir>for every book before and after the change, then compare the two folders (Markdown, PDF and text byte-for-byte; docx and epub by part content, since OpenXml mints random part names and relationship ids on every save).
License
Not yet chosen.
Pages in this repository
- MindAttic.Export — Project Bible — MindAttic.Export is the one place a MindAttic application turns data into a user-facing file: manuscripts and reports to .docx, .epub,…
- MindAttic.Export — Release charter — The shared library and mindattic-export CLI that turn MindAttic data into user-facing files: Prose books and academic documents to…
- MindAttic.Export — Product specification — In docs/ECOSYSTEM.md MindAttic.Export owns the documents concern: every user-facing file (books, manuscripts, reports) is written through…