patch 9.1.1537: helptoc: still some issues when markdown code blocks

Problem:  helptoc: still some issues when parsing markdown code blocks
          (VimWei)
Solution: assign nextline to curline before starting the next loop
          iteration; when processing fenced code blocks, flip the
          skip_fence variable, update the test to be more comprehensive

related: https://github.com/vim/vim/issues/17699#issuecomment-3055603968
closes: #17716

Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Christian Brabandt
2025-07-10 20:44:51 +02:00
parent 48d7f5b5a3
commit ea528a9482
4 changed files with 29 additions and 17 deletions

View File

@ -3,7 +3,7 @@ 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
# Latest Change: 2025 Jul 10
#
# Config {{{1
# g:helptoc {{{2
@ -523,12 +523,14 @@ def SetToc() #{{{2
# Special handling for markdown filetype using setext headings
if g:helptoc.type == 'markdown'
# ignore fenced codeblock lines
if curline =~ '^```.'
skip_fence = true
elseif curline =~ '^```$'
skip_fence = false
skip_fence = !skip_fence
endif
if skip_fence
curline = nextline
continue
endif
# Check for setext formatted headings (= or - underlined)