patch 9.1.1537: helptoc: still some issues when markdown code blocks
Commit:
https://github.com/vim/vim/commit/ea528a94825280ae35328a3f819845d5643cf351
Author: Christian Brabandt <[email protected]>
Date: Thu Jul 10 20:44:51 2025 +0200
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 <[email protected]>
diff --git a/runtime/pack/dist/opt/helptoc/autoload/helptoc.vim
b/runtime/pack/dist/opt/helptoc/autoload/helptoc.vim
index 1b3044a1a..cf31d33d2 100644
--- a/runtime/pack/dist/opt/helptoc/autoload/helptoc.vim
+++ b/runtime/pack/dist/opt/helptoc/autoload/helptoc.vim
@@ -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)
diff --git a/src/testdir/dumps/Test_helptoc_markdown_01.dump
b/src/testdir/dumps/Test_helptoc_markdown_01.dump
index fc6ad879d..dd5d9fc3e 100644
--- a/src/testdir/dumps/Test_helptoc_markdown_01.dump
+++ b/src/testdir/dumps/Test_helptoc_markdown_01.dump
@@ -1,20 +1,20 @@
-|#+0#e000e06#ffffff0| |M|y| |D|o|c|u|m|e|n|t| +0#0000000&@27|┌| |1|/|1|
|(|1|/|1|)| @2|p|r|e|s@1| |?| |f|o|r| |h|e|l|p| |─@1|┐
-| @40|│| |M+0#0000001#e0e0e08|y| |D|o|c|u|m|e|n|t| @18| +0#0000000#ffffff0|│
-|S|o|m|e| |t|e|x|t|.| @30|│| | +0#4040ff13&@29| +0#0000000&|│
-| @40|│| | +0#4040ff13&@29| +0#0000000&|│
+|#+0#e000e06#ffffff0| |H|e|a|d|i|n|g| |1| +0#0000000&@29|┌| |3|/|3|
|(|1|/|1|)| @2|p|r|e|s@1| |?| |f|o|r| |h|e|l|p| |─@1|┐
+| @40|│| |H|e|a|d|i|n|g| |1| @21|│
+|S|o|m|e| |t|e|x|t|.| @30|│| |A|n|o|t|h|e|r| |H|e|a|d|i|n|g| |1| @13|│
+| @40|│| |L+0#0000001#e0e0e08|a|s|t| |H|e|a|d|i|n|g| |1| @15|
+0#0000000#ffffff0|│
|`+0#e000e06&@2|v|i|m| +0#0000000&@34|│| | +0#4040ff13&@29| +0#0000000&|│
|#| |T|h|i|s| |i|s| |a| |V|i|m|9|S|c|r|i|p|t| |c|o|m@1|e|n|t| @10|│| |
+0#4040ff13&@29| +0#0000000&|│
|d|e|f| |M|y|F|u|n|c|(|)| @28|│| | +0#4040ff13&@29| +0#0000000&|│
| @1|#| |A|n|o|t|h|e|r| |c|o|m@1|e|n|t| @21|│| | +0#4040ff13&@29| +0#0000000&|│
|e|n|d@1|e|f| @34|│| | +0#4040ff13&@29| +0#0000000&|│
|`+0#e000e06&@2| +0#0000000&@37|│| | +0#4040ff13&@29| +0#0000000&|│
+|#+0#e000e06&| |A|n|o|t|h|e|r| |H|e|a|d|i|n|g| |1| +0#0000000&@21|│| |
+0#4040ff13&@29| +0#0000000&|│
+| @40|│| | +0#4040ff13&@29| +0#0000000&|│
+|`+0#e000e06&@2| +0#0000000&@37|│| | +0#4040ff13&@29| +0#0000000&|│
+|#| |T|h|i|s| |i|s| |a| |c|o|m@1|e|n|t| |i|n| |a| |c|o|d|e|b|l|o|c|k| @6|│| |
+0#4040ff13&@29| +0#0000000&|│
+|`+0#e000e06&@2| +0#0000000&@37|│| | +0#4040ff13&@29| +0#0000000&|│
+|#+0#e000e06&| |L|a|s|t| |H|e|a|d|i|n|g| |1| +0#0000000&@24|│| |
+0#4040ff13&@29| +0#0000000&|│
+|a|n|d| |m|o|r|e| |t|e|x|t| @27|│| | +0#4040ff13&@29| +0#0000000&|│
> @40|│| | +0#4040ff13&@29| +0#0000000&|│
-|~+0#4040ff13&| @39|│+0#0000000&| | +0#4040ff13&@29| +0#0000000&|│
-|~+0#4040ff13&| @39|│+0#0000000&| | +0#4040ff13&@29| +0#0000000&|│
-|~+0#4040ff13&| @39|│+0#0000000&| | +0#4040ff13&@29| +0#0000000&|│
-|~+0#4040ff13&| @39|│+0#0000000&| | +0#4040ff13&@29| +0#0000000&|│
-|~+0#4040ff13&| @39|│+0#0000000&| | +0#4040ff13&@29| +0#0000000&|│
-|~+0#4040ff13&| @39|│+0#0000000&| | +0#4040ff13&@29| +0#0000000&|│
-|~+0#4040ff13&| @39|│+0#0000000&| | +0#4040ff13&@29| +0#0000000&|│
|~+0#4040ff13&| @39|└+0#0000000&|─@31|┘
-|:|H|e|l|p|T|o|c| @48|1@1|,|0|-|1| @7|A|l@1|
+|:|H|e|l|p|T|o|c| @48|1|8|,|0|-|1| @7|A|l@1|
diff --git a/src/testdir/test_plugin_helptoc.vim
b/src/testdir/test_plugin_helptoc.vim
index eca0dda93..6d311aecd 100644
--- a/src/testdir/test_plugin_helptoc.vim
+++ b/src/testdir/test_plugin_helptoc.vim
@@ -8,15 +8,23 @@ func Test_helptoc_markdown_with_comments()
packadd helptoc
e Xmarkdown.md
call append(0, [
- \ '# My Document',
- \ '', 'Some text.',
+ \ '# Heading 1',
+ \ '',
+ \ 'Some text.',
\ '',
\ '```vim',
\ '# This is a Vim9Script comment',
\ 'def MyFunc()',
\ ' # Another comment',
\ 'enddef',
- \ '```'
+ \ '```',
+ \ '# Another Heading 1',
+ \ '',
+ \ '```',
+ \ '# This is a comment in a codeblock',
+ \ '```',
+ \ '# Last Heading 1',
+ \ 'and more text'
\])
END
diff --git a/src/version.c b/src/version.c
index 16d26f27f..7ff6845ea 100644
--- a/src/version.c
+++ b/src/version.c
@@ -719,6 +719,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1537,
/**/
1536,
/**/
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1uZwV3-00FF9w-AO%40256bit.org.