quarto-dev / quarto

Quarto open-source scientific and technical publishing system
https://quarto.org
GNU Affero General Public License v3.0
280 stars 19 forks source link

VS Code extension: Outline incomplete #363

Open roland-KA opened 5 months ago

roland-KA commented 5 months ago

Especially in longer documents, the VS code extension shows the outline only up to a certain point of the document. All further headlines are not recognised as such.

The problem is caused by paragraphs with nested lists, when using a a second indented list level. The problem is also visible when looking at the icons for collapsing paragraphs as in the following example:

image

The last icon the extension shows is in line 333. The headings in line 340 and 344 don't have one. And these headlines starting from this point down to the end of the document don't show up neither in the outline (the document has over 800 lines with many more headlines).

When I collapse the document using the icon in line 333, it collapses the complete rest of the document (not only the few lines belonging to that list).

Unfortunately, the problem is difficult to reproduce. It happens only in longer documents. So I haven't been able to make a MWE. And it isn't caused by every nested list. There are several nested lists above line 333, which work perfectly.

Unindenting the list items in lines 333 and 334 solves the problem as the following screen shot shows. Here the headlines in lines 340 and 344 are identified as headlines (and have therefore an icon to collapse them):

image
rben01 commented 3 months ago

I've noticed that this can be caused by using pandoc ::: divs. The extension seems to particularly struggle with ::::: (five colons).

rben01 commented 3 months ago

Fiddling around with this extension, it looks like closing ::: are never picked up by https://github.com/quarto-dev/quarto/blob/3bd070a1ffabd0b2dc80c67f5d9fa9a2d8bee896/packages/core/src/markdownit/divs.ts#L17

And so the block below is simply never entered. https://github.com/quarto-dev/quarto/blob/3bd070a1ffabd0b2dc80c67f5d9fa9a2d8bee896/packages/core/src/markdownit/divs.ts#L122

And divPlugin appears to stop being called altogether at some point (once state.env.quartoDivLevel reaches a certain level?), although it's hard to say why.

roland-KA commented 3 months ago

Ah that's a good hint!

I have several :::: {.columns}-directives in my document. It appears to be important to insert a blank line after each :::-div.

E.g. the following code is problematic:

:::: {.columns}

::: {.column width="40%"}
Left column
:::

::: {.column width="60%"}
Right column
:::
::::

With a blank line between the last two lines, the problem occurs not so often (but I doesn't disappear completely after this change).

rben01 commented 3 months ago

Looks like placing blank lines around all ::: lines, both opening and closing, helps with the issue.

roland-KA commented 3 months ago

Indeed, I've just tried it.

But I hope, that somebody finds the cause of that problem, as the blank lines all over the document don't really improve readability.

rben01 commented 3 months ago

I wouldn't be surprised if the markdown parser thinks it can combine consecutive lines into paragraphs except for certain lines (headers, code blocks, lists) and isn't attuned to ::: as a special line type.

tomkom commented 2 months ago

I can confirm this is still happening.

TrismegistusS commented 3 weeks ago

The problem is still not fixed and really kind of annoying -- especially since switching to the visual editor deletes the blank lines around the ::: lines.