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

Docstring Highlighting #33

Closed
MikeInnes opened this issue Aug 2, 2015 · 10 comments
Closed

Docstring Highlighting #33

MikeInnes opened this issue Aug 2, 2015 · 10 comments

Comments

@MikeInnes
Copy link
Collaborator

This docstring makes highlighting go funky:

"""
    @switch isa(x, _) begin
      Integer; "x is an integer!"
      FloatingPoint; "x is a float!"
      "x is something else!"
    end

Where `_` is replaced by the value for testing in each case. The final
"""
macro switch(args...)

screenshot 2015-08-02 12 51 32

The _ seems to start an italic section despite being in a code block, and this doesn't happen without the ). Also, for some reason the final """ isn't closing off the docstring either.

Highlighting top-level strings as markdown is a great idea, but maybe it would then be good to remove the string scope so that the default colour isn't yellow. It'd also be pretty cool if we could highlight indent code blocks as Julia by default.

@garborg
Copy link
Contributor

garborg commented Aug 2, 2015

These fixes would be great.

Re: improving highlighting generally, I have a PR with comprehensive improvements that I'm pretty excited about, but they're languishing locally until a parsing bug is fixed upstream: atom/first-mate#52. I don't know if anyone has done any work on first-mate -- hopefully it's fixed soon.

@sglyon
Copy link
Contributor

sglyon commented Aug 3, 2015

@garborg, really looking forward to your improvements. I think a solid cleanup would be great. Most of what is there right now is just inherited from the textmate bundle. We've made a few changes, but not a general overhaul like I think you are working on.

@sglyon
Copy link
Contributor

sglyon commented Aug 28, 2015

@one-more-minute I think you can just put a space between the _ and ) to fix the italic issue. I just tested and it looks like that would fix the docstring not ending issue also.

This also seems like more of a problem in the atom-gfm grammar since it only happens when we include their grammar (i.e. only happens in a docstring)

@sglyon
Copy link
Contributor

sglyon commented Sep 4, 2015

@garborg any update on this? I see that very little has happened over at atom/first-mate, but are some of your improvements independent of that?

@sglyon
Copy link
Contributor

sglyon commented Sep 4, 2015

Oh and @one-more-minute, I currently have this in my styles.less

 atom-text-editor::shadow {
   .string.docstring.julia {
     color: @syntax-result-marker-color;
   }
 }

It makes it more or less the same color as comments, depending on how the syntax uses that variable. It would be better to somehow pop the string scope when we enter a docstring though

@garborg
Copy link
Contributor

garborg commented Sep 4, 2015

The issue in atom/first-mate has been switched from 'bug' to 'matches macromates', which I imagine means won't fix. So dead end there until Atom supports more powerful tokenizers -- there are links in atom/first-mate#52 to issues suggesting supporting external tokenizers and/or Sublime 3's grammar.

Unfortunately, my plan to highlight almost everything correctly falls apart with a grammar that ignores 'end' patterns, so much of what I did will be useless. I do have plenty of new tests that should pass, but it'll take a bit of work to try to salvage actual changes.

@sglyon
Copy link
Contributor

sglyon commented Sep 4, 2015

Darn, that's disappointing.

I was looking forward to sane/complete scoping for everything.

@tpoisot
Copy link
Contributor

tpoisot commented Sep 7, 2015

The markdown specification used by language-gfm is that an italic string is started by an italic delimiter (_ or *) followed by anything that is not a space.

The following code works well:

"""
@switch `isa(x, _)` begin
  Integer; "x is an integer!"
  FloatingPoint; "x is a float!"
  "x is something else!"
end
Where `_` is replaced by the value for testing in each case. The final
"""
macro switch(args...)

@pfitzseb
Copy link
Collaborator

This is the same as atom/language-gfm#44, btw.

@pfitzseb
Copy link
Collaborator

pfitzseb commented Dec 5, 2017

Fixed on master.

@pfitzseb pfitzseb closed this as completed Dec 5, 2017
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

5 participants