Remove markdown-it#5825
Merged
Merged
Conversation
f8754fb to
3a24ebd
Compare
Contributor
There was a problem hiding this comment.
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-linkfor DOM-based link decoration and fragment parsing/serialization. - Reworks
LocalizedString,InlineMarkdown, toast inline Markdown rendering, and retry-link rendering to usemicromark. - 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
undefinedthrough?? falsemakes unspecified decoration fields remove existing attributes. For example, callers that only addrel/targetwill now strip an existingaria-label,class, ortitlefrom the link. Leave attributes unchanged when the decoration field is omitted, and reservefalsefor explicit removal.
packages/component-better-link/src/betterLinkDocumentMod.ts:111 - The same
?? falsebehavior removes existingrel/targetattributes 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 setOrRemoveAttributetreats 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 anaria-labelwhile keeping the attribute present.
packages/component-better-link/src/betterLinkDocumentMod.ts:121- The denylist skips
constructor,proto, andprototype, but it misses the standard__proto__key. Since this code writes dynamic keys via bracket access, include__proto__in the forbidden set before assigning todatasetTarget.dataset.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
OEvgeny
reviewed
May 29, 2026
|
|
||
| const documentFragment = parseDocumentFragmentFromString(micromark(localized)); | ||
|
|
||
| betterLinkDocumentMod(documentFragment, (href, textContent) => { |
Collaborator
There was a problem hiding this comment.
In future we should fold it into some internal package as we have the mod in bundle as well.
OEvgeny
reviewed
May 29, 2026
OEvgeny
approved these changes
May 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog Entry
Changed
markdown-itand completed migration tomicromark, in PR #5825, by @compulimDescription
We have planned to fade out
markdown-itsince #5330. In this PR, we completely migrate offmarkdown-itby moving localization logic frommarkdown-ittomicromark.Design
Specific Changes
bundletocomponentuseLocalizernow usemicromarkinstead ofmarkdown-itdatasetoptions to "better link" modCHANGELOG.mdI have updated documentationReview Checklist
Accessibility reviewed (tab order, content readability, alt text, color contrast)Browser and platform compatibilities reviewedCSS styles reviewed (minimal rules, noz-index)Documents reviewed (docs, samples, live demo)Internationalization reviewed (strings, unit formatting)package.jsonandpackage-lock.jsonreviewedSecurity reviewed (no data URIs, check for nonce leak)