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

[Meta] code folding / collapsable sections #570

Closed
noraj opened this issue May 28, 2022 · 2 comments
Closed

[Meta] code folding / collapsable sections #570

noraj opened this issue May 28, 2022 · 2 comments

Comments

@noraj
Copy link

noraj commented May 28, 2022

Description

It would be nice to be able to collapse / fold some sections in AsciiDoc documents (like VSCode does for markdown).

Related issues

Note: #553 and #70 are closed by b070724 and 2824561 but it doesn't seem to work for me. Is that possible there was some regression?

Similar behavior for Markdown

For example in Markdown document I can fold heading levels or code blocks:

image

Example with title 1 and the code block folded:

image

@ggrossetie
Copy link
Member

Note: #553 and #70 are closed by b070724 and 2824561 but it doesn't seem to work for me. Is that possible there was some regression

They are not part of any release, that's why . You can see on the commit page that there's no tag associated:

commit-without-tag

For reference, here's another commit where you can see two tags:

commit-release

While I appreciate the effort to create this issue, I don't think we need a meta issue. I like to keep issues actionable and a meta issue is by definition not actionable.

Besides, a section is only a specific type of block. AsciiDoc has quite a few type of blocks :

  • admonition
  • sidebar
  • paragraph
  • list
  • table
  • section
  • open, source, example, stem, quote, verse... blocks

Implementation wise, the tough part is that it depends on the context, for instance:

....
|====
| not a table
|====
....

|====
| a table
|====

I don't know what's the best strategy. In theory, we could Asciidoctor AST but the sourcemap feature isn't perfect (https://docs.asciidoctor.org/asciidoctor/latest/api/sourcemap/). Having said that, it might be good enough for now.
Another solution would be to implement a parser that accurately tracks source location of blocks. That would be a good exercise since I intend to implement a pure JavaScript parser of the AsciiDoc language but will surely require a good amount of time and effort.

Feel free to create dedicated issues for each block type with basic and edge cases and how the content should be folded for every cases.

@noraj
Copy link
Author

noraj commented Sep 18, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants