Skip to content

fix(core): convert multi-line tags in cleanBody#77

Open
abhay-codes07 wants to merge 1 commit into
dodopayments:mainfrom
abhay-codes07:fix/cleanbody-multiline-tags
Open

fix(core): convert multi-line tags in cleanBody#77
abhay-codes07 wants to merge 1 commit into
dodopayments:mainfrom
abhay-codes07:fix/cleanbody-multiline-tags

Conversation

@abhay-codes07

Copy link
Copy Markdown

Summary

cleanBody replaced 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 the s flag so multi-line tags are converted too.

Closes #76.

Changes

  • packages/core/src/text.ts: add the s (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.
  • Added two tests: a multi-line tag is converted, and adjacent tags are not merged.

Type

  • Bug fix (non-breaking)
  • New feature (non-breaking)
  • Breaking change
  • Spec change (requires bump in AEO_SPEC_VERSION)
  • Docs / examples / tooling only

Verification

  • bun run build passes
  • bun run test passes (core: 182 tests)
  • bun run typecheck passes
  • If touching examples: ran dualmark verify (no examples touched)
  • If touching /spec/: ran sync-spec (no spec files touched)

Changeset

  • Added a changeset (patch for @dualmark/core)

cc @thepushkaraj @aagarwal1012. Small core fix, keeps the existing single-line behavior identical.

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.
Copilot AI review requested due to automatic review settings July 1, 2026 02:28
@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

@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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 in cleanBody so . 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 thread packages/core/src/text.ts
Comment on lines +77 to 78
const re = new RegExp(`<${tag}>(.*?)<\\/${tag}>`, "gs");
out = out.replace(re, `${marker}$1${marker}`);
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.

cleanBody leaks raw tags when a tag spans multiple lines

2 participants