Skip to content

Conversation

@cderv
Copy link
Collaborator

@cderv cderv commented Nov 18, 2025

This closes #13661

Looking into how mermaid-format: svg currently work for various format leads to this PR:

  • Adding some testing
  • Move some tests that were wrong because of side effect prevent. Especially rsvg-convert logic needs rsvg-convert tool.
  • Some bug fixes in Lua handling
  • Some warning addition as setting mermaid-format: svg in other context that HTML rendering is prone to problem (especially in LaTeX / Beamer)
  • It also fixes the issue of <script> tag being included always even when we decided to load the .svg with <img> tag. Probably we'll need to revisit mermaid-format: svg results in clipping of diagrams #1622 and maybe use mermaid-cli to create the PNG or SVG file.

cderv added 11 commits November 12, 2025 18:17
Test expects SVG files to be used directly via \includesvg
without HTML script tags in LaTeX output.

This test should fail initially because setupMermaidSvgJsRuntime()
adds script tags that break LaTeX compilation.
The warning was shown for all non-JavaScript formats (PDF, LaTeX, Beamer, DOCX, Typst), but only PDF/LaTeX/Beamer require external tooling (rsvg-convert or Inkscape). DOCX and Typst handle SVG natively.

Changed mermaid.ts to use isLatexOutput() instead of !isJavascriptCompatible().
SVG format without JavaScript postprocessing may have text clipping issues with multi-line labels. LaTeX-based formats additionally require external tooling (rsvg-convert or Inkscape).

Updated mermaid.ts to emit comprehensive warnings for non-JavaScript formats.

Test coverage:
- LaTeX test verifies both clipping + tooling warnings
- DOCX test verifies clipping warning only
- Manual testing checklist for full validation
and add mention of limitations
Migrates SVG to PDF conversion tests from smoke-all to smoke tests with conditional execution based on rsvg-convert availability.

Old smoke-all tests couldn't conditionally test based on tool availability or verify proper error messages.

New test structure:
- Test 1: With rsvg-convert - verifies successful SVG→PDF conversion
- Test 2: Without rsvg-convert, with pre-converted PDF - uses existing PDF, verifies warning message
- Test 3: Without rsvg-convert, no PDF - verifies warning and LaTeX \includesvg usage

Uses which('rsvg-convert')  to conditionally run tests based on tool availability.
@cderv cderv changed the title Several mermaid-format:svg improvement Several mermaid-format: svg edge-cases improvement Nov 18, 2025
@posit-snyk-bot
Copy link
Collaborator

posit-snyk-bot commented Nov 18, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

- Add skip-on-os metadata field (string or array of OS names)
- Rename skipTestOnCi() to skipTest() for broader scope
- Skip mermaid SVG tests on Linux (Puppeteer/Chrome environment issue)

Tests skipped on Linux (all timeout after 10 minutes):
- tests/docs/smoke-all/2025/11/10/13661.qmd (LaTeX)
- tests/docs/smoke-all/2025/11/14/mermaid-svg-docx.qmd (DOCX)
- tests/docs/smoke-all/2025/11/18/mermaid-gfm-svg.qmd (GFM)

These tests pass on Windows. Linux support will be tracked in a
separate issue to investigate Puppeteer/headless Chrome setup.
Eliminates duplicate metadata retrieval by having skipTest() return
the skip reason (string) instead of boolean. Cleaner and more efficient.
Follows codebase pattern for OS detection.
Replaces separate string/array handling with asArray helper.
Adds documentation for the new skip-on-os metadata field that allows
skipping smoke-all tests on specific operating systems.
@cderv
Copy link
Collaborator Author

cderv commented Nov 18, 2025

OS-Specific Test Filtering Added

Added skip-on-os metadata field to handle Linux CI test failures with mermaid-format: svg (Puppeteer/Chrome timeouts).

What was added:

  • 5 commits implementing OS-specific test filtering for smoke-all tests
  • skip-on-os metadata field (string or array): skip-on-os: linux
  • Documentation in tests/README.md

Tests skipped on Linux:

  • tests/docs/smoke-all/2025/11/10/13661.qmd (LaTeX)
  • tests/docs/smoke-all/2025/11/14/mermaid-svg-docx.qmd (DOCX)
  • tests/docs/smoke-all/2025/11/18/mermaid-gfm-svg.qmd (GFM)

All tests pass on Windows. Linux support tracked in #13704.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mermaid-format:svg errors with Beamer target

3 participants