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.
This commit is contained in:
Norbert Ormándi
2023-12-29 03:54:03 +01:00
committed by GitHub
parent 98aa85ed1f
commit 7462f88848
2 changed files with 24 additions and 21 deletions

View File

@@ -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`", "");

View File

@@ -398,27 +398,27 @@ function format_documentation(bbcode: string, classname: string) {
html = html.replace(match[0], make_codeblock(block, "csharp"));
}
html = html.replaceAll("<br/> ", "");
// [param <name>]
html = html.replaceAll(
/\[param\s+(@?[A-Z_a-z][A-Z_a-z0-9]*?)\]/g,
"<code>$1</code>"
);
// [method <name>]
html = html.replaceAll(
/\[method\s+(@?[A-Z_a-z][A-Z_a-z0-9]*?)\]/g,
`<a href="" onclick="inspect('${classname}', '$1')">$1</a>`
);
// [<reference>]
html = html.replaceAll(
/\[(\w+)\]/g,
`<a href="" onclick="inspect('$1')">$1</a>` // eslint-disable-line quotes
);
// [method <class>.<name>]
html = html.replaceAll(
/\[\w+\s+(@?[A-Z_a-z][A-Z_a-z0-9]*?)\.(\w+)\]/g,
`<a href="" onclick="inspect('$1', '$2')">$1.$2</a>` // eslint-disable-line quotes
);
html = html.replaceAll("<br/> ", "");
// [param <name>]
html = html.replaceAll(
/\[param\s+(@?[A-Z_a-z][A-Z_a-z0-9]*?)\]/g,
"<code>$1</code>"
);
// [method <name>]
html = html.replaceAll(
/\[method\s+(@?[A-Z_a-z][A-Z_a-z0-9]*?)\]/g,
`<a href="" onclick="inspect('${classname}', '$1')">$1</a>`
);
// [<reference>]
html = html.replaceAll(
/\[(\w+)\]/g,
`<a href="" onclick="inspect('$1')">$1</a>` // eslint-disable-line quotes
);
// [method <class>.<name>]
html = html.replaceAll(
/\[\w+\s+(@?[A-Z_a-z][A-Z_a-z0-9]*?)\.(\w+)\]/g,
`<a href="" onclick="inspect('$1', '$2')">$1.$2</a>` // eslint-disable-line quotes
);
return html;
}