Skip to content

Remove markdown-it#5825

Merged
compulim merged 12 commits into
mainfrom
feat-remove-markdown-it
May 29, 2026
Merged

Remove markdown-it#5825
compulim merged 12 commits into
mainfrom
feat-remove-markdown-it

Conversation

@compulim
Copy link
Copy Markdown
Contributor

@compulim compulim commented May 12, 2026

Changelog Entry

Changed

  • Removed markdown-it and completed migration to micromark, in PR #5825, by @compulim

Description

We have planned to fade out markdown-it since #5330. In this PR, we completely migrate off markdown-it by moving localization logic from markdown-it to micromark.

Design

Specific Changes

  • Refactored "better link" mod from bundle to component
    • The key feature we use "better link" is for localizing "Send failed. Retry" prompt, which the "Retry" link is replaced as a button
  • useLocalizer now use micromark instead of markdown-it
  • Added new dataset options to "better link" mod
  • 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)

@compulim compulim force-pushed the feat-remove-markdown-it branch from f8754fb to 3a24ebd Compare May 29, 2026 08:52
@compulim compulim marked this pull request as ready for review May 29, 2026 09:01
Copilot AI review requested due to automatic review settings May 29, 2026 09:01
@compulim compulim changed the title [WIP] Remove markdown-it Remove markdown-it May 29, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR completes the migration away from markdown-it by moving localization and internal inline Markdown rendering to micromark, and by extracting shared link/document utilities into a new component-better-link package.

Changes:

  • Adds @msinternal/botframework-webchat-component-better-link for DOM-based link decoration and fragment parsing/serialization.
  • Reworks LocalizedString, InlineMarkdown, toast inline Markdown rendering, and retry-link rendering to use micromark.
  • Removes markdown-it-specific helpers, hooks, context values, and package dependencies.

Reviewed changes

Copilot reviewed 55 out of 58 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
packages/fluent-theme/src/components/preChatActivity/PreChatMessageActivity.tsx Adapts localizer argument to stricter string typing.
packages/fluent-theme/src/components/activity/CopilotMessageHeader.tsx Defaults bot title to an empty string for localizer compatibility.
packages/component/src/Utils/LocalizedString.tsx Reimplements localized Markdown rendering via micromark and better-link DOM decoration.
packages/component/src/Utils/InlineMarkdown.tsx Adds TSX micromark implementation for inline reference links.
packages/component/src/Utils/InlineMarkdown.js Removes old markdown-it implementation.
packages/component/src/Utils/betterLinks.ts Removes old markdown-it better-links plugin.
packages/component/src/Utils/walkMarkdownTokens.js Removes markdown token walker utility.
packages/component/src/Utils/walkMarkdownTokens.spec.js Removes tests for deleted token walker.
packages/component/src/Utils/updateMarkdownAttrs.js Removes markdown-it attribute updater.
packages/component/src/Utils/updateMarkdownAttrs.spec.js Removes tests for deleted updater.
packages/component/src/Utils/addTargetBlankToHyperlinks.ts Adds DOM-based target/rel link decoration.
packages/component/src/Utils/addTargetBlankToHyperlinks.spec.ts Adds replacement tests for DOM-based link decoration.
packages/component/src/Utils/addTargetBlankToHyperlinksMarkdown.js Removes markdown-it token-based link decoration.
packages/component/src/Utils/addTargetBlankToHyperlinksMarkdown.spec.js Removes tests for deleted markdown-it helper.
packages/component/src/providers/CustomElements/customElements/CodeBlock.ts Updates fragment parser import to new package.
packages/component/src/private/renderMarkdownInline.ts Adds standalone inline Markdown renderer for internal UI.
packages/component/src/hooks/useStreamingMarkdownWithDefinitions.ts Updates fragment parser import to new package.
packages/component/src/hooks/useRenderMarkdownAsHTML.ts Updates parser/serializer imports to new package.
packages/component/src/hooks/internal/WebChatUIContext.ts Removes internal markdown-it context fields.
packages/component/src/hooks/internal/useInternalRenderMarkdownInline.js Removes obsolete internal render hook.
packages/component/src/hooks/internal/useInternalMarkdownIt.js Removes obsolete markdown-it hook.
packages/component/src/Composer.tsx Removes markdown-it setup and context plumbing.
packages/component/src/boot/internal.ts Re-exports better-link utilities from the new package.
packages/component/src/BasicToaster.js Uses standalone inline Markdown renderer.
packages/component/src/BasicToast.js Uses standalone inline Markdown renderer.
packages/component/src/ActivityStatus/SendStatus/private/SendFailedRetry.tsx Adds TSX retry message component using InlineMarkdown.
packages/component/src/ActivityStatus/SendStatus/private/SendFailedRetry.js Removes old JS retry component.
packages/component/package.json Swaps markdown-it for micromark and new local package dependency.
packages/component-better-link/package.json Adds new better-link package manifest.
packages/component-better-link/tsup.config.ts Adds build config for the new package.
packages/component-better-link/src/tsconfig.json Adds TypeScript config for the new package.
packages/component-better-link/src/index.ts Exposes better-link package API.
packages/component-better-link/src/betterLinkDocumentMod.ts Centralizes DOM link decoration logic.
packages/component-better-link/src/*.spec.ts Adds/updates better-link behavior tests.
packages/component-better-link/src/private/copyAttribute.ts Adds attribute-copy helper for anchor-to-button conversion.
packages/component-better-link/src/private/copyAttribute.spec.ts Tests attribute-copy helper.
packages/component-better-link/src/parseDocumentFragmentFromString.ts Adds fragment parser utility.
packages/component-better-link/src/serializeDocumentFragmentIntoString.ts Adds fragment serializer utility.
packages/component-better-link/src/stripParagraphContainer.ts Adds paragraph wrapper stripping utility.
packages/component-better-link/.gitignore Adds package ignore rules.
packages/component-better-link/.eslintrc.yml Adds lint config for new package.
packages/bundle/src/markdown/renderMarkdown.ts Imports better-link decoration via component internal exports.
packages/bundle/src/markdown/createStreamingRenderer.ts Uses shared better-link decoration in streaming renderer.
packages/bundle/src/markdown/private/createDecorate.ts Updates better-link decoration type import.
packages/api/src/hooks/useLocalizer.ts Adds localizer overloads and refactors substitution handling.
package.json Registers new workspace and scripts.
package-lock.json Updates workspace and dependency lock data.
lint-staged.config.js Adds lint-staged rule for new package.
Comments suppressed due to low confidence (4)

packages/component-better-link/src/betterLinkDocumentMod.ts:76

  • Passing undefined through ?? false makes unspecified decoration fields remove existing attributes. For example, callers that only add rel/target will now strip an existing aria-label, class, or title from the link. Leave attributes unchanged when the decoration field is omitted, and reserve false for explicit removal.
    packages/component-better-link/src/betterLinkDocumentMod.ts:111
  • The same ?? false behavior removes existing rel/target attributes whenever a decorator omits those fields. That changes links even when the caller only intended another decoration, so omitted fields should be left unchanged.
    packages/component-better-link/src/betterLinkDocumentMod.ts:56
  • setOrRemoveAttribute treats an empty string as falsy and neither sets nor removes the attribute, even though the attribute setter type allows any string. This breaks legitimate empty-string values such as clearing an aria-label while keeping the attribute present.
    packages/component-better-link/src/betterLinkDocumentMod.ts:121
  • The denylist skips constructor, proto, and prototype, but it misses the standard __proto__ key. Since this code writes dynamic keys via bracket access, include __proto__ in the forbidden set before assigning to datasetTarget.dataset.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/component/src/Utils/addTargetBlankToHyperlinks.ts Outdated
Comment thread packages/component/src/Utils/InlineMarkdown.tsx Outdated
Comment thread packages/component/src/Utils/InlineMarkdown.tsx Outdated
Comment thread packages/component/src/Utils/InlineMarkdown.tsx Outdated
Comment thread packages/component/src/Utils/LocalizedString.tsx Outdated
Comment thread packages/api/src/hooks/useLocalizer.ts Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

const documentFragment = parseDocumentFragmentFromString(micromark(localized));

betterLinkDocumentMod(documentFragment, (href, textContent) => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In future we should fold it into some internal package as we have the mod in bundle as well.

Comment thread packages/component/src/Utils/LocalizedString.tsx
@compulim compulim merged commit 6bcfcee into main May 29, 2026
59 of 60 checks passed
@compulim compulim deleted the feat-remove-markdown-it branch May 29, 2026 18: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.

3 participants