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

i18n for typst #9829

Closed
wants to merge 5 commits into from
Closed

i18n for typst #9829

wants to merge 5 commits into from

Conversation

gordonwoodhull
Copy link
Contributor

@gordonwoodhull gordonwoodhull commented May 31, 2024

Closes #9555

Internationalization of

  • Abstract title
  • Figures
  • Theorems etc

Loose ends on this draft

@cscheid
Copy link
Collaborator

cscheid commented May 31, 2024

[ ] I don't know how to test a pandoc3 figure - where does this arise? I fixed this but didn't test it.

If you have an image with a caption but without a crossreferenceable ID, it should be a pandoc3 Figure. Something like

---
format: typst
---

![Hello]({{< placeholder >}})
image

@cscheid
Copy link
Collaborator

cscheid commented May 31, 2024

  • Similarly, what is a PanelLayout in Typst? I tried the HTML Panel Layouts ::: {layout = "[ [1,1] ]"} but no surprise that didn't work.

I believe you that it didn't work, but we do have support for it, in

return render_floatless_typst_layout(layout)

includes change to typst-template.typ which will need to be
revisited with jgm/pandoc#9724
@gordonwoodhull
Copy link
Contributor Author

gordonwoodhull commented Jun 3, 2024

Thanks @cscheid! I was able to test pandoc3 figure with

![Hello]({{< placeholder >}})

and the subfloat case case for PanelLayout with

::: {#fig-panel layout-ncol=2}

![Marcador]({{< placeholder 200 >}}){#fig-layout-a}

![Marcador]({{< placeholder 200 >}}){#fig-layout-b}

Panels

:::

IIUC the final case of make_typst_figure() in layout/typst.lua should be a PanelLayout without crossreferenceable content:

::: {#fig-panel2 layout-ncol=2}

![Marcador]({{< placeholder 200 >}})

![Marcador]({{< placeholder 200 >}})

Panels

:::

But anything I put there, I get the inscrutable error

Block, list of Blocks, or compatible element expected, got Blocks
	while retrieving function argument content
	while retrieving arguments for function Div

stack traceback:
	...c/quarto-cli/src/resources/filters/./ast/customnodes.lua:527: in local 'scaffold'
	...on/src/quarto-cli/src/resources/filters/./ast/render.lua:46: in local 'filter_fn'
	...c/quarto-cli/src/resources/filters/./ast/customnodes.lua:154: in function <...c/quarto-cli/src/resources/filters/./ast/customnodes.lua:144>
	(...tail calls...)
	[C]: in ?
	[C]: in method 'walk'
...

(I thought that Blocks was a list of Blocks!)

I tried to debug this, but the line numbers and functions in the stack trace don't quite make sense to me. Perhaps it merits a separate issue.

It renders as I would expect in HTML

image

and I think this confirms that the supplement is unused and does not need to be localized.

@cscheid
Copy link
Collaborator

cscheid commented Jun 3, 2024

(I thought that Blocks was a list of Blocks!)

This is a really bad error message from Pandoc, and it can come up in situations where a Blocks list has a non-Block element inside it. It is emitted by Pandoc in their Lua-to-Haskell marshalling code, and it's hard for us to guard against it in general :(

@gordonwoodhull
Copy link
Contributor Author

gordonwoodhull commented Jun 3, 2024

Very helpful clue. Okay, I'm opening a new issue for that one as it doesn't seem like this example has worked right since 1.5.0 but it started crashing with subfloats.

I think this is complete except for looking at the future impact of the fix and submitting a PR on Pandoc. That seems to require a different change to the template but I am not sure that I understand their i18n system yet.

@gordonwoodhull gordonwoodhull marked this pull request as ready for review June 3, 2024 18:05
@gordonwoodhull
Copy link
Contributor Author

gordonwoodhull commented Jun 3, 2024

I've pushed the fix to #9854 to this branch, since the test here triggers that.

Ok to merge? When we get a fix upstream in Pandoc we can revert to their template.

@cscheid
Copy link
Collaborator

cscheid commented Jun 3, 2024

@gordonwoodhull I don't think we should have that subfigure situation - if we're going to have supplements and numbering in that case, then they'd need to be subfloats.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

commit message is incorrect, this affects the parent title of a panel with non-cross-referenceable figures (that are nevertheless rendered as cross-referenced, with counter continuing in them)

@gordonwoodhull
Copy link
Contributor Author

Completely agree, but I think it's outside the scope of this PR. I think we have a small constellation of issues around figures without ids in Typst.

Could we merge this and I'll open another issue with the numbering problem?

@gordonwoodhull
Copy link
Contributor Author

Continued in #9857

@gordonwoodhull
Copy link
Contributor Author

Squashed and merged to main in d40b8ec, closing this.

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.

Support abstract-title for Typst format The lang field does not alter key terms in typst
2 participants