Skip to content

[Romaine] 撳複製撳鈕个時節,保留斷行#224

Merged
GJRobert merged 1 commit intomainfrom
jules-5232764111664409179-7f0b79db
Apr 6, 2026
Merged

[Romaine] 撳複製撳鈕个時節,保留斷行#224
GJRobert merged 1 commit intomainfrom
jules-5232764111664409179-7f0b79db

Conversation

@Aiuanyu
Copy link
Copy Markdown
Owner

@Aiuanyu Aiuanyu commented Apr 5, 2026

This change modifies the copyRomanizerResult function in js/romanizer.js to ensure that line breaks are preserved when the user copies the conversion results. It replaces <br> elements with newlines in the cloned DOM node and updates the whitespace cleaning regex to only collapse horizontal whitespace, preserving existing \n characters.

Fixes #223


PR created automatically by Jules for task 5232764111664409179 started by @Aiuanyu

- 修正 Romanizer (Romaine) 複製功能會拿忒斷行个問題
- 在複製前將 <br> 標籤轉做 \n
- 更新正規表示式以淨清理水平空白,保留換行符號

Co-authored-by: Aiuanyu <93833368+Aiuanyu@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 5, 2026

Deploying hakspring with  Cloudflare Pages  Cloudflare Pages

Latest commit: e9a721c
Status: ✅  Deploy successful!
Preview URL: https://fe0edb33.hakspring.pages.dev
Branch Preview URL: https://jules-5232764111664409179-7f.hakspring.pages.dev

View logs

@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@claude
Copy link
Copy Markdown

claude bot commented Apr 5, 2026

Code review for PR 224 - see full review in next comment

@claude
Copy link
Copy Markdown

claude bot commented Apr 5, 2026

Overall: Clean, well-targeted fix. Approach is correct, changes are minimal. What is done well: (1) Correct approach - Cloning the DOM and replacing br elements with newlines before reading textContent is the right way to preserve line breaks. (2) Regex fix is accurate - the pattern /[^\S\r\n]+/g correctly collapses only horizontal whitespace while leaving newlines intact, better than the previous /\s+/g which erased newlines. (3) Minimal footprint - only touches what is needed. Edge cases to consider: (1) Multiple consecutive br tags will produce multiple newlines (blank lines). If the romanizer can emit adjacent br elements, consider capping: textToCopy.replace(/\n{3,}/g, '\n\n'). Minor polish, not a blocker. (2) .trim() strips leading/trailing newlines - generally correct for clipboard content, just confirming it is intentional. (3) The \r in the regex is a safe no-op since textContent returns \n not \r\n in the DOM. Verdict: Correctly addresses issue 223. No security, performance, or correctness concerns. Recommend approval.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the text copying logic in js/romanizer.js to preserve line breaks. It converts
elements to newlines and adjusts the whitespace cleaning regex to target only horizontal whitespace. I have no feedback to provide.

@GJRobert GJRobert merged commit 36acbaf into main Apr 6, 2026
3 checks passed
@GJRobert GJRobert deleted the jules-5232764111664409179-7f0b79db branch April 6, 2026 02:12
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.

[Romaine] 撳複製撳鈕个時節,保留斷行

2 participants