fix(core): convert multi-line tags in cleanBody#77
Open
abhay-codes07 wants to merge 1 commit into
Open
Conversation
The HTML-tag replacement regex in cleanBody lacked the dotAll flag, so a tag whose content spanned multiple lines was never matched and its raw markup leaked into the cleaned markdown. Add the s flag while keeping the lazy quantifier so multi-line tags are converted and adjacent tags are not merged.
|
@abhay-codes07 is attempting to deploy a commit to the Dodo Payments Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
Fixes @dualmark/core’s cleanBody so configured HTML-ish tags (e.g. <Highlighted>…</Highlighted>) are correctly replaced even when their contents span multiple lines.
Changes:
- Add the
s(dotAll) flag to the tag-replacement regex incleanBodyso.matches newlines. - Add tests covering multi-line tag conversion and ensuring adjacent tags are not merged.
- Add a changeset for a patch release of
@dualmark/core.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/core/src/text.ts | Updates the tag-replacement regex flags (adds dotAll) and documents the behavior. |
| packages/core/test/text.test.ts | Adds regression tests for multi-line tag replacement and lazy matching across adjacent tags. |
| .changeset/cleanbody-multiline-tags.md | Patch changeset documenting the bug fix for release notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+77
to
78
| const re = new RegExp(`<${tag}>(.*?)<\\/${tag}>`, "gs"); | ||
| out = out.replace(re, `${marker}$1${marker}`); |
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.
Summary
cleanBodyreplaced configured tags with a regex missing the dotAll flag, so a<Tag>…</Tag>whose content spanned multiple lines was left in the output as raw markup. This adds thesflag so multi-line tags are converted too.Closes #76.
Changes
packages/core/src/text.ts: add thes(dotAll) flag to the tag-replacement regex. The match stays lazy (.*?), so it still stops at the first closing tag and does not merge two adjacent tags.Type
AEO_SPEC_VERSION)Verification
bun run buildpassesbun run testpasses (core: 182 tests)bun run typecheckpassesdualmark verify(no examples touched)/spec/: ran sync-spec (no spec files touched)Changeset
@dualmark/core)cc @thepushkaraj @aagarwal1012. Small core fix, keeps the existing single-line behavior identical.