Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: typst fig align code cell #8991

Closed
wants to merge 8 commits into from

Conversation

gordonwoodhull
Copy link
Contributor

@cscheid, here is a proposed solution for Typst fig-align (#8767) for discussion at our meeting today.

It simply marks .cell > .cell-output-display as .quarto-scaffold, maybe too broad:

  • There's a good chance this will "accidentally" fix Centered tables from code using typst #8797, will test now
  • What happens if there are multiple plot outputs? Existing code skips that case but I think expectation is that fig-align should be applied to all. (I'll check that as well.)

Note we can't directly test if alignment is working, we can only test if extra blocks surround the #align().

Another possible fix can be made in post-processing, messier but more focused. See alternate branch here:
https://github.com/quarto-dev/quarto-cli/compare/fix/typst-fig-align-code-cell-in-post?expand=1

@gordonwoodhull gordonwoodhull changed the title Fix/typst fig align code cell WIP: typst fig align code cell Mar 6, 2024
@gordonwoodhull gordonwoodhull marked this pull request as draft March 6, 2024 14:09
@cscheid
Copy link
Collaborator

cscheid commented Mar 6, 2024

Great! It looks like some of the tests are failing because of different whitespace handling on windows?

@gordonwoodhull
Copy link
Contributor Author

Interesting.. I'll see if \s* works instead of \n

@gordonwoodhull
Copy link
Contributor Author

Yep, it also works for tables #8797 if I broaden the selector:

-            local cod = quarto.utils.match(".cell/[1]/.cell-output-display")(div)
+            local cod = quarto.utils.match(".cell/:child/.cell-output-display")(div)

But it's confusing to have an expected alignment for tables but no way to control table alignment (as discussed there), so I'm not sure if that's a good enough solution.

@cderv
Copy link
Collaborator

cderv commented Mar 6, 2024

For the newline, I see we are using also (\r\n?|\n) (3452940)

_quarto:
tests:
asciidoc:
ensureFileRegexMatches:
-
- '\[NOTE\](\r\n?|\n).Bruv(\r\n?|\n)===='
- '\[TIP\](\r\n?|\n)===='

I found that to cover what I found on the web

Linux uses \n for a new-line, Windows \r\n and old Macs \r

\s is spaces, tabs and new lines so it works also. More broad though as it covers spaces and tabs.

@gordonwoodhull
Copy link
Contributor Author

Thanks @cderv, that’s the universal newline and most precise.

@gordonwoodhull
Copy link
Contributor Author

Superceded by #9052

@cderv
Copy link
Collaborator

cderv commented Mar 28, 2024

Thanks for closing. Can we delete the branch fix/typst-fig-align-code-cell in the repo then ?

just asking for keep branch numbers in remotes cleaned

@gordonwoodhull gordonwoodhull deleted the fix/typst-fig-align-code-cell branch March 28, 2024 17:17
@gordonwoodhull
Copy link
Contributor Author

Thanks @cderv, deleted this and a bunch of other temporary branches I had.

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.

Centered tables from code using typst
3 participants