Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

改行問題に対応するためJSDOMから変更 #147

Merged
merged 1 commit into from
Aug 3, 2024

Conversation

ttizze
Copy link
Owner

@ttizze ttizze commented Aug 3, 2024

Closes #144

Summary by CodeRabbit

### リリースノート

#### New Feature
- `extractNumberedElements`関数がHTML解析に`htmlparser2`を使用するように変更され、`data-number`属性を持つ要素のテキスト内容を収集する機能が追加されました。

#### Refactor
- `generateSystemMessage`関数の出力フォーマットに関する指示が追加され、テキスト内の改行文字(\n)をそのまま保持して出力するように修正されました。

Copy link

github-actions bot commented Aug 3, 2024

This PR is linked to issue #144

Copy link

github-actions bot commented Aug 3, 2024

Image description CodeRabbit

### ウォークスルー
この変更では、HTMLコンテンツの解析に使用するパーサーを`jsdom`から`htmlparser2`に変更し、特定の属性を持つ要素のテキスト内容を収集する機能が強化されました。また、システムメッセージ生成関数の出力フォーマットに関する指示が追加され、改行文字を保持するようになりました。

### 変更点

| ファイル | 要約 |
| --- | --- |
| web/app/feature/translate/utils/extractNumberedElements.ts | `extractNumberedElements`関数が`jsdom`から`htmlparser2`に変更され、`data-number`属性を持つ要素を検出し、そのテキスト内容を収集するようになりました。 |
| web/app/feature/translate/utils/generateGeminiMessage.ts | `generateSystemMessage`関数の出力フォーマットに関する指示が追加され、改行文字を保持するようになりました。 |

Uplevel your code reviews with CodeRabbit Pro

CodeRabbit Pro

If you like this project, please support us by purchasing the Pro version. The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. Moreover, CodeRabbit Pro is free for open source projects.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Image description CodeRabbit

Commits Files that changed from the base of the PR and between 2d46801 and 2b873df commits.
Files selected (2)
  • web/app/feature/translate/utils/extractNumberedElements.ts (1)
  • web/app/feature/translate/utils/generateGeminiMessage.ts (2)
Review comments generated (12)
  • Review: 1
  • LGTM: 11

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

Comment on lines +24 to +28
ontext(text) {
if (inNumberedElement) {
currentText.push(text.trim());
}
},
Copy link

Choose a reason for hiding this comment

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

Image description CodeRabbit

26行目のtext.trim()は、テキスト内のすべての空白を削除してしまう可能性があります。改行タグ(
)の処理と矛盾する可能性があるため、ここではtrimを使用しない方が良いでしょう。

-					currentText.push(text.trim());
+					currentText.push(text);

@ttizze ttizze changed the title refactor: Update extractNumberedElements to use htmlparser2 for parsing HTML content 改行問題に対応するためJSDOMから変更 Aug 3, 2024
@ttizze ttizze merged commit 1736ee2 into main Aug 3, 2024
6 checks passed
@ttizze ttizze deleted the ttizze/fix-issue-144 branch August 3, 2024 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

翻訳テキストの改行が正しくない
1 participant