Skip to content

Forward pretty format option to nested SVG frames - #8535

Merged
laurmaedje merged 1 commit into
mainfrom
pretty-nested-svg
Jun 30, 2026
Merged

laurmaedje merged 1 commit into
mainfrom
pretty-nested-svg

Conversation

@saecki

@saecki saecki commented Jun 19, 2026

Copy link
Copy Markdown
Member

This passes the pretty parameter of HTML to nested SVG elements, which seems expected.
Before the nested SVGs were always minimized, which was an oversight in #8371.

@saecki saecki changed the title Forward pretty format option to nested SVGs Forward pretty format option to nested SVG frames Jun 19, 2026
@T0mstone

T0mstone commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

This doesn't preserve indentation.
For example,

#html.frame(circle())

compiles to

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
  </head>
  <body>
    <svg style="overflow: visible; width: 2.727272727em; height: 2.727272727em; display: block" viewBox="0 0 30 30" width="30pt" height="30pt" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:h5="http://www.w3.org/1999/xhtml">
  <path fill="none" stroke="#000000" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="4" d="M 0 0m 0 15c 0 -8.27676 6.72324 -15 15 -15c 8.27676 0 15 6.72324 15 15c 0 8.27676 -6.72324 15 -15 15c -8.27676 0 -15 -6.72324 -15 -15"/>
</svg>

  </body>
</html>

Still, I prefer this to a minimized SVG👍

@laurmaedje

Copy link
Copy Markdown
Member

Adding the additional necessary indent for each line on the HTML export side shouldn't be too hard, right?

@laurmaedje laurmaedje added the waiting-on-author Pull request waits on author label Jun 30, 2026
@saecki

saecki commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

Adding the additional necessary indent for each line on the HTML export side shouldn't be too hard, right?

No, that's what I thought too. Keeping this on the HTML side, would also keep caching of the frame intact.
IIRC this is already done for raw text.

@saecki
saecki force-pushed the pretty-nested-svg branch from 7a00602 to d7f8a14 Compare June 30, 2026 10:08
Comment thread crates/typst-html/src/encode.rs Resolved
@saecki
saecki force-pushed the pretty-nested-svg branch from d7f8a14 to 88ef501 Compare June 30, 2026 11:10
@laurmaedje
laurmaedje added this pull request to the merge queue Jun 30, 2026
@laurmaedje laurmaedje removed the waiting-on-author Pull request waits on author label Jun 30, 2026
Merged via the queue into main with commit f88aba5 Jun 30, 2026
18 checks passed
@laurmaedje
laurmaedje deleted the pretty-nested-svg branch June 30, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix A bug fix. html Related to HTML export

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants