Comments (4)
Hi,
The syntax highlighting pattern for standard Python strings fails with embedded escaped quotes.
Yeah, that's probably because nobody ever bothered to make them better :D
For instance c quotes pattern is exceptionally robust. I rarely deal with python in my work
so it had less of my attention.
P. S. I am trying to understand how the highlight structure's end and blkend work. Please give me some hints.
I am in the processes of making changes with some ideas gained over the year, so readme is a bit out of date. It will be updated once I feel like I've exhausted my ideas.
The way end works, its a 16 byte array of chars, each char can take 3 states: -1, 0, 1. It determines where the result of a pattern match continues. 16 corresponds to 16 groups that could be defined, more than enough.
0 means nothing special happens (default) advance sp by the length of the matched group.
-1 means the pattern group that matched will be highlighted but treated like it didn't match. thus the string pointer is set to sp+1. Notice the +1 is necessary otherwise we would be stuck in an infinite loop matching the same pattern over and over. So its not exactly no match operation, more like a way to let other patterns passthrough.
1 same concept as -1 except we advance by the starting location of the group match. i.e if match was (5,10) add sp+5
blkend tells which group is going to terminate the multiline block. if its negative the same group that started the block terminates the block. There are a few gochas, for example when screen is positioned going up instead of down, it is always assumed that group 1 will do the termination in that case.
Hope this helps, I know its arcane, but the purpose is to have a minimal and lean implementation.
from nextvi.
from nextvi.
I have attached the old Python program which I have been using for testing;
Use null pointer, I don't think github reply attachments work (or you forgot to attach it).
https://0x0.st/
I added extra strings near the top. The highlighting is quite good, but the result is sometimes bizarre: on line 591, the fd.write call uses a triple-quoted string; the string ends on line 616, but the highlighting continues until line 626. The highlighting changes as I move around in the file. Is that expected?
Moving up screen up won't do it right if the pattern is not fully enclosed (screen wise)
Btw, my multiline pattern now looks like this:
{"py", "((?:[!\"\"\"]*\"{3}\n$)|(?:\"{3}[!\"\"\"]*)|\"{3})", {6}, {0}, -1},
Did you happen to test it? I think its better because it handles this:
fsjfjsdj """ jdfsjfj
"""
jdfsjfj will be highlighted.
I use 6 for color, a special string a separate color I guess ha ha.
-Kyryl
from nextvi.
from nextvi.
Related Issues (20)
- i<CR><ESC> HOT 6
- stdin pipe breaks all syntax highlighting HOT 1
- Issues with stdin_pipe HOT 14
- Is gf bind in normal mode that edits the file whose address is under the cursor, a thing in Nextvi? HOT 6
- arrowkeys_normal.patch shouldn't exit insert mode HOT 24
- Remove variable length arrays HOT 14
- arrowkeys_insert: the first time entering command mode, the command bar is broken until you type something HOT 1
- gcc warning HOT 2
- visual mode equivalent? HOT 2
- ec_closebuf segfaults if it is the only remaining buffer HOT 1
- Float without leading zero HOT 2
- a way to change how big tabs are HOT 1
- soft line wrap? HOT 1
- implementing vim-like dw HOT 3
- stdin_pipe: lockup if stdin is terminal HOT 5
- Skip command confirmation when only one line HOT 1
- arrowkeys_insert: cursor position is wrong when moving up or down a line after typing something HOT 6
- Segmentation fault HOT 3
- Edge case of missing filename HOT 3
- ex "!" HOT 2
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 nextvi.