-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Highlight Elixir string markdown header correctly #775
Highlight Elixir string markdown header correctly #775
Conversation
Thanks for contributing! Would it be ok to only change the negative look-ahead in the comment pattern, so that we ignore comments starting with more than one hash? |
I'll give it a try and let you know. |
daa8ac3
to
1096ccb
Compare
Changing the negative lookahead wasn't enough. If it was given this: @doc """
## Header
""" It would match on |
Damn you're perfectly right! Please use the 'comment': {
pattern: /([^#])#(?![{#]).*/,
lookbehind: true
} Can you also fix the indentation before the comments you added? I can merge this once it's done ;) |
1096ccb
to
1aede3e
Compare
Elixir allows markdown inside its triple-quote heredoc syntax. However, the "#" used in markdown headers is currently misinterpreted as a comment. So, if you write this: ```elixir @doc """ Get the first name of a user. - `user` - A User struct. user = %User{name: "Alice Winston"} User.first_name(user) "Alice" """ ``` Prism interprets the markdown headers as comments, not as part of the string, and this messes up the coloring. This can be fixed by adding a negative lookbehind, such that the comments regex matches "#" but not "##".
1aede3e
to
220f1df
Compare
Done! I amended the commit. |
Thanks! |
Highlight Elixir string markdown header correctly
Oh, I had to add an alternative to handle the empty comment |
How do you run the tests? |
By running |
I'm fixing this now. |
It's fixed already! See ccb6566 |
👍 |
Elixir allows markdown inside its triple-quote heredoc syntax. However,
the "#" used in markdown headers is currently misinterpreted as a
comment. So, if you write this:
Prism interprets the markdown headers as comments, not as part of the
string, and this messes up the coloring.
It's easy to fix, just put the string regular expressions before the
comment regular expression in the elixir component.