quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.59k stars 295 forks source link

Quarto into Confluence : Problem MERMAID #6363

Open ledemocrate opened 11 months ago

ledemocrate commented 11 months ago

Bug description

Quarto has native support for embedding Mermaid and Graphviz diagrams. This enables you to create flowcharts, sequence diagrams, state diagrams, gantt charts, and more using a plain text syntax inspired by markdown. It works very good, but no when it published into Confluence

Steps to reproduce

  1. Make a quarto document with a diagram mermaid into :

    ```{mermaid}
    erDiagram
    COLLAB ||--|{ DEPUTE : rattachement 
    COLLAB {
        integer collab_code PK "sequence incremental pour chaque depute_code"
        string depute_code PK "id du fichier collaborateur" 
        string nom_collab  "nom_collab du fichier collaborateur avec MAJUSCULE & TRIM" 
        string prenom_collab  "prenom_collab du fichier collaborateur avec MAJUSCULE & TRIM"
        string intitule_collab "nom_collab + prenom_collab du fichier collaborateur avec MAJUSCULE & TRIM"
    }
    DEPUTE }o--|{ VOTE : vote
    DEPUTE {
       string depute_code PK "id du fichier deputes"
       string nom_depute  "nom du fichier depute avec MAJUSCULE & TRIM"
       string prenom_depute  "prenom du depute collaborateur avec MAJUSCULE & TRIM"
       string intitule_depute  "prenom du fichier depute avec MAJUSCULE & TRIM"
       string groupe_politique  "prenom du fichier depute avec MAJUSCULE & TRIM"
    
    }
    VOTE {
      string depute_code PK "champ depute_code des fichiers de *.json"
      string loi_code PK "nom du fichier du fichier de vote"
      integer vote_code "champ construit dans le job READ_DATA_VOTE"
    }
  2. Run a preview to see that worked : quarto preview confluence-demo-mermaid.qmd
  3. Run a publishing into Confluence Cloud : quarto publish confluence confluence-demo-mermaid.qmd

Expected behavior

Actual behavior

 Updating content at https://daka-team.atlassian.net/wiki/spaces/DKTBUILDIN/pages/3700752482...
ERROR: API Error: 400 - Bad Request

Stack trace:
    at ConfluenceClient.handleResponse (file:///C:/Users/Quentin%20GOLLENTZ/AppData/Local/Programs/Quarto/bin/quarto.js:102331:19)
    at ConfluenceClient.fetch (file:///C:/Users/Quentin%20GOLLENTZ/AppData/Local/Programs/Quarto/bin/quarto.js:102136:25)
    at eventLoopTick (ext:core/01_core.js:181:11)
    at async ConfluenceClient.updateContent (file:///C:/Users/Quentin%20GOLLENTZ/AppData/Local/Programs/Quarto/bin/quarto.js:102269:25)
    at async updateContent (file:///C:/Users/Quentin%20GOLLENTZ/AppData/Local/Programs/Quarto/bin/quarto.js:102596:32)
    at async doOperation (file:///C:/Users/Quentin%20GOLLENTZ/AppData/Local/Programs/Quarto/bin/quarto.js:102703:47)
    at async withSpinner (file:///C:/Users/Quentin%20GOLLENTZ/AppData/Local/Programs/Quarto/bin/quarto.js:38760:16)
    at async doWithSpinner (file:///C:/Users/Quentin%20GOLLENTZ/AppData/Local/Programs/Quarto/bin/quarto.js:101684:12)
    at async publishDocument (file:///C:/Users/Quentin%20GOLLENTZ/AppData/Local/Programs/Quarto/bin/quarto.js:102709:13)
    at async Object.publish4 [as publish] (file:///C:/Users/Quentin%20GOLLENTZ/AppData/Local/Programs/Quarto/bin/quarto.js:102837:16)

Your environment

- OS : Windows 11
- R : 4.1.2
- Quarto : 1.4.266
- Knitr : 1.43
- Rmarkdon : 2.23

### Quarto check output

[>] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.6: OK
      Dart Sass version 1.55.0: OK
      Deno version 1.33.4: OK
[>] Checking versions of quarto dependencies......OK
[>] Checking Quarto installation......OK
      Version: 1.4.266
      Path: C:\Users\Quentin GOLLENTZ\AppData\Local\Programs\Quarto\bin
      CodePage: 1252

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

[>] Checking Python 3 installation....(None)

      Unable to locate an installed version of Python 3.
      Install Python 3 from https://www.python.org/downloads/

[>] Checking R installation...........OK
      Version: 4.1.2
      Path: C:/PROGRA~1/R/R-41~1.2
      LibPaths:
        - C:/Users/Quentin GOLLENTZ/Documents/R/win-library/4.1
        - C:/Program Files/R/R-4.1.2/library
      knitr: 1.43
      rmarkdown: 2.23

[>] Checking Knitr engine render......OK
ledemocrate commented 11 months ago

If the bug isn't clear, please let me know. The problem is : "I can't publish Quarto Document into Confluence if Quarto include Mermaid diagram"

cderv commented 11 months ago

Thank I can reproduce by

Thanks for the report

cderv commented 11 months ago

OK what I have found so far is that we are trying to update the image this way

<p><ac:image
    ac:align="center"
    ac:layout="center"
    ac:width="5.77in"
    ac:height="6.23in"
    ac:alt="">
        <ri:attachment ri:filename="mermaid-figure-1.png" />
    </ac:image></p>

And it seems ac:width and ac:height are causing the issue when using API to update.

If I retrieve the page content via API I get none 🤔

<p><ac:image ac:align="center" ac:layout="center" ac:alt="">
        <ri:attachment ri:filename="mermaid-figure-1.png" ri:version-at-save="1" />
    </ac:image></p>

but width and height seems to be part of Confluence XML format https://confluence.atlassian.com/doc/confluence-storage-format-790796544.html#ConfluenceStorageFormat-Images

So could be a product version ? or an issue in Confluence API directly ? 🤔

Also this issue should happen with image and not just mermaid graph. I'll try that too