From 7462f88848cb5ecf2967320d9fca886d89648ccd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norbert=20Orm=C3=A1ndi?= <60075235+DeszkaCodes@users.noreply.github.com> Date: Fri, 29 Dec 2023 03:54:03 +0100 Subject: [PATCH] Fix BBCode [br] not rendering in hover (#557) Fix BBCode [br] not rendering in hover. This is a workaround to the LSP's incorrect concatenation of doc-comments. --- src/lsp/GDScriptLanguageClient.ts | 3 ++ src/providers/documentation_builder.ts | 42 +++++++++++++------------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/lsp/GDScriptLanguageClient.ts b/src/lsp/GDScriptLanguageClient.ts index 7d399d7..ac8bf35 100644 --- a/src/lsp/GDScriptLanguageClient.ts +++ b/src/lsp/GDScriptLanguageClient.ts @@ -153,6 +153,9 @@ export default class GDScriptLanguageClient extends LanguageClient { // docstrings being displayed as titles value = value.replace(/\n[#]+/g, "\n"); + // fix bbcode line breaks + value = value.replaceAll("`br`", "\n\n"); + // fix bbcode code boxes value = value.replace("`codeblocks`", ""); value = value.replace("`/codeblocks`", ""); diff --git a/src/providers/documentation_builder.ts b/src/providers/documentation_builder.ts index 8673708..cfe6dc1 100644 --- a/src/providers/documentation_builder.ts +++ b/src/providers/documentation_builder.ts @@ -398,27 +398,27 @@ function format_documentation(bbcode: string, classname: string) { html = html.replace(match[0], make_codeblock(block, "csharp")); } -html = html.replaceAll("
", ""); -// [param ] -html = html.replaceAll( - /\[param\s+(@?[A-Z_a-z][A-Z_a-z0-9]*?)\]/g, - "$1" -); -// [method ] -html = html.replaceAll( - /\[method\s+(@?[A-Z_a-z][A-Z_a-z0-9]*?)\]/g, - `$1` -); -// [] -html = html.replaceAll( - /\[(\w+)\]/g, - `$1` // eslint-disable-line quotes -); -// [method .] -html = html.replaceAll( - /\[\w+\s+(@?[A-Z_a-z][A-Z_a-z0-9]*?)\.(\w+)\]/g, - `$1.$2` // eslint-disable-line quotes -); + html = html.replaceAll("
", ""); + // [param ] + html = html.replaceAll( + /\[param\s+(@?[A-Z_a-z][A-Z_a-z0-9]*?)\]/g, + "$1" + ); + // [method ] + html = html.replaceAll( + /\[method\s+(@?[A-Z_a-z][A-Z_a-z0-9]*?)\]/g, + `$1` + ); + // [] + html = html.replaceAll( + /\[(\w+)\]/g, + `$1` // eslint-disable-line quotes + ); + // [method .] + html = html.replaceAll( + /\[\w+\s+(@?[A-Z_a-z][A-Z_a-z0-9]*?)\.(\w+)\]/g, + `$1.$2` // eslint-disable-line quotes + ); return html; }