mirror of
https://github.com/vim/vim
synced 2025-07-15 16:51:57 +00:00
patch 9.1.1533: helptoc: does not handle code sections in markdown well
Problem: helptoc: does not handle code sections in markdown well (VimWei) Solution: Skip over fenced code sections (lacygoill), add a test. fixes: #17699 closes: #17710 Co-authored-by: lagygoill <lacygoill@lacygoill.me> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
@ -1,4 +1,10 @@
|
||||
vim9script noclear
|
||||
|
||||
# the Vim HelpTOC plugin, creates a table of contents in a popup
|
||||
# Maintainer: Vim project
|
||||
# Original Author: @lacygoill
|
||||
# Latest Change: 2025 Jul 09
|
||||
#
|
||||
# Config {{{1
|
||||
# g:helptoc {{{2
|
||||
# Create the g:helptoc dict (used to specify the shell_prompt and other
|
||||
@ -503,6 +509,7 @@ def SetToc() #{{{2
|
||||
l[0]->str2nr() - ll[0]->str2nr())
|
||||
|
||||
var skip_next: bool = false
|
||||
var skip_fence: bool = false
|
||||
|
||||
# Non-help headings processing
|
||||
for lnum: number in range(1, line('$'))
|
||||
@ -516,6 +523,14 @@ def SetToc() #{{{2
|
||||
|
||||
# Special handling for markdown filetype using setext headings
|
||||
if g:helptoc.type == 'markdown'
|
||||
if curline =~ '^```.'
|
||||
skip_fence = true
|
||||
elseif curline =~ '^```$'
|
||||
skip_fence = false
|
||||
endif
|
||||
if skip_fence
|
||||
continue
|
||||
endif
|
||||
# Check for setext formatted headings (= or - underlined)
|
||||
if nextline =~ '^\s\{0,3}=\+$' && curline =~ '\S'
|
||||
# Level 1 heading (one or more =, up to three spaces preceding)
|
||||
|
Reference in New Issue
Block a user