Skip to content

Commit 8839752

Browse files
authored
Merge pull request #241 from vinta/fix/spacing-rules
Fix/spacing rules
2 parents fb3a4b1 + 1e5cafe commit 8839752

File tree

23 files changed

+431
-86
lines changed

23 files changed

+431
-86
lines changed

.claude/TODO.md

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,71 @@
1515

1616
- [x] Replace `tabs` permission with `activeTab` (removes "Read browsing history" warning)
1717
- [x] Implement dynamic content script registration with chrome.scripting API
18-
- [x] Optimize pangu.js loading with on-demand injection
18+
- [x] Optimize `pangu.js` loading with on-demand injection
19+
- [x] Skip auto spacing if there is no CJK content in webpages
1920

2021
### Match Pattern Implementation
2122

2223
- [x] Implement blacklist/whitelist with Chrome match pattern validation
2324
- [x] Use Chrome's `excludeMatches` API for efficient blacklist handling
2425
- [x] Add match pattern validation with helpful error messages
2526

27+
### Regex Pattern Fixes
28+
29+
- [x] Fixed `AN_LEFT_BRACKET` pattern to prevent adding spaces in function calls like `a.getB()`
30+
- Added negative lookbehind `(?<!\\.[A-Za-z0-9]*)` to exclude patterns after dots
31+
- [x] Fixed pipe character `|` handling - removed from operator patterns (#194)
32+
- [x] Fixed filesystem path patterns to support special characters like `@`, `+`, dots (#209, #218, #219)
33+
- Enhanced pattern to match paths like `/node_modules/@babel/core`
34+
- [x] Fixed HTML tag spacing - tags no longer get spaces inside them (#164)
35+
- Implemented placeholder system to protect HTML tags during processing
36+
- Attribute values still get processed for spacing
37+
- [x] Fixed input field auto-spacing (#158)
38+
- Added `input` to `ignoredTags` regex in browser implementation
39+
- Prevents spacing in form fields, login/registration forms
40+
- [x] Fixed slash pattern conflict with filesystem paths
41+
- Removed `/` from `CJK_ANS` pattern to prevent spacing in patterns like `陳上進/vinta`
42+
- Made filesystem path pattern more specific to avoid false matches
43+
- [x] Improved filesystem path pattern to be less aggressive
44+
- Changed from matching any `/something` to only known system directories
45+
- Removed the `FIX_NAME_SLASH` workaround as it's no longer needed
46+
- Pattern now only matches paths starting with system dirs like `/home`, `/usr`, `/etc`, or `/node_modules`
47+
2648
## In Progress
2749

28-
- [ ] None
50+
- [ ] None currently active
2951

3052
## Next Steps
3153

32-
### High Priority
54+
### High Priority - Unfixed Issues
3355

34-
- [ ] Generate different size icons from `icon_1500.svg`
35-
- [ ] Add a button for "Add this url to blacklist" in popup page or context menu
56+
- [ ] Fix issue #173 - Full-width curved quotes shouldn't have spaces
57+
- Full-width quotation marks (「」『』) are being incorrectly spaced
58+
- These are punctuation marks in CJK languages and shouldn't be separated
59+
60+
### Medium Priority - Unfixed Issues
61+
62+
- [ ] Fix issue #201 - Spaces inserted between image-separated text
63+
- When images are used as separators, unwanted spaces are added
64+
- [ ] Fix issue #207 - Breaking Bilibili upload page layout
65+
- Auto-spacing interferes with specific website functionality
66+
- May need site-specific rules or better element detection
3667

37-
### Medium Priority
68+
### Low Priority - Unfixed Issues
3869

39-
- [x] No need to perform spacing if there is no CJK in webpages
40-
- Implemented pageHasCJK() detection in BrowserPangu class
41-
- Added watchForCJKContent() for dynamic content monitoring
42-
- Saves processing time on pages without CJK content
70+
- [ ] Fix issue #169 - YouTube title persistence bug
71+
- Changes to YouTube titles don't persist
72+
- May be related to YouTube's dynamic content updates
73+
- [ ] Fix issue #216 - Add support for skipping Markdown syntax
74+
- Markdown formatting (like `**bold**`, `_italic_`) gets broken by spacing
75+
- Need to protect Markdown syntax during processing
76+
- [ ] Fix issue #161 - Markdown syntax support
77+
- Similar to #216, need comprehensive Markdown protection
78+
79+
### Feature Enhancements
80+
81+
- [ ] Generate different size icons from `icon_1500.svg`
82+
- [ ] Add a button for "Add this url to blacklist" in popup page or context menu
4383
- [ ] Improve `autoSpacingPage()` performance, especially with a large DOM tree
4484
- See @.claude/researches/performance-optimization.md
4585
- [ ] Add instructions in options page for enabling experimental CSS `text-autospace`

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
- Community support:
2424

25+
- [Paranoid Text Spacing](https://tools.1chooo.com/paranoid-text-spacing)
2526
- [盤古之白 - 文案排版轉換](https://pangu.serko.dev/)
2627

2728
### For Developers
@@ -57,7 +58,7 @@ Learn more on [npm](https://www.npmjs.com/package/pangu).
5758
```html
5859
<script src="pangu/dist/browser/pangu.umd.js"></script>
5960
<script>
60-
const text = pangu.spacing('當你凝視著bug,bug也凝視著你');
61+
const text = pangu.spacingText('當你凝視著bug,bug也凝視著你');
6162
// text = '當你凝視著 bug,bug 也凝視著你'
6263
6364
pangu.spacingElementById('main');
@@ -85,7 +86,7 @@ import pangu from 'pangu';
8586
// or
8687
const pangu = require('pangu');
8788

88-
const text = pangu.spacing('與PM戰鬥的人,應當小心自己不要成為PM');
89+
const text = pangu.spacingText('與PM戰鬥的人,應當小心自己不要成為PM');
8990
// text = '與 PM 戰鬥的人,應當小心自己不要成為 PM'
9091

9192
const content = await pangu.spacingFile('/path/to/text.txt');

browser_extensions/chrome/dist/content-script.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33
const DEFAULT_SETTINGS = {
44
spacing_mode: "spacing_when_load",
55
filter_mode: "blacklist",
6-
blacklist: ["*://docs.google.com/*", "*://gist.github.com/*", "*://github.com/*/blob/*", "*://github.com/*/commit/*", "*://github.com/*/pull/*"],
6+
blacklist: [
7+
"https://docs.google.com/*",
8+
"https://gist.github.com/*",
9+
"https://github.com/*/blob/*",
10+
"https://github.com/*/commit/*",
11+
"https://github.com/*/pull/*",
12+
"https://github.com/vinta/pangu.js/issues*",
13+
"https://www.netflix.com/*"
14+
],
715
whitelist: [],
816
is_mute_sound_effects: false,
917
is_enable_detect_cjk: false

browser_extensions/chrome/dist/utils/settings.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
const DEFAULT_SETTINGS = {
22
spacing_mode: "spacing_when_load",
33
filter_mode: "blacklist",
4-
blacklist: ["*://docs.google.com/*", "*://gist.github.com/*", "*://github.com/*/blob/*", "*://github.com/*/commit/*", "*://github.com/*/pull/*"],
4+
blacklist: [
5+
"https://docs.google.com/*",
6+
"https://gist.github.com/*",
7+
"https://github.com/*/blob/*",
8+
"https://github.com/*/commit/*",
9+
"https://github.com/*/pull/*",
10+
"https://github.com/vinta/pangu.js/issues*",
11+
"https://www.netflix.com/*"
12+
],
513
whitelist: [],
614
is_mute_sound_effects: false,
715
is_enable_detect_cjk: false

browser_extensions/chrome/src/utils/settings.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ import type { Settings } from './types';
33
export const DEFAULT_SETTINGS: Settings = {
44
spacing_mode: 'spacing_when_load',
55
filter_mode: 'blacklist',
6-
blacklist: ['*://docs.google.com/*', '*://gist.github.com/*', '*://github.com/*/blob/*', '*://github.com/*/commit/*', '*://github.com/*/pull/*'],
6+
blacklist: [
7+
'https://docs.google.com/*',
8+
'https://gist.github.com/*',
9+
'https://github.com/*/blob/*',
10+
'https://github.com/*/commit/*',
11+
'https://github.com/*/pull/*',
12+
'https://github.com/vinta/pangu.js/issues*',
13+
'https://www.netflix.com/*',
14+
],
715
whitelist: [],
816
is_mute_sound_effects: false,
917
is_enable_detect_cjk: false,

browser_extensions/chrome/vendors/pangu/pangu.umd.js

Lines changed: 29 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/browser/pangu.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/browser/pangu.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/browser/pangu.umd.js

Lines changed: 29 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/browser/pangu.umd.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)