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

Handle long content in callout when format is typst #12179

Open
benabel opened this issue Feb 28, 2025 · 9 comments
Open

Handle long content in callout when format is typst #12179

benabel opened this issue Feb 28, 2025 · 9 comments
Assignees
Labels
bug Something isn't working callouts Issues with Callout Blocks. triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone. typst

Comments

@benabel
Copy link

benabel commented Feb 28, 2025

Bug description

callout doesn't handle correctly long content in typst.

Steps to reproduce

---
title: "Long calloutt"
format: typst
---


::: {.callout-note}

{{< lipsum 7 >}}

:::

Actual behavior

callout overflow on the page it is created.

Expected behavior

Long callout should break pages like code blocks...

Your environment

No response

Quarto check output

Quarto 1.7.13
[✓] Checking environment information...
      Quarto cache location: /home/ben/.cache/quarto
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.4.0: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.46.3: OK
      Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.7.13
      Path: /opt/quarto/bin

[✓] Checking tools....................OK
      TinyTeX: (not installed)
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Using: Installation From Path
      Path: /usr/bin
      Version: undefined

[✓] Checking Chrome Headless....................OK
      Chrome:  (not detected)

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.13.2
      Path: /usr/bin/python3
      Jupyter: (None)

      Jupyter is not available in this Python installation.
      Install with python3 -m pip install jupyter

      There is an unactivated Python environment in .venv. Did you forget to activate it?

[✓] Checking R installation...........(None)

      Unable to locate an installed version of R.
      Install R from https://cloud.r-project.org/
@benabel benabel added the bug Something isn't working label Feb 28, 2025
@mcanouil
Copy link
Collaborator

That's the same issue as with LaTeX.

In my opinion, I really don't believe callouts should contain such contents.

@mcanouil
Copy link
Collaborator

mcanouil commented Feb 28, 2025

FYI, this is done on purpose as "breakable" default in Typst is "true".

@mcanouil mcanouil added callouts Issues with Callout Blocks. typst labels Feb 28, 2025
@cderv
Copy link
Collaborator

cderv commented Feb 28, 2025

This was added in a0a7b4a for crossref callouts, so pinging @cscheid to see if this could be changed, or made configurable by the user (if user knows that the callout will be long and need to break.

Changing to true give this by the way

Image

@cderv cderv added the triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone. label Feb 28, 2025
@benabel
Copy link
Author

benabel commented Feb 28, 2025

Ok, it's really clear now, setting breakable to false seems reasonable, I agree with all that have been said.

In my use case I was using quarto.Callout to create custom callouts in a lua filter as described in #844. At the moment, I need to hard code my typst block element, maybe the breakable keyword could be passed by quarto the underlying typst code, at the moment this do not work.

return quarto.Callout({
            breakable = true,
            type = "tip",
            content = {div},
            title = "Correction",
            collapse = false,
            icon = true,
            appearance = 'simple'
        })

Is it worth adding this as it will not be used by all formats.

@mcanouil
Copy link
Collaborator

I don't think, the "quarto" Lua API should become specific towards one format.

@benabel
Copy link
Author

benabel commented Feb 28, 2025

Ok, thanks for your time and reflexions, I ended redefinig the typst callout function in my typst-template.typ.

// breakable callout see https://github.com/quarto-dev/quarto-cli/issues/12179
// callout typst code from https://github.com/quarto-dev/quarto-cli/blob/93ac52d00d94f01993d86bc75340451b00fee4ff/src/resources/formats/typst/pandoc/quarto/definitions.typ#L150
#let callout(body: [], title: "Callout", background_color: rgb("#dddddd"), icon: none, icon_color: black) = {
  block(
    breakable: true, 
    fill: background_color, 
    stroke: (paint: icon_color, thickness: 0.5pt, cap: "round"), 
    width: 100%, 
    radius: 2pt,
    block(
      inset: 1pt,
      width: 100%, 
      below: 0pt, 
      block(
        fill: background_color, 
        width: 100%, 
        inset: 8pt)[#text(icon_color, weight: 900)[#icon] #title]) +
      if(body != []){
        block(
          inset: 1pt, 
          width: 100%, 
          block(fill: white, width: 100%, inset: 8pt, body))
      }
    )
}

@benabel
Copy link
Author

benabel commented Feb 28, 2025

This issue was disturbing me for years now. It is ok for me now, do you want that I close the issue?

@mcanouil
Copy link
Collaborator

Let's wait for Carlos.

@cscheid
Copy link
Collaborator

cscheid commented Feb 28, 2025

I don't think, the "quarto" Lua API should become specific towards one format.

I agree with the sentiment and the principle. At the same time, Quarto callouts already have different behaviors in different formats, so this wouldn't be a big additional violation of the principle.

With that said, I'm not sure (or I no longer remember) how breakable: true interacts with crossrefs, and that would be a problem. We need more substantial testing here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working callouts Issues with Callout Blocks. triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone. typst
Projects
None yet
Development

No branches or pull requests

4 participants