]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Unescape non-breaking spaces (#514)
authorDavid Dominguez <352985+ddominguez@users.noreply.github.com>
Fri, 14 Jun 2024 15:07:28 +0000 (11:07 -0400)
committerGitHub <noreply@github.com>
Fri, 14 Jun 2024 15:07:28 +0000 (08:07 -0700)
autoload/lsp/markdown.vim
test/markdown_tests.vim

index c7b11d6e3139de1f1e4bbdc758839c621042ce6b..fd73cee3ee39d744436ed1d7bfe35f83d8569b19 100644 (file)
@@ -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
 
index 9670565b67d9554832da969d793c5b6e6bffb3bb..59abfb60e24ed53f86e542bb700f427656b73c6b 100644 (file)
@@ -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>>