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

Add embedded language support for markdown in @docs and @moduledocs #87

Closed
Terbium-135 opened this issue Dec 10, 2024 · 8 comments · Fixed by #90
Closed

Add embedded language support for markdown in @docs and @moduledocs #87

Terbium-135 opened this issue Dec 10, 2024 · 8 comments · Fixed by #90

Comments

@Terbium-135
Copy link
Contributor

Right now I am extracting the text into a markdown file, edit and copy back.

It would be very nice to get syntax highlighting for @doc and @moduledoc parts. Since these are markdown the readability might increase.

Instead of this:
2024-12-10 09_02_23-user_login_live ex - ganymed  SSH_ Raspberry4  - Visual Studio Code - Insiders

one might see:
2024-12-10 09_01_42-doc md - ganymed  SSH_ Raspberry4  - Visual Studio Code - Insiders

@Terbium-135 Terbium-135 changed the title Add embedded language support Add embedded language support for markdown in @docs and @moduledocs Dec 11, 2024
@Blond11516
Copy link
Collaborator

@Terbium-135 This should be fixed on main. Please pull the latest main and try it out when you get the chance. Thanks!

@lukaszsamson
Copy link

@Blond11516 I tried that in ElixirLS v0.15 and had to revert as markdown rules would leak out of context and break highlighting of everything following. See elixir-lsp/vscode-elixir-ls#315 (comment)

@Terbium-135
Copy link
Contributor Author

I tried it as well and facing:
2024-12-16 06_07_55- Extension Development Host  core_components ex - Visual Studio Code - Insiders

I changed package.json and set:

  "engines": {
    "vscode": "^1.79.0-insider"
  },

I see no leakage so far. But only had a quick glance.
2024-12-16 06_42_49- Extension Development Host  core_components ex - Visual Studio Code - Insiders

and

2024-12-16 07_12_20- Extension Development Host  ● core_components ex - Visual Studio Code - Insider

I am not using ElixirLS.

@Terbium-135
Copy link
Contributor Author

Sadly I discovered a file which leaks markdown - perhaps something can be done to better (start and) terminate the heredoc area?

2024-12-16 18_23_16- Extension Development Host  authentication_component ex - Visual Studio Code -

taken from this part:

2024-12-16 18_24_53- Extension Development Host  authentication_component ex - Visual Studio Code -

The 2nd next """ ends markdown and switches back to elixir:

2024-12-16 18_27_30- Extension Development Host  authentication_component ex - Visual Studio Code -

@Blond11516
Copy link
Collaborator

So from what I've seen the issue of leakage is caused by the additional indentation that @doc and friends add at the beginning of the markdown. This causes vscode to misinterpret the markdown as soon as it detects some sort of indented element (non-fenced code block, element within a list, etc.)

For example, as soon as the heredoc contains a list, vscode interprets everything coming after it as a list element, because the markdown is indented as such:
Capture d’écran 2024-12-16 220252

This then appears to cause the next closing heredoc to be missed for whatever reason.

A custom markdown grammar might indeed be able to fix this, but that's obviously not a very desirable solution. I'll dig a bit into TextMate to see if there's any way to have it ignore this identation but I wouldn't bet on that being the case. Ideally I'd like to see how other extensions handle this; it would need to be a grammar that injects a whitespace-sensitive language (markdown, python, etc.) with some implicit indentation but I don't have any ideas off the top of my head. I'm all ears if anyone knows of something like this 🤷

I've pushed a small reproduction repository with examples of list and nested module failures.

@Blond11516
Copy link
Collaborator

I've reverted the changes from main and pushed them back in a new branch.

@Terbium-135
Copy link
Contributor Author

Thank you for all your work and investigation so far!

@SteffenDE
Copy link

I think a while pattern should do the trick, see elixir-lsp/vscode-elixir-ls#315 (comment).

Confirmed working (with ElixirLS) for the examples from https://github.com/Blond11516/markdown-leakage-repro

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