Skip to content

Support rendering raw HTML tags that appear in a MarkdownString #40607

Closed

Description

From Michael Morrison (@borlak) on December 21, 2017 0:1

screen shot 2017-12-20 at 4 00 20 pm

In the screenshot, you can see the "p" and "br" tags are not rendered. I don't know if I need another extension to do this properly -- I searched the extensions and didn't see anything that seemed to fit.

I'm on a Mac, using Code version 1.19.1 and the intellisense extension version 2.1.0.

Copied from original issue: felixfbecker/php-language-server#557

Activity

  1. felixfbecker commented on Dec 21, 2017

    @felixfbecker
    ContributorAuthor

    This is controlled by vscode - Markdown can contain HTML, but vscode chooses to escape all HTML. Imo simple HTML like p/b/ul/li etc should be whitelisted, there are npm modules that do this easily.

  2. added
    extensions
    on Dec 21, 2017
  3. mjbvz commented on Dec 21, 2017

    @mjbvz
    Contributor

    Yes, this is by-design. Our built-in markdown parser for intellisense documentation explicitly disables html tags so that we maintain more control over the presentation. Is html documentation widely used in the php community?

  4. felixfbecker commented on Dec 21, 2017

    @felixfbecker
    ContributorAuthor

    I am using the same API stubs for the standard libraries that JetBrains PHPStorm is using, they use HTML everywhere unfortunately:

    https://github.com/JetBrains/phpstorm-stubs/blob/43061d78f1980dedab671a30b419074b9e6d79f8/Core/Core.php#L76-L95

    It would be really awesome if simple HTML tags could be whitelisted, e.g. with https://www.npmjs.com/package/sanitize-html

  5. jrieken commented on Jan 3, 2018

    @jrieken
    Contributor

    Fair, html to markdown to html sounds a little weird. One idea is to have HtmlString similar to MarkdownString

  6. felixfbecker commented on Jan 3, 2018

    @felixfbecker
    ContributorAuthor

    Well I don't know generally in advance what content the string is, and since markdown can contain HTML per spec, I don't think HtmlString is needed

  7. mjbvz commented on Jan 3, 2018

    @mjbvz
    Contributor

    I've had one or two issues about supporting html in jsdocs, but haven't seen that pattern being widespread enough to justify pushing for this. And all the requests were to support html tags like <b> or <img> or <p> which already have markdown equivalents.

    My questions and concerns:

    • How many extensions/use-cases would benefit from the change?
    • How painful are current workarounds?
    • Should there be multiple ways to express the same thing? (i.e. *text* and <i>text</i>) Which one would we encourage?
    • This would make the supported html subset part of the VS Code api. Do we want that?
    • Does this open us up too much to API creep, such as: why not whitelist <video> tags or style="color: red;" attributes?
  8. felixfbecker commented on Jan 3, 2018

    @felixfbecker
    ContributorAuthor

    How many extensions/use-cases would benefit from the change?

    Can't comment on that, but there are thousands of PHP devs who would benefit directly from this.

    How painful are current workarounds?

    I see only two options:

    • Change the complete PHPStorm stubs repo to pure markdown. Not an option.
    • Use an HTML-to-markdown converter to optimistically convert it. Problem would be first detecting HTML in the first place and then not escaping existing markdown parts. Might actually be impossible. Will have a perf impact.

    Should there be multiple ways to express the same thing? (i.e. text and text) Which one would we encourage?
    This would make the supported html subset part of the VS Code api. Do we want that?

    I don't think vscode needs to be concerned with that. The markdown spec allows HTML to be used, LSP uses markdown, so vscode should support markdown as full as possible.

    Does this open us up too much to API creep, such as: why not whitelist

    It should be possible to strike a reasonable balance here. sanitize-html has some reasonable defaults that can serve as an inspiration: https://www.npmjs.com/package/sanitize-html#what-are-the-default-options

    allowedTags: [ 'h3', 'h4', 'h5', 'h6', 'blockquote', 'p', 'a', 'ul', 'ol',
      'nl', 'li', 'b', 'i', 'strong', 'em', 'strike', 'code', 'hr', 'br', 'div',
      'table', 'thead', 'caption', 'tbody', 'tr', 'th', 'td', 'pre' ],
    allowedAttributes: {
      a: [ 'href', 'name', 'target' ],
      // We don't currently allow img itself by default, but this
      // would make sense if we did
      img: [ 'src' ]
    },
    // Lots of these won't come up by default because we don't allow them
    selfClosing: [ 'img', 'br', 'hr', 'area', 'base', 'basefont', 'input', 'link', 'meta' ],
    // URL schemes we permit
    allowedSchemes: [ 'http', 'https', 'ftp', 'mailto' ],
    allowedSchemesByTag: {},
    allowProtocolRelative: true

    With some slight modifications given this is running in an editor, not a browser (e.g. we clearly don't need target, meta etc)

  9. added
    under-discussion
    on Jan 4, 2018
  10. changed the title [-]HTML inside intellisense popup not rendering[/-] [+]HTML inside hover/signature help markdown not rendering[/+] on Feb 28, 2018
  11. changed the title [-]HTML inside hover/signature help markdown not rendering[/-] [+]HTML inside hover/signature help markdown is not rendered[/+] on Feb 28, 2018
  12. DanTup commented on Mar 7, 2018

    @DanTup
    Contributor

    Hit this in Dart too:

    Dart-Code/Dart-Code#638

    Though our use is even more weird, because the API docs have this:

    /// <p><i class="material-icons md-36">access_alarms</i> &#x2014; material icon named "access alarms".</p>
    static const IconData access_alarms = const IconData(0xe191, fontFamily: 'MaterialIcons');
    

    I'm not sure how to handle this. It basically comes with a requirement of some custom CSS for it to render correctly.

  13. jrieken commented on Mar 8, 2018

    @jrieken
    Contributor

    requirement of some custom CSS for it to render correctly

    It is a lot, lot less likely that we will support custom, free form CSS there

  14. 28 remaining items

  15. DanTup commented on Sep 6, 2021

    @DanTup
    Contributor

    Matt Bierner (@mjbvz) would this also be supported via LSP?

  16. mjbvz commented on Sep 7, 2021

    @mjbvz
    Contributor

    Please file a separate feature request against the LSP. I imagine the API would look similar but folks on the LSP side would have to confirm this feature makes sense for them

  17. DanTup commented on Sep 8, 2021

    @DanTup
    Contributor
  18. changed the title [-]HTML inside hover/signature help markdown is not rendered[/-] [+]Support rendering raw HTML tags that appear in a MarkdownString[/+] on Oct 4, 2021
  19. added and removed
    under-discussion
    on Oct 12, 2021
  20. added
    unreleased
    insiders-released
    and removed
    unreleased
    on Oct 12, 2021
  21. locked and limited conversation to collaborators on Nov 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

apiapi-finalizationeditor-hoverextensionsinsiders-releasedon-testplan

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions