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

typst output doesn't process links from gt #11932

Open
arthurgailes opened this issue Jan 22, 2025 · 7 comments
Open

typst output doesn't process links from gt #11932

arthurgailes opened this issue Jan 22, 2025 · 7 comments
Assignees
Labels
bug Something isn't working tables Issues with Tables including the gt integration upstream Bug is in upstream library
Milestone

Comments

@arthurgailes
Copy link

Bug description

The link below works in the gt via RStudio, but typst somehow ignores the markdown output. Thanks for you time.

Steps to reproduce

---
format: typst
---

## Quarto

Works great in GT, typst says no

```{r}
library(gt)

gt(gtcars[1:5,]) |> 
  tab_source_note(md("[google](google.com)"))
```

But it could say yes! [google](google.com)

Expected behavior

No response

Actual behavior

No response

Your environment

Windows Server 2016

Quarto check output

Quarto 1.6.40

@arthurgailes arthurgailes added the bug Something isn't working label Jan 22, 2025
@mcanouil
Copy link
Collaborator

mcanouil commented Jan 22, 2025

To be clear, gt does not emit Markdown, it emits HTML.
Use keep-md: true to see the intermediate Markdown document that is processed to Typst.

I don't know where the issue lies, but Quarto succeeds in parsing HTML tables with links, but not from your example.

CC @rich-iannone @cscheid

InputOutput
---
format: typst
---

```{=html}
<table border="1">
  <thead>
    <tr>
      <th>Header 1</th>
      <th>Header 2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Row 1, Cell 1</td>
      <td>Row 1, Cell 2</td>
    </tr>
    <tr>
      <td>Row 2, Cell 1</td>
      <td>Row 2, Cell 2</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <td colspan="2">
        <a href="https://quarto.org">Visit Quarto</a>
      </td>
    </tr>
  </tfoot>
</table>
```
Image
Code
---
format: typst
---

Mimicking `gt`

```{=html}
---
format: typst
---

```{=html}
<table border="1">
  <thead>
    <tr>
      <th>Header 1</th>
      <th>Header 2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Row 1, Cell 1</td>
      <td>Row 1, Cell 2</td>
    </tr>
    <tr>
      <td>Row 2, Cell 1</td>
      <td>Row 2, Cell 2</td>
    </tr>
  </tbody>
  <tfoot class="gt_sourcenotes">
    <tr>
      <td class="gt_sourcenote" colspan="15"><span data-qmd-base64="PGEgaHJlZj0iZ29vZ2xlLmNvbSI+Z29vZ2xlPC9hPg=="><span class='gt_from_md'><a href="google.com">google</a></span></span></td>
    </tr>
  </tfoot>
</table>
```
Image

@mcanouil mcanouil added the tables Issues with Tables including the gt integration label Jan 22, 2025
@gordonwoodhull
Copy link
Contributor

gordonwoodhull commented Jan 22, 2025

Will look, since this is going through Quarto’s Typst-specific html table processing

@gordonwoodhull gordonwoodhull self-assigned this Jan 22, 2025
@mcanouil
Copy link
Collaborator

Oh, I thought it was going through HTML > AST > Typst.

@mcanouil
Copy link
Collaborator

mcanouil commented Jan 22, 2025

Note that the processing issue is not specific to Typst, also why I thought of the HTML table parsing to AST (or maybe a gt issue).
Sorry, to not have make this clearer.

InputOutput
Code
---
format: pdf
---

Mimicking `gt`

```{=html}
<table border="1">
  <thead>
    <tr>
      <th>Header 1</th>
      <th>Header 2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Row 1, Cell 1</td>
      <td>Row 1, Cell 2</td>
    </tr>
    <tr>
      <td>Row 2, Cell 1</td>
      <td>Row 2, Cell 2</td>
    </tr>
  </tbody>
  <tfoot class="gt_sourcenotes">
    <tr>
      <td class="gt_sourcenote" colspan="15"><span data-qmd-base64="PGEgaHJlZj0iZ29vZ2xlLmNvbSI+Z29vZ2xlPC9hPg=="><span class='gt_from_md'><a href="google.com">google</a></span></span></td>
    </tr>
  </tfoot>
</table>
```

```{=html}
<table border="1">
  <thead>
    <tr>
      <th>Header 1</th>
      <th>Header 2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Row 1, Cell 1</td>
      <td>Row 1, Cell 2</td>
    </tr>
    <tr>
      <td>Row 2, Cell 1</td>
      <td>Row 2, Cell 2</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <td colspan="2">
        <a href="https://quarto.org">Visit Quarto</a>
      </td>
    </tr>
  </tfoot>
</table>
```
Image

@gordonwoodhull gordonwoodhull removed their assignment Jan 22, 2025
@cderv
Copy link
Collaborator

cderv commented Jan 23, 2025

I believe it is gt issue. The encoded part in data-qmd-base64 is HTML content and not markdown content

> rawToChar(base64enc::base64decode("PGEgaHJlZj0iZ29vZ2xlLmNvbSI+Z29vZ2xlPC9hPg=="))
[1] "<a href=\"google.com\">google</a>"

It should be [google](google.com) so that Quarto renders it to the right format through pandoc.

This is a gt issue.

@cderv
Copy link
Collaborator

cderv commented Jan 23, 2025

And I think this is the same as what I found in there

gt is applying some markdown conversion before passing it to quarto (rstudio/gt@31c1632/R/quarto.R#L33-L41 (blame)). This seems not right, because then markdown seems to be converted to HTML before being encoded for quarto.

@cderv cderv added the upstream Bug is in upstream library label Jan 23, 2025
@cderv cderv added this to the Future milestone Jan 23, 2025
@gordonwoodhull
Copy link
Contributor

gordonwoodhull commented Jan 23, 2025

Oh, I thought it was going through HTML > AST > Typst.

For Typst only, it's HTML > juice html > AST > Typst, which is why I always get concerned when gt-Typst issues come up. (But I should test first.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tables Issues with Tables including the gt integration upstream Bug is in upstream library
Projects
None yet
Development

No branches or pull requests

5 participants