Comments (5)
@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.
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.
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.
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.
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)
- Feature Request: Bracketed Paste Mode HOT 13
- [Question] Contribution Guidelines
- [Bug Report] Configured Coding Languages are not Highlighted HOT 2
- [Feature Request] copy current line HOT 3
- Avoid FTBFS when using binutils-gold HOT 1
- build fails in archlinux HOT 8
- copy-paste doesn't work well HOT 1
- yaml syntax highlighting of single-quoted strings incorrect HOT 2
- curses.h HOT 2
- Suggestion: preserve cur_buffer->find_string when playing a macro HOT 2
- compile ne for RiskV64 HOT 3
- Memory leak after opening file from file browser HOT 4
- [Feature Request] Soft wrapping Flag. HOT 1
- Single ESC breaks ne HOT 10
- Table of contents at the end? HOT 5
- [Feature Request] a way to move cursor to end of paste HOT 6
- "0x" prefix "tolerated" in ~/.ne/.keys file HOT 5
- autocomplete (or tab complete) macro names?
- truncation warning HOT 1
- Empty initializer list HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ne.