Conversation
在文件名渲染阶段对书名字段进行后处理,自动移除括号及其内容。 功能特性: - 同时处理中文全角括号()和英文半角括号() - 支持嵌套括号递归处理 - 支持白名单关键词跳过(每行一个) - 默认关闭,需用户主动启用 - 主开关关闭时白名单设置项自动隐藏
增强功能: - 支持分别控制书名和作者的括号移除(默认仅处理书名) - 括号类型选择:All / Chinese only(()) / English only (()) - 英文括号前后空格清理开关 - 设置界面动态显示:父级开关关闭时子选项自动隐藏 默认值设计确保向后兼容: - removeParensFromTitle: true(与基础版行为一致) - removeParensFromAuthor: false(防止意外修改) - removeParensType: 'all'(最全面处理) - removeParensSpaces: true(更整洁输出)
There was a problem hiding this comment.
Pull request overview
This pull request adds a feature to automatically remove bracket content from book titles and author names when generating file names for Kindle highlights in Obsidian. The feature is designed to address the issue of excessively long or cluttered file names in the Chinese Kindle library, where book titles often include parenthetical annotations.
Changes:
- Added comprehensive bracket removal settings with fine-grained control (disabled by default, user opt-in required)
- Implemented bracket removal logic supporting both Chinese full-width brackets (()) and English brackets (())
- Added per-field control (title and author independently), bracket type selection, space cleanup, and whitelist functionality
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| styles.css | Added CSS styling for collapsible bracket settings section with border, hover states, and proper spacing |
| src/store/settingsStore.ts | Added six new settings properties for bracket removal configuration and corresponding setter methods |
| src/settings/index.ts | Implemented collapsible settings UI with toggles, dropdown, and textarea for bracket removal configuration |
| src/rendering/renderer/fileNameRenderer.ts | Implemented core bracket removal logic with nested bracket handling, whitelist support, and space management |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ntrols\n\nAdd automatic parentheses removal from book titles and author names when\ngenerating file names. Supports nested parentheses and whitelist keywords.\n\n- Handle both Chinese full-width () and English () parentheses\n- Per-field control for title and author\n- Recursive removal for nested parentheses\n- Whitelist keywords to skip removal (one per line, case-insensitive)\n- Disabled by default, user opt-in required\n- Hide settings when main toggle is off # Conflicts: # src/rendering/renderer/fileNameRenderer.ts # src/settings/index.ts # styles.css
|
Thank you so much for your contribution. Appreciate it. My first thoughts - if this is predominantly about sanitising book name for us in file name, then I think we can be opinionated abuot it and just do the trimming of the brackets without giving the user a lot of control. I would prefer to keep the settings as simple as possible. It also sounds that this could be a change that can be made to any book regardless of the language. So we can make this Chinese agnostic. What do you think? |
|
Hello, hadynz! I agree with your point: the settings can indeed be simplified further. Based on the way parentheses appear in most book titles, I could set it so that “Remove spaces around English brackets” is always enabled, and that parentheses are always removed from titles and other such content. The only remaining settings would be an option to specify “types of parentheses to remove” and a whitelist option for exceptions. Something along these lines:
Regarding your other question, the function for removing parentheses is not tied to “Chinese.” I’ve already set up separate options to remove either English (Half-width) or Chinese (Full-width) parentheses, so you don’t need to worry! |
Reduce the filename bracket cleanup surface to a single toggle, type selector, and whitelist.\nApply cleanup consistently to title and author, and add targeted tests for whitelist and fallback behavior.
Remove the bracket-type selector, keep only the whitelist when cleanup is enabled, and make bracket cleanup always strip both full-width and half-width bracketed content.


Many book titles in the Chinese Kindle library include parenthetical notes, and these parenthetical contents are written verbatim into Obsidian note filenames, resulting in excessively long filenames or filenames containing meaningless annotations. This feature allows users to automatically remove parentheses and their contents when generating filenames.
Add automatic bracket removal from book titles and author names
when generating file names. At the same time, a setting has been added to allow fine-grained control over whether to enable this feature.
Features: