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

Fix rendering of indented code blocks in markdown #3503

Merged
merged 1 commit into from
Aug 24, 2022

Conversation

connorlay
Copy link
Contributor

@connorlay connorlay commented Aug 22, 2022

Relates to #3425 and elixir-lsp/elixir-ls#694

Properly handles the rendering of indented code blocks in markdown. Given that we do not have a language identifier available, we style these blocks as generic code (visually distinct from markdown text, but no highlighting via tree-sitter).

This improves the experience of writing Elixir in Helix, as the majority of documentation favors indentation over fences.

Before ☹️
image

After 😁
image

@archseer
Copy link
Member

Do you think it would be worth highlighting these blocks using the parent document's language? If the file is elixir it's also very likely the code block is elixir (or iex)

@the-mikedavis
Copy link
Member

I'm not sure there's a good strategy for picking languages in indented code blocks in markdown: it could either be Elixir, IEx or HEEx (I think I've also seen some EEx and Erlang too) when injecting or using markdown from Elixir. We could try parsing the code block with each of them and use the first that doesn't have any errors, falling back to no syntax highlighting when all error out.

@archseer
Copy link
Member

I think fixing this upstream is still the best way to get it fully correct, but falling back to the main language should work for most languages. Elixir is an outlier where code examples can also consist of a mix of IEx snippets

@connorlay
Copy link
Contributor Author

@archseer @the-mikedavis I agree the long-term solution for Elixir is to handle language detection within the language server. Detecting language syntax in Helix via tree-sitter sounds like a viable solution too.

With that in mind, are you open to merging this as-is? Even without syntax highlighting I think this is a significant QOL improvement 🙂

@the-mikedavis
Copy link
Member

I think this is a good improvement even without defaulting to the document's language 👍

@archseer archseer merged commit 99b1e8a into helix-editor:master Aug 24, 2022
AlexanderBrevig pushed a commit to AlexanderBrevig/helix that referenced this pull request Aug 29, 2022
thomasskk pushed a commit to thomasskk/helix that referenced this pull request Sep 9, 2022
jdrst pushed a commit to jdrst/helix that referenced this pull request Sep 13, 2022
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

Successfully merging this pull request may close these issues.

3 participants