How to modify some details of Vimwiki2HTML in vimwiki

  question, vim

Vimwiki’s default Vimwiki2HTML command converts %toc to the directory of the current wiki entry, but converts the secondary directory id to TOC _ 1.1 (the id contains a dot number). in order to implement scroll detection using bootstrap-scrollspy (see:How to Realize Web Page Scroll Detection and Fixed Navigation Bar at Top), a dot cannot be used in id.

Excuse me:

  1. How can the directory id in the html file generated by vimwiki contain no dot, for example, toc_1_1 instead of toc_1.1?
  2. How can < ul > tags in the generated directory have attributesclass="nav"This is also to use bootstrap-scrollspy.

Vimwiki’s help manual reads as follows:

Key Default value~
custom_wiki2html ”
The full path to an user-provided script that converts a wiki page to HTML.
Vimwiki calls the provided |vimwiki-option-custom_wiki2html| script from the
command-line, using ‘!’ invocation.

The following arguments, in this order, are passed to the
|vimwiki-option-custom_wiki2html| script:

1. force : [0/1] overwrite an existing file
2. syntax : the syntax chosen for this wiki
3. extension : the file extension for this wiki
4. output_dir : the full path of the output directory, i.e. ‘path_html’
5. input_file : the full path of the wiki page
6. css_file : the full path of the css file for this wiki

For an example and further instructions, refer to the following script:


To use the internal wiki2html converter, use an empty string (the default).

My level is limited and I cannot write an external script directly. I want to refer to what the vimwiki default script looks like, but I don’t knowinternal wiki2html converterWhere is the script for.

There are now two ways:

1. Batch processing with sed; Use sed to modify html generated by vimwiki to make it conform to specifications. the script is as follows:

sed -i 'N;s/<div class="toc">\n<ul>/<div class="toc">\n<ul class="nav">/ ; s/toc_\([0-9]*\)\.\([0-9]*\)/toc_\1_\2/g' ~/Documents/wiki_html/cs_html/*.html ~/Documents/wiki_html/life_html/*.html ~/Documents/wiki_html/original_html/*.html ~/Documents/wiki_html/*.html

Note: the sed N command adds even lines to the buffer of odd lines, so < div class=”toc “> needs to be placed in odd lines.

2. modify the autoload/vimwiki/html.vim file as follows:

    if level > plevel
      call add(toc, '<ul class="nav">')
    elseif level < plevel
      let plevel = s:close_list(toc, plevel, level)


    for l in range(1, h_level-1)
      let h_number .= a:id[l].'_' 

Thank you, themacropodus@gmail.comCan I modified the internal wiki2html …The answer.