[Repo Assist] Add --embed-resources to fsdocs convert — self-contained HTML output by default#1072
Conversation
Closes #1068 - Add ConvertHelpers module with findContentSearchDirs and embedResourcesInHtml helpers - fsdocs convert now inlines local CSS, JS, and images into the output HTML by default, producing a single self-contained file - Add --no-embed-resources flag to opt out of embedding - Add --template fsdocs sentinel to use the built-in default template from embedded assembly resources without needing a local _template.html - Automatically set {{root}}="" substitution when embedding so template paths like {{root}}content/fsdocs-default.css resolve correctly Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/repo-assist fix the review comments above please. |
…rebinding, add unit tests - Move cssPattern/jsPattern/imgPattern to module level with RegexOptions.Compiled - Replace 'let mutable html' + 'html <-' with sequential immutable 'let html =' rebindings - Add 4 integration unit tests for ConvertHelpers.embedResourcesInHtml: CSS inlining, JS inlining, remote URLs left unchanged, --no-embed-resources flag Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Commit pushed:
|
This comment has been minimized.
This comment has been minimized.
…vert-93fa0b4a915b3eda
…vert-93fa0b4a915b3eda
|
@dsyme, looks reasonable, did you test this locally? |
…into repo-assist/feature-1068-embed-resources-convert-93fa0b4a915b3eda
I've tested it locally just now at first glance, the CSS and scripts do get embedded. Questions
I'll ask repo assist to make a manual validation walkthrough |
|
/repo-assist can you please add a directory tests/manual/convert with a README.md and examples to help us validate that this is doing the right thing. Also answer my questions above |
- Supply default values for all standard {{fsdocs-*}} template parameters
when a template is used with fsdocs convert, so placeholders are replaced
rather than appearing as literal text in the output.
- fsdocs-page-title and fsdocs-collection-name default to the input filename.
- User-supplied --parameters values always override these defaults.
- Add tests/manual/convert/ with README, example.md, example.fsx,
and _template-minimal.html to support manual validation.
- Update RELEASE_NOTES.md.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Commit pushed:
|
This comment has been minimized.
This comment has been minimized.
|
/repo-assist extend tests/manual/convert/ with examples showing images being inlined, I don't see anything about that there yet |
- Add tests/manual/convert/images/sample.png (small raster PNG) - Add tests/manual/convert/images/sample.svg (simple SVG badge) - Reference both images in example.md so they appear in converted output - Add Scenario 8 (image inlining enabled) and Scenario 9 (disabled) to README - Extend Scenario 2 checklist with image data-URI verification - Add image-related rows to Common Issues table Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Commit pushed:
|
|
🤖 Repo Assist here. Done! I've extended New files:
Updated files:
|
Apply Fantomas formatting: [ 1 .. 5 ] → [ 1..5 ] in range literal. This was the only lint failure in CI for PR #1072. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Commit pushed:
|

🤖 This PR was created by Repo Assist, an automated AI assistant, in response to a
/repo-assistcommand from @dsyme on #1068.Closes #1068
Summary
fsdocs convertnow produces a single self-contained HTML file by default: all locally-referenced CSS, JS, and images are inlined into the output. This means the generated file renders correctly when opened directly in a browser or shared as an attachment, without needing a companioncontent/directory.New CLI options
--template fsdocs_template.htmlneeded)--no-embed-resourcesfalseUsage examples
How it works
--template fsdocsreads the default_template.htmlfrom the embedded assembly resource (the same resource already used byfsdocs init) and writes it to a temp file, which is then cleaned up after conversion.Resource embedding runs as a post-processing pass on the generated HTML file:
(link rel="stylesheet" href="...")→(style)CSS_CONTENT(/style)(script src="...")→(script)JS_CONTENT(/script)(img src="local.png")→ `(img src="(redacted)(redacted)https://`) and existing data-URIs are left untouched.Path resolution searches candidate directories in order: output file directory → template directory → NuGet package
extras/content→ in-repodocs/content(development build).{{root}}substitution — when embedding is active and the user hasn't provided arootparameter,rootis set to""so paths like{{root}}content/fsdocs-default.cssbecomecontent/fsdocs-default.cssand are found by the path resolver.Design decisions
fsdocs build):fsdocs converthas no mechanism to copy acontent/directory alongside the output, so the HTML would be broken by default without embedding. The "share a single file" use case is the whole point ofconvert.--embed-remoteflag could cover this.--outputformat latex,ipynb, etc.) are unaffected.Changes
src/fsdocs-tool/BuildCommand.fs: AddedConvertHelpersmodule (private) withfindContentSearchDirsandembedResourcesInHtml; modifiedConvertCommandto add--no-embed-resourcesoption and--template fsdocssentinel, with resource embedding as a post-processing step.RELEASE_NOTES.md: Added changelog entry.Test Status
fsdocs convert test.md --template fsdocsproduces a 48 KB self-contained HTML with 2 inlined(style)blocks and 8 inlined(script)blocks, no externalcontent/references remaining.Known limitations / future work
HtmlAgilityPack) would be more robust, but adds a dependency. For the types of HTML that fsdocs templates produce this should be sufficient.(img)tags in the body content (embedded in the Markdown/script) are also eligible for inlining if they reference local paths. Currently only tags in the template shell are likely to be matched; body images would need the output file directory in the search path (which is already included).--embed-remoteflag could add this.