Skip to content

Commit

Permalink
Unescape non-breaking spaces (yegappan#514)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddominguez authored and Shane-XB-Qian committed Sep 1, 2024
1 parent 69f3678 commit a944454
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions autoload/lsp/markdown.vim
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ def Unescape(text: string, block_marker: string = ""): string
result = result->substitute(' \@<! \=\n', ' ', 'g')
# change hard line breaks
result = result->substitute(' \{2,}\n', '\n', 'g')
# replace non-breaking spaces with spaces
result = result->substitute('&nbsp;', ' ', 'g')
return result->substitute($'\\\({punctuation}\)', '\1', 'g')
enddef

Expand Down
17 changes: 16 additions & 1 deletion test/markdown_tests.vim
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,22 @@ def g:Test_Markdown()
[],
[{'col': 13, 'type': 'LspMarkdownCode', 'length': 15}]
]
]
],
[
# non-breaking space characters
# Input text
[
'&nbsp;&nbsp;This is text.',
],
# Expected text
[
' This is text.',
],
# Expected text properties
[
[]
]
],
]

var doc: dict<list<any>>
Expand Down

0 comments on commit a944454

Please sign in to comment.