Git Product home page Git Product logo

Comments (5)

utoddl avatar utoddl commented on August 22, 2024 2

@carlsmith could you post a gist of your .jsf? These things are incredibly hard to describe. To paraphrase: talking about .jsf is like dancing about architecture.

from ne.

utoddl avatar utoddl commented on August 22, 2024 1

Here's me, eating my words. Remember what I said about talking about .jsf is like dancing about architecture? Time to dance. :) I sort of see what you're shooting for, but I'd like to suggest a less invasive approach. Let's go back to the python.jsf as distributed with ne and start fresh from there.

Notice that all states with the exception of :idle of course (and ":comment", which is probably a mistake) which transition to "idle" do so with a noeat. This is very important, as it means that pretty much every "\n" is going to send you back to "idle".

From my reading of the iPython pages, the only times we deviate from normal Python syntax is at the beginning of lines or immediately after an equals sign, give or take some white space. So let's wedge this in between the existing colour definitions and "idle":

=IpTag          inverse green
=IpString       inverse yellow

:maybe_ip Idle
        *               idle            noeat
        " \t"           maybe_ip
        "!%"            ip_tag          noeat
:ip_tag IpTag
        *               ip_string       noeat
        "!%"            ip_tag
:ip_string IpString
        *               ip_string
        "\n"            maybe_ip

This defines two new colors: one for the tags and one for the strings. It also makes your default/first state "maybe_ip" using the Idle colour. It skips over spaces looking for either "!" or "%" without consuming them. Anything else sends us to "idle", so we don't mess up the rest of the Python syntax. "ip_tag" eats the bang and percent signs, then transitions to "ip_string", which eats everything to the end of line.

We still need "idle" to deal with possible iPython magic after an equals sign or new lines. So let's add this transition to "idle":

  "=\n"           maybe_ip

It eats, so the equal sign gets the Idle colour, but we go looking for iPython magic. If we don't find it, "maybe_ip" noeats and goes right back to Idle, so again, we don't break any of the Python syntax.

The only other thing I'm seeing is the missing noeat on "comment"'s transition on newline, so add that:

  "\n"            idle            noeat

And I think we're done. You'll probably want to tweak the colors, and you may find some circumstances that I didn't spot. But I think we're closer to what you wanted without breaking the existing Python bits. Give it a try and let us know what you think.

from ne.

carlsmith avatar carlsmith commented on August 22, 2024

No problem @utoddl. The gist is online here. I added a comment there that points out what edits have been made to the original file. Thank you for looking into this.

My approach was to just try and highlight the commands magenta, but ideally, they should be highlighted using sh.jsf.

If we can get IPython syntax highlighting working properly, I'll post something to the IPython mailing list, sharing my configuration, and explaining and plugging ne a bit. I'm sure there are more than few people there that would be interested.

from ne.

carlsmith avatar carlsmith commented on August 22, 2024

Thank you for this @utoddl. It's really kind of you to take the time, and your help is much appreciated mate. I'll check the new code out this evening, and let you know how it goes. I really just wanted to say thank you.

from ne.

carlsmith avatar carlsmith commented on August 22, 2024

I just got a chance to try it out. It works perfectly. Thank you @utoddl.

I'm a ne fan! IPython support is a really nice extra, and your willingness to help your users like you have here is really appreciated. I'm genuinely happy pluggingne, and will let the IPython community now about this feature and ne soon.

Awesome work. Thanks again man.

from ne.

Related Issues (20)

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.