diff --git a/CHANGELOG.md b/CHANGELOG.md index 789406c02..1b8ced65b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,23 @@ ## CHANGELOG +### `@krassowski/jupyterlab-lsp 3.3.1` (unreleased) + +- bug fixes: + + - LaTeX is now rendered in documentation panel of completer ([#506]) + - completion response returned as plain text use pre tag to retain whitespace formatting ([#506]) + - pre-formatted code font size was reduced to match font-size of the text in completion panel ([#506]) + +[#506]: https://github.com/krassowski/jupyterlab-lsp/pull/506 + ### `jupyter-lsp 1.1.3` (unreleased) - features: - add config for the classic notebook server extension ([#504]) +[#504]: https://github.com/krassowski/jupyterlab-lsp/pull/504 + ### `@krassowski/jupyterlab-lsp 3.3.0` (2021-01-31) - features: diff --git a/packages/completion-theme/style/index.css b/packages/completion-theme/style/index.css index 276993e23..d54145b82 100644 --- a/packages/completion-theme/style/index.css +++ b/packages/completion-theme/style/index.css @@ -28,3 +28,8 @@ content: 'Loading...'; color: #7f7f7f; } + +/* a workaround for code being larger font size than text in markdown-rendered panel */ +.jp-Completer-docpanel pre code { + font-size: 90%; +} diff --git a/packages/jupyterlab-lsp/src/features/completion/completion.ts b/packages/jupyterlab-lsp/src/features/completion/completion.ts index ef350df6b..95aa4164f 100644 --- a/packages/jupyterlab-lsp/src/features/completion/completion.ts +++ b/packages/jupyterlab-lsp/src/features/completion/completion.ts @@ -99,6 +99,7 @@ export class CompletionLabIntegration implements IFeatureLabIntegration { this.renderer = new LSPCompletionRenderer({ integrator: this, markdownRenderer: markdown_renderer, + latexTypesetter: this.renderMimeRegistry.latexTypesetter, console: console.scope('renderer') }); this.renderer.activeChanged.connect(this.active_completion_changed, this); diff --git a/packages/jupyterlab-lsp/src/features/completion/renderer.ts b/packages/jupyterlab-lsp/src/features/completion/renderer.ts index 6abee0be5..99ae8d862 100644 --- a/packages/jupyterlab-lsp/src/features/completion/renderer.ts +++ b/packages/jupyterlab-lsp/src/features/completion/renderer.ts @@ -52,10 +52,11 @@ export class LSPCompletionRenderer createDocumentationNode(item: LazyCompletionItem): HTMLElement { if (item.isDocumentationMarkdown) { + let documentation = item.documentation; this.options.markdownRenderer .renderModel({ data: { - 'text/markdown': item.documentation + 'text/markdown': documentation }, trusted: false, metadata: {}, @@ -63,10 +64,17 @@ export class LSPCompletionRenderer // empty } }) + .then(() => { + if (this.options.latexTypesetter && documentation.includes('$')) { + this.options.latexTypesetter.typeset( + this.options.markdownRenderer.node + ); + } + }) .catch(this.options.console.warn); return this.options.markdownRenderer.node; } else { - let node = document.createElement('div'); + let node = document.createElement('pre'); node.textContent = item.documentation; return node; } @@ -77,6 +85,7 @@ export namespace LSPCompletionRenderer { export interface IOptions { integrator: CompletionLabIntegration; markdownRenderer: IRenderMime.IRenderer; + latexTypesetter?: IRenderMime.ILatexTypesetter; console: ILSPLogConsole; } } diff --git a/python_packages/jupyter_lsp/setup.py b/python_packages/jupyter_lsp/setup.py index 2cc1b6949..50eb56ee3 100644 --- a/python_packages/jupyter_lsp/setup.py +++ b/python_packages/jupyter_lsp/setup.py @@ -20,6 +20,6 @@ ( "etc/jupyter/jupyter_notebook_config.d", ["jupyter_lsp/etc/jupyter_notebook_config.json"], - ) + ), ], )