Skip to content

Audio embeds#687

Merged
feruzm merged 3 commits intodevelopfrom
audio
Mar 4, 2026
Merged

Audio embeds#687
feruzm merged 3 commits intodevelopfrom
audio

Conversation

@feruzm
Copy link
Copy Markdown
Member

@feruzm feruzm commented Mar 4, 2026

Summary by CodeRabbit

  • New Features

    • 3Speak audio links and embeds are now automatically detected and converted into interactive audio players with playback controls.
    • Audio embeds include security sandbox attributes and automatic parameter normalization (iframe and mode handling) for consistent playback.
  • Tests

    • Added comprehensive test coverage for 3Speak audio link and iframe handling, including edge cases.
  • Chores

    • Package version and changelog updated.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 4, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9c76dcdc-1e29-4c3c-ada7-61e8746ae45d

📥 Commits

Reviewing files that changed from the base of the PR and between 866b967 and 3677464.

⛔ Files ignored due to path filters (6)
  • packages/render-helper/dist/browser/index.js is excluded by !**/dist/**
  • packages/render-helper/dist/browser/index.js.map is excluded by !**/dist/**, !**/*.map
  • packages/render-helper/dist/node/index.cjs is excluded by !**/dist/**
  • packages/render-helper/dist/node/index.cjs.map is excluded by !**/dist/**, !**/*.map
  • packages/render-helper/dist/node/index.mjs is excluded by !**/dist/**
  • packages/render-helper/dist/node/index.mjs.map is excluded by !**/dist/**, !**/*.map
📒 Files selected for processing (3)
  • packages/render-helper/CHANGELOG.md
  • packages/render-helper/package.json
  • packages/render-helper/src/methods/a.method.ts

📝 Walkthrough

Walkthrough

Adds support for 3Speak audio embeds: introduces two regex constants, updates anchor and iframe processing to detect and normalize 3Speak audio links/embeds (injecting iframes, classes, sandbox/frameborder, and query params), and adds test coverage for these cases.

Changes

Cohort / File(s) Summary
3Speak Audio Regex Constants
packages/render-helper/src/consts/regexes.const.ts
Added SPEAK_AUDIO_REGEX and SPEAK_AUDIO_EMBED_REGEX to detect 3Speak audio links and embed URLs.
Link Processing
packages/render-helper/src/methods/a.method.ts
Imported SPEAK_AUDIO_REGEX and added handling to convert matching 3Speak audio anchor elements (when text equals href) into markdown audio embeds: set classes (markdown-audio-link markdown-audio-link-speak), remove href, build iframe src with mode/iframe params, insert iframe, and return early.
Iframe Processing
packages/render-helper/src/methods/iframe.method.ts
Imported SPEAK_AUDIO_EMBED_REGEX and added handling for audio.3speak.tv embeds: normalize query params (iframe=1, default mode=compact when missing), set src, add class speak-audio-iframe, and apply frameborder="0" and sandbox attributes.
Tests
packages/render-helper/src/methods/a.method.spec.ts, packages/render-helper/src/methods/iframe.method.spec.ts
Added new test suites for 3Speak audio link-to-embed conversion and iframe normalization (permlink and CID variants, mode preservation, iframe param behavior). Note: duplicate test blocks were introduced in iframe.method.spec.ts.
Changelog & Version
packages/render-helper/CHANGELOG.md, packages/render-helper/package.json
Bumped package version to 2.4.21 and added changelog entry "Audio embeds (#687)".

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Audio embeds #687: Appears to add the same 3Speak audio support (regexes, a.method.ts and iframe.method.ts changes); likely the same or overlapping work.
  • Fix speak #661: Modifies 3Speak embed handling for video in the same anchor/iframe processing areas; may share normalization logic and test patterns.
  • SEO context for Quality #646: Touches the anchor-processing function in a.method.ts (SEO/external-link logic); changes could interact with the new audio link handling.

Poem

🐰 I found a stream on 3Speak's hill,
I stitched a regex, hummed a drill,
Links bloom into iframes bright,
Sandbox snug, mode set just right,
Hop — the audio sings until dusk's thrill.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Audio embeds' directly and clearly summarizes the main change: adding support for 3Speak audio embed handling across multiple files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch audio

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@feruzm feruzm marked this pull request as draft March 4, 2026 06:48
@feruzm feruzm marked this pull request as ready for review March 4, 2026 06:48
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/render-helper/src/methods/a.method.ts (1)

806-823: Consider using regex for parameter detection for consistency.

The current implementation uses .includes('iframe=') and .includes('mode=') for parameter detection, while iframe.method.ts uses regex patterns like /[?&]iframe=/. The .includes() approach could theoretically false-match substrings (e.g., ?noiframe=1), though this is unlikely with 3Speak URLs in practice.

For consistency with iframe.method.ts and slightly more robust matching:

♻️ Optional: Align parameter detection with iframe.method.ts
-    const embedSrc = href.includes('iframe=') ? href : `${href}&iframe=1`
-    const finalSrc = embedSrc.includes('mode=') ? embedSrc : `${embedSrc}&mode=compact`
+    const embedSrc = /[?&]iframe=/.test(href) ? href : `${href}&iframe=1`
+    const finalSrc = /[?&]mode=/.test(embedSrc) ? embedSrc : `${embedSrc}&mode=compact`
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/render-helper/src/methods/a.method.ts` around lines 806 - 823, The
parameter checks in the 3Speak audio branch use href.includes('iframe=') and
includes('mode=') which can false-match substrings; update the detection to use
query-param regexes like /[?&]iframe=/ and /[?&]mode=/ (consistent with
iframe.method.ts) when computing embedSrc and finalSrc (refer to the variables
href, embedSrc, finalSrc and the SPEAK_AUDIO_REGEX branch in a.method.ts); keep
the existing behavior of appending &iframe=1 and &mode=compact only when the
corresponding param is not present.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/render-helper/src/methods/a.method.ts`:
- Around line 806-823: The parameter checks in the 3Speak audio branch use
href.includes('iframe=') and includes('mode=') which can false-match substrings;
update the detection to use query-param regexes like /[?&]iframe=/ and
/[?&]mode=/ (consistent with iframe.method.ts) when computing embedSrc and
finalSrc (refer to the variables href, embedSrc, finalSrc and the
SPEAK_AUDIO_REGEX branch in a.method.ts); keep the existing behavior of
appending &iframe=1 and &mode=compact only when the corresponding param is not
present.

ℹ️ Review info
Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1873361e-8d50-4be5-bf88-dabfe0570597

📥 Commits

Reviewing files that changed from the base of the PR and between 373b9c2 and 866b967.

📒 Files selected for processing (5)
  • packages/render-helper/src/consts/regexes.const.ts
  • packages/render-helper/src/methods/a.method.spec.ts
  • packages/render-helper/src/methods/a.method.ts
  • packages/render-helper/src/methods/iframe.method.spec.ts
  • packages/render-helper/src/methods/iframe.method.ts

@feruzm feruzm added the patch Bug fixes and patches (1.0.0 → 1.0.1), add this only if any packages/ have patch changes in PR label Mar 4, 2026
@feruzm feruzm merged commit 2d5d72e into develop Mar 4, 2026
@feruzm feruzm deleted the audio branch March 4, 2026 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Bug fixes and patches (1.0.0 → 1.0.1), add this only if any packages/ have patch changes in PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant