Coder Social home page Coder Social logo

Comments (24)

Glavin001 avatar Glavin001 commented on September 28, 2024

Any chance this can be adopted?

Absolutely. I originally tried to get https://github.com/atom/highlights working however it complained with errors when I installed it so I used another package, see #1. Maybe @kevinsawicki could give me a hand in where I should look for how the EditorView renders syntax highlighting :).

from atom-coffeescript-preview.

kevinsawicki avatar kevinsawicki commented on September 28, 2024

There is an API on the EditorView to build HTML for a given text chunk using the current theme.

The Markdown preview package uses it to colorize code blocks in markdown files.

You can get the JS grammar by doing atom.syntax.grammarForScopeName('source.js') and then do the following to build the HTML: https://github.com/atom/markdown-preview/blob/17dd86ede2d6a270fecc39b696282937c67fb3ae/lib/renderer.coffee#L97-L100

Is this what you are looking for?

from atom-coffeescript-preview.

Glavin001 avatar Glavin001 commented on September 28, 2024

Looks like exactly what I need! Thank you @kevinsawicki!
I should be able to whip this up quickly later tonight :).

from atom-coffeescript-preview.

kevinsawicki avatar kevinsawicki commented on September 28, 2024

Great, let me know if you have any issues, very cool package 👍

from atom-coffeescript-preview.

batjko avatar batjko commented on September 28, 2024

Great stuff! Thank you both.

from atom-coffeescript-preview.

Glavin001 avatar Glavin001 commented on September 28, 2024

Pushed :).
screenshot

from atom-coffeescript-preview.

batjko avatar batjko commented on September 28, 2024

Yup, that looks pretty now!

The font size isn't catching up yet, but the theme is working very nicely now!
image

from atom-coffeescript-preview.

Glavin001 avatar Glavin001 commented on September 28, 2024

Whaaat? I even fixed the font-size before I pushed. It updates the font-size every time it renders the new preview.
https://github.com/Glavin001/atom-coffeescript-preview/blob/master/lib/coffeescript-preview-view.coffee#L135-L141

@kevinsawicki any ideas / alternatives to syncing the font-size?

from atom-coffeescript-preview.

batjko avatar batjko commented on September 28, 2024

Sorry, mate.
I tried closing the preview, then changing the coffee's size, then re-loading the preview, still not adapting.

No errors in the console, btw.

from atom-coffeescript-preview.

Glavin001 avatar Glavin001 commented on September 28, 2024

Just tried it with mine. It is working, because the tab change event is triggered when I got back from Atom Settings tab back to the coffeescript editor, and it reloads the view and re-applies the font-size.

How are you setting the font size?

from atom-coffeescript-preview.

Glavin001 avatar Glavin001 commented on September 28, 2024

@batjko I think I may have found the problem. And also a solution. Continuing with issue #6

from atom-coffeescript-preview.

batjko avatar batjko commented on September 28, 2024

Ah, yea I'm not using the settings view for it, rather the Ctrl+= and Ctrl+- key binding for adjusting the size.
But even changing it in the Settings View doesn't do it for the preview.

from atom-coffeescript-preview.

Glavin001 avatar Glavin001 commented on September 28, 2024

@batjko I have pushed and published a patch that fixes the issues you described and I tested with Ctrl+= and Ctrl+- key binding for adjusting the size. Hope it works well for you, too :).

from atom-coffeescript-preview.

batjko avatar batjko commented on September 28, 2024

Yup, now it changes font size as I change it. Purrs like a kitten!
Well done, and thanks for the quick turn-around!

from atom-coffeescript-preview.

Glavin001 avatar Glavin001 commented on September 28, 2024

You're very welcome! Thank you for your support and let me know if you have any other ideas to make it even better!

from atom-coffeescript-preview.

violet-athena avatar violet-athena commented on September 28, 2024

Hi guys, this works fine for the inbuilt themes of Atom, but when trying something different (Monokai) it just shows grey text. Any idea where the problem might be?

from atom-coffeescript-preview.

Glavin001 avatar Glavin001 commented on September 28, 2024

@daniocean, like this?
image

from atom-coffeescript-preview.

violet-athena avatar violet-athena commented on September 28, 2024

Yes, exactly :)

from atom-coffeescript-preview.

Glavin001 avatar Glavin001 commented on September 28, 2024

I have been using the editor-colors class, and these other themes that are not working appear to be just using editor with editor-colors. However, it could also be an issue with the latest Atom updates -- I am finding that the font-size is also incorrectly rendered now even though the CSS says font-size: 16px for both.

image

from atom-coffeescript-preview.

Glavin001 avatar Glavin001 commented on September 28, 2024

Tested Themes:

  • Atom Dark
  • Base16
  • Monokai
  • Solarized Dark

from atom-coffeescript-preview.

Glavin001 avatar Glavin001 commented on September 28, 2024

@daniocean just published a patch. Let me know if it works for you as well.

from atom-coffeescript-preview.

Glavin001 avatar Glavin001 commented on September 28, 2024

Also, I recommend everyone slowly migrates over to using https://github.com/Glavin001/atom-preview :).

from atom-coffeescript-preview.

violet-athena avatar violet-athena commented on September 28, 2024

Works great, thanks!

I'll probably move to "preview" as soon as this fix is in it :)

Cheers!

from atom-coffeescript-preview.

Glavin001 avatar Glavin001 commented on September 28, 2024

Excellent!

Sounds good. I'll have to make the fix on Preview later tonight after work.

Continued development will likely only continue on with Preview and deprecate CoffeeScript-Preview very soon.

Thanks for your support! Enjoy.

from atom-coffeescript-preview.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.