![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
On Sat, 16 May 2020, Nicola wrote:
On 2020-05-16, Aditya Mahajan
wrote: On Sat, 16 May 2020, Aditya Mahajan wrote:
Moreover, if you comment line line 126 of `2context.vim`
"let s:id = synIDtrans (s:id)
[If you make a local copy of 2context.vim, then you need to run the file with `--mode=dev-vim` to ensure that the local copy is used]
Then the ruby example generates the following file:
\SYNBOL{}\SYN[rubyComment]{# Ruby program listing}\SYNEOL{} \SYNBOL{}\SYN[rubyDefine]{def}\SYN[rubyMethodBlock]{ }\SYN[rubyMethodName]{foobar}\SYNEOL{} \SYNBOL{}\SYN[rubyMethodBlock]{ print(}\SYN[rubyStringDelimiter]{"}\SYN[rubyString]{Hello World}\SYN[rubyStringDelimiter]{"}\SYN[rubyMethodBlock]{)}\SYNEOL{} \SYNBOL{}\SYN[rubyDefine]{end}\SYNEOL{}
So, if you are willing to define wrappers for all ruby syntax blocks, then I can provide a configuration option so that `2context` does not apply that line.
That might provide a finer control over the highlighting, but the main issue here seems to be that the generated file has Identifier instead of Function, Special instead of Delimiter and Constant instead of String. Looking at 2context.vim, AFAICS s:id_name seems computed correctly. Maybe, the script does not set the appropriate filetype?
filetype is set correctly (since we get `ruby....` options), but something weird is happening even with 2html.vim. Here is a minimal example: ```test.rb # Ruby program listing def foobar print("Hello World") end ``` Run: vim -u NONE -c "syntax manual" -c "set syntax=ruby" -c "source /usr/share/nvim/runtime/syntax/2html.vim" -c "wqa" test.rb gives ```test.rb.html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> ... </head> <body> <pre id='vimCodeElement'> <span class="Comment"># Ruby program listing</span> <span class="PreProc">def</span> <span class="Identifier">foobar</span> print(<span class="Special">"</span><span class="Constant">Hello World</span><span class="Special">"</span>) <span class="PreProc">end</span> </pre> </body> </html> <!-- vim: set foldmethod=manual : --> ``` which is similar to what 2context.vim gets. If I source tohtml.vim or 2context.vim from an existing vim session, then the tags are correct. I have not been able to figure out why this is happening. Aditya