Skip to content

Commit 98dccae

Browse files
committed
Add support for Cyrillic in headings
1 parent c2444b1 commit 98dccae

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

ftplugin/markdown.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function! s:GetHeadingLevel(headingLine)
114114
endfunction
115115

116116
function! s:GetHeadingLinkGFM(headingName)
117-
let l:headingLink = tolower(a:headingName)
117+
let l:headingLink = tr(a:headingName, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")
118118

119119
" \_^ : start of line
120120
" _\+ : one of more underscore _
@@ -126,7 +126,7 @@ function! s:GetHeadingLinkGFM(headingName)
126126
" chinese chars are removed.
127127
" \\%#=0: allow this pattern to use the regexp engine he wants. Having
128128
" `set re=1` in the vimrc could break this behavior. cf. issue #19
129-
let l:headingLink = substitute(l:headingLink, "\\%#=0[^[:alnum:]\u00C0-\u00FF\u4e00-\u9fbf _-]", "", "g")
129+
let l:headingLink = substitute(l:headingLink, "\\%#=0[^[:alnum:]\u00C0-\u00FF\u0400-\u04ff\u4e00-\u9fbf _-]", "", "g")
130130
let l:headingLink = substitute(l:headingLink, " ", "-", "g")
131131

132132
if l:headingLink ==# ""

test/GFM.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* [1.1 heading with dot 2.1](#11-heading-with-dot-21)
1414
* [1.1](#11)
1515
* [heading with some "special" (yes, special) chars: les caractères unicodes](#heading-with-some-special-yes-special-chars-les-caractères-unicodes)
16-
* [heading with Cyrillic Б б](#heading-with-cyrillic--)
16+
* [heading with Cyrillic Б б](#heading-with-cyrillic-Б-б)
1717

1818
<!-- vim-markdown-toc -->
1919

test/test.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ call ASSERT(GetHeadingLinkTest("### ![vim-markdown-toc-img](/path/to/a/png)", "G
6565
call ASSERT(GetHeadingLinkTest("### ![](/path/to/a/png)", "GitLab") ==# "-2")
6666
call ASSERT(GetHeadingLinkTest("### 1.1", "GitLab") ==# "11")
6767
call ASSERT(GetHeadingLinkTest("### heading with some \"special\" \(yes, special\) chars: les caractères unicodes", "GitLab") ==# "heading-with-some-special-yes-special-chars-les-caractères-unicodes")
68+
call ASSERT(GetHeadingLinkTest("## heading with Cyrillic Б б", "GitLab") ==# "heading-with-cyrillic-Б-б")
6869

6970
" Redcarpet Test Cases
7071
call ASSERT(GetHeadingLinkTest("# -Hello-World-", "Redcarpet") ==# "hello-world")

0 commit comments

Comments
 (0)