intersystems / language-server

Repository for the VS Code Language Server
https://marketplace.visualstudio.com/items?itemName=intersystems.language-server
Other
16 stars 6 forks source link

Preserve empty `<span>` elements in hover documentation #266

Closed gjsjohnmurray closed 1 year ago

gjsjohnmurray commented 1 year ago

Continuing from #265, VS Code permits a syntax for displaying codicons in the hover markdown. But turndown is removing the empty <span> element it relies on:

/// <p>This works, but displays an underline character I don't want: <span class="codicon codicon-source-control">_</span></p>
/// <p>This doesn't work (no codicon shows) because of turndown's 'blank' rule: <span class="codicon codicon-source-control"></span></p>

image

An (untested) change at this line might work: https://github.com/intersystems/language-server/blob/83358d6f1f1aea08a4aef091519968f0489eb26f/server/src/utils/functions.ts#L18

    const turndown = new TurndownService({
            codeBlockStyle: "fenced",
            blankReplacement: function (content, node) {
                return node.nodeName === 'SPAN' ? node.outerHTML : ''
            },
        });
isc-bsaviano commented 1 year ago

@gjsjohnmurray I'm a little hesitant to make this change. I don't think we should encouraging people to put VS Code-specific HTML in Documatic. Any number of clients could be trying to render that HTML.

gjsjohnmurray commented 1 year ago

Yes, the mechanism I want to leverage here is VS Code-specific, but it will fall back harmlessly in other contexts (e.g. Documatic web browser).

isc-bsaviano commented 1 year ago

Since the empty span is harmless in Documatic I'll make this change.