Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Support HTML-in-Markdown #5161

Merged
merged 29 commits into from May 3, 2024
Merged

[Feature] Support HTML-in-Markdown #5161

merged 29 commits into from May 3, 2024

Conversation

beyackle2
Copy link
Contributor

@beyackle2 beyackle2 commented May 2, 2024

Changelog Entry

Breaking changes

  • HTML-in-Markdown is now supported. To disable this feature, set styleOptions.markdownRenderHTML to false

Added

Description

This enables rendering of HTML-based citations by porting our "better link" plug-in into a HTML mod. And providing a new styleOptions to disable this if needed.

Design

Porting "better link" plugin to a HTML mod

Today, the "better link" is a Markdown-It plugin. It can only apply to Markdown links but not <a>.

We are porting the "better link" into a HTML mod, so we can apply a few decorations to <a> in additional to Markdown links:

  • Adds aria-label/title (accessibility)
  • Changes link to a <button> (needed by citation)
  • Adds rel="noopener noreferer" and target="_blank" (security)
  • Adds "Open in external" icon (accessibility)

In future, we can apply "better link" and sanitization with a BYO Markdown engine. Today, the BYO engine need to do these job themselves.

Output of useRenderMarkdownAsHTML

Today, useRenderMarkdownAsHTML will emit <p>Hello, World!</p>.

As this HTML could be used in Adaptive Cards, and we are using CSS to apply "open in external" icon. We need to add a container around the emitted HTML to apply our CSS.

Tomorrow, it will emit <div class="webchat__render-markdown"><p>Hello, World!</p></div>.

The webchat__render-markdown is a "lightweight" container with CSS of display: contents.

Specific Changes

  • Added new styleOptions.markdownRenderHTML and default to true
  • Updated useRenderMarkdownAsHTML to emit HTML with a container
  • Ported "better link" plug-in to HTML mod
  • Updated snapshots related as links in Adaptive Cards will now have "open in external" icon
  • I have added tests and executed them locally
  • I have updated CHANGELOG.md
  • I have updated documentation

Review Checklist

This section is for contributors to review your work.

  • Accessibility reviewed (tab order, content readability, alt text, color contrast)
  • Browser and platform compatibilities reviewed
  • CSS styles reviewed (minimal rules, no z-index)
  • Documents reviewed (docs, samples, live demo)
  • Internationalization reviewed (strings, unit formatting)
  • package.json and package-lock.json reviewed
  • Security reviewed (no data URIs, check for nonce leak)
  • Tests reviewed (coverage, legitimacy)

@beyackle2 beyackle2 marked this pull request as ready for review May 2, 2024 23:50
compulim
compulim previously approved these changes May 3, 2024
@compulim compulim changed the title [Feature] modify BetterLink to improve HTML rendering in citations [Feature] Support HTML-in-Markdown May 3, 2024
@compulim compulim merged commit 84e32c9 into main May 3, 2024
25 checks passed
@compulim compulim deleted the feat-better-link-html-mod branch May 3, 2024 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants