quarto-dev / quarto-cli

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

[Docusaurus] Code folding is broken (Quarto 1.4) #8314

Closed eitsupi closed 9 months ago

eitsupi commented 9 months ago

Bug description

I don't know what's going on, but nothing happens if filename exists. If filename does not exist, there is no </details> tag.

Steps to reproduce

---
title: foo
format: docusaurus-md
---

```{python}
#| filename: Python
#| code-fold: true
1 + 1

and

````qmd
---
title: foo
format: docusaurus-md
---

```{python}
#| code-fold: true
1 + 1

### Expected behavior

~~Sorry, but I don't know the correct output because I can't remember which version of Quarto CLI worked correctly (the Docusaurus format is almost always broken, as evidenced by the large number of issues I've created)~~

````md
---
title: foo
format: docusaurus-md
---

<details>
<summary>Code</summary>

```python title="Python"
1 + 1

2

and

````md
---
title: foo
format: docusaurus-md
---

<details>
<summary>Code</summary>

```python
1 + 1

2

(From Quarto CLI 1.4.432)

### Actual behavior

````mdx
---
title: foo
format: docusaurus-md
---

```python title="Python"
1 + 1
2

and

````mdx
---
title: foo
format: docusaurus-md
---

<details class="code-fold">
<summary>Code</summary>

```python
1 + 1

<div dangerouslySetInnerHTML={{ __html: quartoRawHtml[0] }} />

2

### Your environment

- Ubuntu 22.04

### Quarto check output

```sh
$ quarto check
Quarto 1.4.544
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.11: OK
      Dart Sass version 1.69.5: OK
      Deno version 1.37.2: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.4.544
      Path: /opt/quarto/bin

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

[✓] Checking LaTeX....................OK
      Tex:  (not detected)

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

[✓] Checking Python 3 installation....OK
      Version: 3.10.12
      Path: /usr/local/python/current/bin/python3
      Jupyter: 5.7.1
      Kernels: python3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........OK
      Version: 4.3.2
      Path: /usr/local/lib/R
      LibPaths:
        - /usr/local/lib/R/site-library
        - /usr/local/lib/R/library
      knitr: 1.45
      rmarkdown: 2.25

[✓] Checking Knitr engine render......OK
eitsupi commented 9 months ago

As a side note, I really recommend that you check with a working example that Docusaurus (and Hugo) work before the release of 1.4. Code-folding is what is mentioned on the website, so I think it's a pretty serious issue that this was completely broken and missed.

cscheid commented 9 months ago

@eitsupi I apologize - the issue is that we have no good automated way of checking whether those features are working. We'll investigate

eitsupi commented 9 months ago

Thanks for the reply. Of course, I know it's not covered by the tests in this repository, but the latter example of this bug (without filename) is due to the presence of an image on the website, and also because of the lack of the tag, docusaurus fails to build and raises an error. You can definitely detect it if you try a simple website rendering using docusaurus.

cscheid commented 9 months ago

I meant my original message as a response to "Docusaurus format is almost always broken"

cderv commented 9 months ago

Just sharing this here as documentation about what happened in the history of 1.4 so that we learn to pay more attention for the future. Always good to understand the source of an issue to correctly fix it.

Long story below... 😄


The recent change at 4d53bba389d78001936a4a1bc8ef8b7b0430a133 introduced the malformed content (unclosed HTML tag) but before this, the feature was already lost as parent commit gives me this output for the .mdx file

---
title: foo
format: docusaurus-md
---

```python title="Python"
1 + 1
2
1 + 1
2

We look the folding structure completely when fixing citation processing at 8e15dde0dd7d3f56149e226a9bd6235b76818b65. 
But even before this commit, we lost part of the feature for when `filename` is provided (first cell)

as we got this rendered 
````markdown
---
title: foo
format: docusaurus-md
---

```python title="Python"
1 + 1
2
Code ```python 1 + 1 ```
2


So if we go back to the first time we lost the syntax, it was between f584196916ab2ed45368f4b94593b4c10a8d22b7 and 851e31d3f4e9e00e9cf7fd0876cadc1a8cbeaf54 range I believe. 

Parent commit 3489892 still output correctly two fold syntax correctly. 

So to sumup, compare to 1.3

- We broke the folding for cells with `filename` between 3489892dd99d4c107acf0de35609bc3df1a1abf6...851e31d3f4e9e00e9cf7fd0876cadc1a8cbeaf54

- Then we lost completely the `code-fold` feature when doing this change 8e15dde0dd7d3f56149e226a9bd6235b76818b65 (for #7996)

- And we reintroduced part of the feature but incorrectly by accident at 4d53bba389d78001936a4a1bc8ef8b7b0430a133 (for #8293)

We'll definitely improve our testing suite now that it is fixed to avoid all this during for so long ! 
eitsupi commented 9 months ago

Thanks for quick updates and information!