Repository navigation
Pandoc filter shim: generated fast path, launch-failure handling, size-limit scale hint - #153
Conversation
…ze-limit scale hint - The shim's fast path starts the tool only for a code block of a class the engine draws (mermaid) or a local picture whose name ends in a suffix the engine may change (.svg .vl.json .vl .scad .vsdx .pptx .pdf .mmd .mermaid). --write-shim fills both lists into the embedded template from PictureAttributes.BlockClasses and PictureSuffixes, so the shim cannot drift from the tool; docs/filters/canvasnet.lua is regenerated. - The shim treats a pandoc.pipe error as a process failure only when it is a table with a numeric error_code, reads its fields in protected mode, and reports every other error as "cannot run the canvasnet tool" with tostring. - A size-limit error of a size that follows the natural size names the scale that fits; the Pandoc filter names the block's or picture's scale attribute. - Tests: engine pass-through of pictures it does not draw, the registry, the generated shim, FitScale, the filter's size hint (stub and real drawer), and test-canvasnet.ps1 checks for the fast path and stubbed pandoc.pipe errors. - Requirements, design, verification, user guide, help card, and SysML model updated; the shim should be written again after updating the tool. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Active issues remain, including an incorrect two-significant-digit rounding implementation, a nondeterministic wall-clock regex timeout in a test, and an incomplete XML documentation sentence.
3 open issues
What changed in this PR
This PR improves the Pandoc filter shim and rendering diagnostics by generating fast-path registries from the engine, hardening launch-failure handling, and providing actionable scale hints for oversized images.
Changes:
- Generate Lua class and suffix tables from shared engine registries.
- Normalize tool-launch and malformed-output failures into clear shim errors.
- Add fit-scale metadata, Pandoc hints, tests, and synchronized documentation.
| File | Description |
|---|---|
| test/DemaConsulting.CanvasNet.Viewer.Tests/Imaging/SourceLoaderTests.cs | Tests fit-scale hints, exception metadata, and rounding behavior. |
| test/DemaConsulting.CanvasNet.Tool.Tests/PandocFilter/PictureAttributesTests.cs | Verifies shared picture suffix and block-class registries. |
| test/DemaConsulting.CanvasNet.Tool.Tests/PandocFilter/PandocFilterSubsystemTests.cs | Tests oversized Mermaid scale guidance. |
| test/DemaConsulting.CanvasNet.Tool.Tests/PandocFilter/PandocFilterShimTests.cs | Tests shim template generation and generated fast-path contents. |
| test/DemaConsulting.CanvasNet.Tool.Tests/PandocFilter/PandocFilterEngineTests.cs | Tests pass-through behavior and scale-attribute hints. |
| src/DemaConsulting.CanvasNet.Viewer/Imaging/SourceLoader.cs | Adds fit-scale calculation and size-limit exception metadata. |
| src/DemaConsulting.CanvasNet.Tool/PandocFilter/PictureAttributes.cs | Defines shared picture suffix and block-class registries. |
| src/DemaConsulting.CanvasNet.Tool/PandocFilter/PandocFilterShim.cs | Generates the Lua shim from its template and engine registries. |
| src/DemaConsulting.CanvasNet.Tool/PandocFilter/PandocFilterEngine.Drawing.cs | Converts fit-scale metadata into Pandoc attribute hints. |
| src/DemaConsulting.CanvasNet.Tool/PandocFilter/PandocFilterEngine.cs | Uses shared block classification and tracks block jobs. |
| src/DemaConsulting.CanvasNet.Tool/PandocFilter/canvasnet.lua | Implements generated fast-path checks and protected launch-failure handling. |
| src/DemaConsulting.CanvasNet.Tool/DemaConsulting.CanvasNet.Tool.csproj | Documents the embedded Lua file as a generated template. |
| src/DemaConsulting.CanvasNet.Tool/Commands/PandocFilterCommand.cs | Updates command guidance for regenerating the shim. |
| src/DemaConsulting.CanvasNet.Tool/Commands/Help/pandoc.md | Documents fast-path behavior and size-limit hints. |
| docs/verification/canvas-net-viewer/imaging/source-loader.md | Records fit-scale verification scenarios. |
| docs/verification/canvas-net-tool/pandoc-filter/picture-attributes.md | Records registry verification coverage. |
| docs/verification/canvas-net-tool/pandoc-filter/pandoc-filter-shim.md | Records generated-shim and launch-failure verification. |
| docs/verification/canvas-net-tool/pandoc-filter/pandoc-filter-engine.md | Records pass-through and scale-hint verification. |
| docs/verification/canvas-net-tool/pandoc-filter.md | Records oversized Mermaid integration verification. |
| docs/user_guide/canvas-net-tool.md | Updates user-facing shim and size-limit guidance. |
| docs/sysml2/model/canvas-net-tool/pandoc-filter/picture-attributes.sysml | Updates the model for shared registries. |
| docs/sysml2/model/canvas-net-tool/pandoc-filter/pandoc-filter-shim.sysml | Updates the model for generated shims and failure handling. |
| docs/reqstream/canvas-net-viewer/imaging/source-loader.yaml | Adds fit-scale requirements and test traceability. |
| docs/reqstream/canvas-net-tool/pandoc-filter/picture-attributes.yaml | Adds registry requirements. |
| docs/reqstream/canvas-net-tool/pandoc-filter/pandoc-filter-shim.yaml | Adds generated fast-path requirements. |
| docs/reqstream/canvas-net-tool/pandoc-filter/pandoc-filter-engine.yaml | Adds oversized-picture and pass-through requirements. |
| docs/reqstream/canvas-net-tool/pandoc-filter.yaml | Integrates the updated Pandoc filter requirements. |
| docs/filters/test-canvasnet.ps1 | Expands end-to-end coverage for fast paths and launch failures. |
| docs/filters/canvasnet.lua | Stores the regenerated repository Lua shim. |
| docs/design/canvas-net-viewer/imaging/source-loader.md | Documents fit-scale calculation and exception metadata. |
| docs/design/canvas-net-tool/pandoc-filter/picture-attributes.md | Documents shared suffix and block-class registries. |
| docs/design/canvas-net-tool/pandoc-filter/pandoc-filter-shim.md | Documents template generation and failure handling. |
| docs/design/canvas-net-tool/pandoc-filter/pandoc-filter-engine.md | Documents block classification and scale-specific hints. |
| docs/design/canvas-net-tool/pandoc-filter.md | Updates the filter fast-path design documentation. |
| docs/design/canvas-net-tool/commands/pandoc-filter-command.md | Documents writing the generated shim. |
Review effort: Lite
…o regex timeout in test, doc grammar Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Defer approval because the change spans generated Lua, Pandoc execution, in-process rendering, and Viewer exception propagation, requiring human and runtime validation of embedded-image failures and Pandoc integration.
No open issues 🎉
3 resolved since last review
Review effort: Lite
There was a problem hiding this comment.
🔵 Needs a closer look
The change spans generated Lua, Pandoc’s pipe/error ABI, the tool engine, and Viewer exception metadata, requiring maintainer verification of real Pandoc behavior and the claimed end-to-end run after the mixed sizing-option hint correction.
No open issues 🎉
Review effort: Lite


Pull Request
Description
Fixes from the Pandoc filter rollout feedback (the handoff after 0.2.0-beta.11).
canvasnet.luatemplate has@CLASSES@and@SUFFIXES@placeholders that--write-shimfills from the engine's own tables:mermaid(case-sensitive, as the engine matches them);.svg .vl.json .vl .scad .vsdx .pptx .pdf .mmd .mermaid(case-insensitive).So a document with no CanvasNet pictures never starts the tool, and the shim cannot drift from the engine.
canvasnet.lua:message that says what went wrong, instead of a Lua error from inside the shim. The e2e script tests seven failure shapes through a stubbedpandoc.piperun bydotnet pandoc lua.0.56). The Viewer passes the scale to the tool through the exception'sDataentryDemaConsulting.CanvasNet.Viewer.FitScale.The filter protocol stays at 1, so shims already written keep working. The docs and
canvasnet help pandocsay to regenerate the shim (dotnet canvasnet pandoc-filter --write-shim docs/filters/canvasnet.lua) after updating the tool, to pick up the generated fast path.Type of Change
Related Issues
Follow-up to #146.
Pre-Submission Checklist
Before submitting this pull request, ensure you have completed the following:
Build and Test
pwsh ./build.ps1(passed, 0 failures)Code Quality
Quality Checks
Please run the following checks before submitting:
pwsh ./lint.ps1(passed)Testing
Documentation
Additional Notes
docs/filters/test-canvasnet.ps1(the end-to-end filter checks) passed all 124 checks.docs/filters/canvasnet.luais regenerated from the new template, and the existing test keeps it byte-identical to the embedded copy.