0

Help With VimWiki

Vimwiki Code Block Syntax Highlighting in HTML Not Working Properly

Issue:

I'm trying to enable syntax highlighting for code blocks in Vimwiki's HTML export. In Vim, both Python and Go code blocks have syntax highlighting, but in the exported HTML:

  • Inside vim both blocks have syntax highlight so not a syntax issue I think?
  • The Python block is missing entirely.
  • The Go block appears, but without syntax highlighting.

My Vimwiki Configuration:

letg:vimwiki_listing_hl = 1 let g:vimwiki_listing_hl_command = 'pygmentize -f html' let g:vimwiki_fenced_languages = ['python', 'go', 'cpp', 'sh'] 

I confirmed that Pygments is installed:

pygmentize -V # Output: Pygments version 2.18.0 

Code Blocks in vimwiki

{{{type=python import qiskit as q import numpy as n for i in range(2): print(32) }}} {{{type=go import main }}} 

How can i enable syntax highlight for exported html.

System Info

Fedora 41 KDE

4
  • I have the same problem. Maybe it should be reported in the issue tracker of vimwiki. Commented Mar 4 at 20:09
  • Could you tell us what is the result of the following Vim command: :echo has('unix')? It seems that the g:vimwiki_listing_hl is only supported on unix systems. Commented Mar 4 at 20:36
  • 1
    I am on fedora Linux, and the command does return 1. Commented Mar 5 at 3:29
  • Use the plugin's documentation and issue tracker. Commented Mar 5 at 8:44

2 Answers 2

1

The g:vimwiki_listing_hl is only supported on Unix system.

The :echo has('unix') needs to return 1.

0

I don't use that plugin so I can't tell if that is the cause of your problems or not, but your syntax is incorrect, and Vim should have told you so:

Error detected while processing /path/to/.vimrc: line 4: E492: Not an editor command: letg:vimwiki\_listing\_hl = 1 line 6: E121: Undefined variable: g:vimwiki Press ENTER or type command to continue 

Instead of this:

letg:vimwiki\_listing\_hl = 1 let g:vimwiki\_listing\_hl\_command = 'pygmentize -f html' let g:vimwiki_fenced_languages = ['python', 'go', 'cpp', 'sh'] 

you should have this:

let g:vimwiki_listing_hl = 1 let g:vimwiki_listing_hl_command = 'pygmentize -f html' let g:vimwiki_fenced_languages = ['python', 'go', 'cpp', 'sh'] 

Fix your config first.

Which raises a few questions:

  • Why did you use that random syntax to begin with?
  • Why hasn't Vim warned you about it?
  • If it did, why did you ignore those warnings?
1
  • Hmm that's wierd my config does have the correct syntax, I don't know what happened while pasting that gave me those \ in between... Anyways I have corrected the post Commented Mar 5 at 14:05

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.