-
Notifications
You must be signed in to change notification settings - Fork 66
Generalize wiki#toc#gather_entries #288
Copy link
Copy link
Closed
Description
wiki#toc#gather_entries assumes ATX headers:
wiki.vim/autoload/wiki/toc.vim
Lines 153 to 156 in 0a16c4a
| " Parse current header | |
| let l:level = len(matchstr(l:line, '^#*')) | |
| let l:header = matchlist(l:line, g:wiki#rx#header_items)[2] | |
| let l:anchors[l:level] = l:header |
wiki.vim is meant to be filetype agostic, thus this should be generalized to allow other formats, as suggested by @saccarosium in #287.
Proposal: Add an option g:wiki_toc_header_format to allow other header formats, e.g.:
*g:wiki_toc_header_format*
Option to specify the header format used for parsing the table of contents.
Possible values:
atx ~
Atx headers are probably the most common header type in Markdown files
and look like this: >markdown
# Header level 1
## Header level 2
<
setext ~
Setext headers are common in Markdown files and look like this: >markdown
Header level 1
===
Header level 2
---
<
asciidoc ~
AsciiDoc headers are used in AsciiDoc files. They look like this: >asciidoc
= Document Title (level 0)
== Level 1 Section title
=== Level 2 Section title
<
One problem with using a global option is that one may want wiki.vim to work with different filetypes. Thus, it should be possible to also override the global option in any relavant commands, e.g. WikiTocGenerate:
*<plug>(wiki-toc-generate)*
*WikiTocGenerate*
`:[range]WikiTocGenerate [header_format]
Create/Update table of contents. The optional argument `header_format` allows
to override the header format specified in |g:wiki_toc_header_format|.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels