Skip to content

feat: add support for inline SVG tags#221

Draft
michalfita wants to merge 1 commit intomax-heller:mainfrom
michalfita:handling_inline_svg
Draft

feat: add support for inline SVG tags#221
michalfita wants to merge 1 commit intomax-heller:mainfrom
michalfita:handling_inline_svg

Conversation

@michalfita
Copy link

This is hackish draft of something that sends content as data URI.

The tree doesn't seem to keep slices referring to the original content for easy extraction, so the only way I find is to rebuild SVG content from the tree, but this is very hackish brutal recursive mechanism.

I'm getting incomplete image (just text and arrow tips) in the output PDF, but I'm not sure if the original SVG from svgbob is correct in that context or the rebuilding tags doesn't omit some crucial parts.

I'm really open to more suggestions here.

Fixes: #220

This is hackish draft of something that sends content as data URI.

Fixes: max-heller#220
@michalfita
Copy link
Author

I just spent 2h chasing why diagrams out of mdbook-svgbob don't have lines, and I found the culprit mentioned in boozook/mdbook-svgbob#22.

So, in result what I'm getting right now:
obraz

What leaves two more problem to solve:

  • How to deal with <div...><style>svg {...}</style><svg>...</svg></div> wrapping the stuff we inline?
  • How to align the image inside the column?

Copy link
Owner

@max-heller max-heller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to align the image inside the column?

I have yet to find a way to align images in Pandoc, see #42 (comment). Some writers support ad-hoc alignment annotations, but there's no canonical form. If we can set width/height appropriately, that might be enough to make things look reasonable.

How to deal with <div...><style>svg {...}</style><svg>...</svg></div> wrapping the stuff we inline?

  • The <div> should already be getting ignored, which seems fine, though ideally we'd copy over the width/height that mdbook-svgbob attaches to the <div> to the image itself (or maybe we could change mdbook-svgbob to add width/height to the SVG element itself?).
  • We might be able to parse that inline <style> (there's some basic CSS parsing and handling already), but it doesn't seem critical here so we should be able to strip all <style> elements from non-HTML output formats.

*<------+ PR merged
|
* v0.2.0
```
Copy link
Owner

@max-heller max-heller Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How large is the HTML source of the SVG this generates? To keep the test pipeline simple, ideally we could inline the output of mdbook-svgbob to avoid needing to run it in CI. Also, once we're happy with this test, let's make it a test similar to the others in src/tests (maybe in src/tests/images.rs).

@max-heller max-heller added the html Related to raw HTML processing label Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

html Related to raw HTML processing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for inline SVG content (in relation to mdbook-svgbob)?

2 participants