Skip to content

Bracket#332

Open
ProudBenzene wants to merge 5 commits intohadynz:masterfrom
ProudBenzene:bracket
Open

Bracket#332
ProudBenzene wants to merge 5 commits intohadynz:masterfrom
ProudBenzene:bracket

Conversation

@ProudBenzene
Copy link
Copy Markdown

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:

  • Remove Chinese full-width brackets and/or English brackets
  • Per-field control (title and author independently)
  • Bracket type selection (All / Chinese only / English only)
  • Optional space cleanup around English brackets
  • Whitelist keywords to skip removal
  • Collapsible settings section for bracket removal options
  • Disabled by default, user opt-in required
image

在文件名渲染阶段对书名字段进行后处理,自动移除括号及其内容。

功能特性:
- 同时处理中文全角括号()和英文半角括号()
- 支持嵌套括号递归处理
- 支持白名单关键词跳过(每行一个)
- 默认关闭,需用户主动启用
- 主开关关闭时白名单设置项自动隐藏
增强功能:
- 支持分别控制书名和作者的括号移除(默认仅处理书名)
- 括号类型选择:All / Chinese only(()) / English only (())
- 英文括号前后空格清理开关
- 设置界面动态显示:父级开关关闭时子选项自动隐藏

默认值设计确保向后兼容:
- removeParensFromTitle: true(与基础版行为一致)
- removeParensFromAuthor: false(防止意外修改)
- removeParensType: 'all'(最全面处理)
- removeParensSpaces: true(更整洁输出)
Copilot AI review requested due to automatic review settings February 19, 2026 08:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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
@hadynz
Copy link
Copy Markdown
Owner

hadynz commented Feb 21, 2026

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?

@ProudBenzene
Copy link
Copy Markdown
Author

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:

  • Types of Parentheses to Remove
    • None
    • English (Half-width)
    • Chinese (Full-width)
    • All
  • WhiteList

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.
@ProudBenzene
Copy link
Copy Markdown
Author

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’ve just made some further changes to the code: I’ve simply removed the original “Select Title or Author” and “Chinese/English Parentheses” options. With these changes, there’s now only a single “remove brackets” option, along with a whitelist that appears only when the option is enabled.

image image

Changes made:

  • simplified the feature to a single opt-in toggle plus a whitelist
  • removed the bracket-type selector and now always trim both full-width and half-width bracket content
  • kept the behavior language-agnostic rather than Chinese-specific
  • applied the cleanup consistently to both title and author
  • added focused tests for whitelist handling, nested brackets, and fallback behavior

So the current version is much more opinionated and closer to a filename sanitization feature than a highly configurable formatter.

What are your thoughts on this change, and do you have any additional requirements for this feature?

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.

3 participants