-
Notifications
You must be signed in to change notification settings - Fork 62
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
Add syntax highlight variant based on CommonMark using external parser #328
base: master
Are you sure you want to change the base?
Conversation
Nesting needs to work like this: Container blocks → Leaf blocks → Inlines In that order. |
I'm not sure where CommonMark leaves Pandoc's div syntax. An extension with an extra kind of Container block? |
Fenced divs? Those should be a container block. |
My point was the CM spec at this point has three types of container blocks, and fenced divs are not one of them. I believe there is an allowance for them somewhere (I remember discussing this when Pandoc was considering adding the syntax) but I can't remember how it handles this. Extensions I think. |
I mistakenly branched this work off of something 52 commits behind master. I just rebased and tweaked how it is launched to make it easier to experiment with different approaches.
|
@fmoralesc I know for the sake of interfacing with vim-pandoc you want to get this working in Pandoc ... and that's understandable. I have my own reasons for wanting to get this working in Lua. First I need the general highlighting method work from Lua for another project that this is just a proof of concept for, and also I want to be able to wire SILE internals directly into my vim buffer. Hence I'm pushing forward with being able to do both. I rewired the Rust code so that it can generate both Python and Lua native modules from the same basic code. I actually got it working without the extra wrappers, but the trait handling was messy because I got back to basically where I was with Lua, but this time with Rust code using native types and only converting to Lua structures at the last minute. I did not get the Python as far along as your version yet, but I'll keep working on it some. I wasn't sure where to put the Python code half on the equation relative to the rest of the plugin. |
First of all, great job!
Ultimately for vim-pandoc I don't think the language we write this thing in matters, and I don't think python is a requirement. I just wrote my python version because I wanted to have something to toy around from the stage that we interface with vim (how to handle multiline blocks and so on, get
an idea of the performance...) As you can tell, I'm way more confident in python than in anything else ;)
|
I left some comments in gitter earlier today, I'm copying them here for reference:
|
I'm actually learning a lot from seeing your Python work, I don't think it's a waste to mess around with what vim/nvim allow different language interfaces to accomplish. By the way I stuck a |
Same here for me with your rust and lua work. Earlier you said you didn't know what to do with my python code. Well, just steal the ideas and incorporate them in the lua code! 😉 I think that as far as the highlighting system goes, it makes sense to have only one language in the codebase interacting with vim (at some stage vim-pandoc used viml, python AND RUBY... those were the days... and we had python in the syntax file... 🤦 I guess we have come full circle EDIT: and let's not forget that if commonmark-hs finally pans out, we might want to have the syntax interact with a haskell library). |
fn get_offsets(_py: Python, buffer: String) -> PyResult<()> { | ||
let events = super::get_offsets(buffer).unwrap(); | ||
for event in events.iter() { | ||
eprintln!("DEBUG={:#?}", event); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//eprintln!("DEBUG={:#?}", event);
let event_dict = PyDict::new(_py);
event_dict.set_item("group", event.group.as_str()).unwrap();
event_dict.set_item("start", event.first).unwrap();
event_dict.set_item("end", event.last).unwrap();
//event_dict.set_item("lang", format!("{:#?}", event.lang)).unwrap();
pyevents.set_item(i, event_dict)?;
i += 1;
@@ -0,0 +1,23 @@ | |||
use pyo3::prelude::*; | |||
use pyo3::wrap_pyfunction; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use pyo3::types::PyDict;
@@ -3,3 +3,4 @@ | |||
*.swp | |||
tags | |||
doc/tags | |||
/target |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*.so
/target-lua
/target-python
See primary discussion at #327.
See CommonMark Spec.
This will be a long running effort. Please feel free to pitch in with ideas or pull requests against this branch.