feat: add Chinese line break restoration for highlight text#333
Open
ProudBenzene wants to merge 4 commits into
Open
feat: add Chinese line break restoration for highlight text#333ProudBenzene wants to merge 4 commits into
ProudBenzene wants to merge 4 commits into
Conversation
Kindle strips original line breaks from highlight text and replaces them with spaces. In Chinese text, a space after sentence-ending punctuation (。!?…」』)】) is a reliable signal of an original line break, since Chinese text normally has no inter-sentence spaces. - Add restoreChineseLineBreaks() function in parseBooks.ts - Apply restoration during highlight text processing when enabled - Add settings toggle (disabled by default)
There was a problem hiding this comment.
Pull request overview
This PR adds a feature to restore line breaks in Chinese highlight text that Kindle strips out during the export process. When Kindle exports highlights, it replaces original line breaks with spaces. In Chinese text, this creates an unusual pattern where spaces appear after sentence-ending punctuation (。!?…」』)】), which normally don't have spaces between them. The feature detects these patterns and restores the line breaks.
Changes:
- Added
restoreChineseLineBreaks()function to detect and restore line breaks in Chinese text based on punctuation patterns - Added a new boolean setting
restoreChineseLineBreaks(disabled by default) to the settings store - Added a toggle in the settings UI to enable/disable the feature
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/sync/syncClippings/parseBooks.ts | Implements the Chinese line break restoration function and integrates it into the highlight text processing pipeline |
| src/store/settingsStore.ts | Adds the restoreChineseLineBreaks setting field, default value, and setter function |
| src/settings/index.ts | Adds the UI toggle for the new setting in the settings panel |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… based on PR review
Document that the feature is an opt-in punctuation heuristic, keep it from rewriting existing newlines, and extend tests around mixed CJK content and preserved line breaks.
Rename the line break restoration setting, store field, utility, and tests to use CJK terminology and clarify the user-facing description accordingly.
Author
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.

Kindle strips original line breaks from highlight text and replaces them with spaces. In Chinese text, a space after sentence-ending punctuation (。!?…」) is a reliable signal of an original line break, since Chinese text normally has no inter-sentence spaces.