[BUG] SVG output is not compatible with most tools beyond browsers
See original GitHub issueDescribe the bug
Iโm looking at automating the conversion of richโs SVG output to PNG for documentation purposes, but it appears that the full compatibly of these SVGs is currently limited to chromium-based browsers.
Iโll take the following test file as example (generate with rich 12.1.0):
Here is how it is displayed with macOS Finderโs Quicklook (missing background):

In Safari:

Inkscape:

Trying to convert to PNG using Inkscapeโs CLI yields the following errors:
end_font_face_cb: font face rule limited support.
font-family : 'Fira Code';
src : local('FiraCode-Regular'), url(https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Regular.woff2) format('woff2'), url(https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Regular.woff) format('woff');
font-style : normal;
font-weight : 400
end_font_face_cb: font face rule limited support.
font-family : 'Fira Code';
src : local('FiraCode-Bold'), url(https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Bold.woff2) format('woff2'), url(https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Bold.woff) format('woff');
font-style : bold;
font-weight : 700
WARNING: unknown type: svg:foreignObject
Background RRGGBBAA: ffffff00
Similarly, CLI tools like rsvp-convert
or ImageMagickโs convert
completely fail to produce a useable output. The best I could get is from qlmanage
(related to macOS QuickLook โ I learned about it today), but still unusable:
Platform
Click to expand
macOS 12.3 Rich 12.1.0
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ <class 'rich.console.Console'> โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ A high level console interface. โ
โ โ
โ โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ
โ โ <console width=284 None> โ โ
โ โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ โ
โ โ
โ color_system = None โ
โ encoding = 'utf-8' โ
โ file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> โ
โ height = 13 โ
โ is_alt_screen = False โ
โ is_dumb_terminal = False โ
โ is_interactive = False โ
โ is_jupyter = False โ
โ is_terminal = False โ
โ legacy_windows = False โ
โ no_color = False โ
โ options = ConsoleOptions(size=ConsoleDimensions(width=284, height=13), legacy_windows=False, min_width=1, max_width=284, is_terminal=False, encoding='utf-8', max_height=13, justify=None, overflow=None, no_wrap=False, highlight=None, markup=None, height=None) โ
โ quiet = False โ
โ record = False โ
โ safe_box = True โ
โ size = ConsoleDimensions(width=284, height=13) โ
โ soft_wrap = False โ
โ stderr = False โ
โ style = None โ
โ tab_size = 8 โ
โ width = 284 โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโโโ <class 'rich._windows.WindowsConsoleFeatures'> โโโโโฎ
โ Windows features available. โ
โ โ
โ โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ โ
โ โ WindowsConsoleFeatures(vt=False, truecolor=False) โ โ
โ โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ โ
โ โ
โ truecolor = False โ
โ vt = False โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Environment Variables โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ {'TERM': 'xterm-256color', 'COLORTERM': None, 'CLICOLOR': None, 'NO_COLOR': None, 'TERM_PROGRAM': None, 'COLUMNS': None, 'LINES': None, 'JPY_PARENT_PID': None, 'VSCODE_VERBOSE_LOGGING': None} โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
platform="Darwin"
Issue Analytics
- State:
- Created a year ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Inkscape "Viewer does not support full SVG 1.1"
I have run into a bug in a diagram created on diagrams.net. When the file is opened in Inkscape, text is truncated and...
Read more >A Practical Guide To SVG And Design Tools
In this article, I'll shed light on three of the most popular design tools: Adobe Illustrator, Sketch, and Figma. There are also other...
Read more >How To Import & Export SVG, PDG, DXF Files & Vectors in ...
This tutorial explains exactly how to import and export SVG, DXF and PDF files in Vactric Vcarve desktop, pro and Aspire.
Read more >Accessible SVGs | CSS-Tricks
Browsers that support SVG: IE 10+, FF, Chrome and Safari; Most common ... a description โ note this is not read by narrator...
Read more >4. Tools of the Trade - Using SVG with CSS3 and HTML5 [Book]
Many aspects of SVG were inspired by the capabilities of Illustrator, and Illustrator has long supported export of its graphics to SVG format....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For my project fastero, in order to convert the output to PNG, I used selenium to open the SVG file and take a screenshot then use PIL to crop it. This was the only method I could think of that actually worked, Iโve tried a lot of methods too, the one I used is definitely not optimal. But it does create some beautiful output (with custom CSS of course)
<figure class="image">Although this does take around 4-5 seconds, but I think itโs worth it
The alternatives I tried are, Inkscape, svglib, cairosvg and some other library I forgot the name of
Should be fixed in the last release