Repository: yamatoiizuka/palt-typesetting (ts)

Issue:
Remove thin spaces between Latin punctuation and Japanese segment
日本語と半角カンマ、ピリオドとの間に発生する四分アキを取り除く

## 現状
**入力**
```
ラテン, 日本語.
```

**出力**
```
ラテン<thin-space />, 日本語<thin-space />.
```

## 修正後
thin space が挿入されず、そのままのスペースを維持するように修正します。
**入力**
```
ラテン, 日本語.
```

**出力**
```
ラテン, 日本語.
```

Pull request:
Remove thin spaces between Latin punctuation and Japanese segment
Fix #209 

Patch:
diff --git a/src/util-regex.ts b/src/util-regex.ts
index ae1eae9..6296058 100644
--- a/src/util-regex.ts
+++ b/src/util-regex.ts
@@ -4,6 +4,16 @@
 export const latinRegex =
   /[\p{scx=Latin}0-9⁰¹²³⁴-⁾₀-₎¢¤$€£¥+−×÷=≠><≥≤±≈~¬∅∞∫∏∑√∂%‰@&.,:;!¡?¿'"‘’“”\-(){}[\]|/\\^_`*#\s]+/gu
 
+/**
+ * 読点類（ラテン文字）
+ */
+export const latinCommaRegex = /,/
+
+/**
+ * 句点類（ラテン文字）
+ */
+export const latinPeriodRegex = /\./
+
 /**
  * 日本語
  */
diff --git a/src/util-text-classes.ts b/src/util-text-classes.ts
index 77729d7..44fea00 100644
--- a/src/util-text-classes.ts
+++ b/src/util-text-classes.ts
@@ -65,7 +65,10 @@ const CharClass = {
    */
   startsWithPunctuation: (segment: string): boolean => {
     // periodsRegexとcommasRegexを組み合わせて一つの正規表現を作成
-    const combinedRegex = new RegExp(`^[${util.periodsRegex.source}${util.commasRegex.source}]`)
+    // 半角カンマ・ピリオドも含める
+    const combinedRegex = new RegExp(
+      `^[${util.periodsRegex.source}${util.commasRegex.source}${util.latinPeriodRegex.source}${util.latinCommaRegex.source}]`
+    )
     return combinedRegex.test(segment)
   },
 }


Test patch:
diff --git a/tests/insert-separators.test.ts b/tests/insert-separators.test.ts
index de1dc9d..2df740a 100644
--- a/tests/insert-separators.test.ts
+++ b/tests/insert-separators.test.ts
@@ -35,6 +35,20 @@ describe('insertSeparators', () => {
     expect(insertSeparatorsToText(currentText, nextText, options)).toEqual(expected)
   })
 
+  it('does not insert a thin space before a latin comma', () => {
+    const currentText = '文字'
+    const nextText = ','
+    const expected = '文字'
+    expect(insertSeparatorsToText(currentText, nextText, options)).toEqual(expected)
+  })
+
+  it('does not insert a thin space before a latin period', () => {
+    const currentText = '言語'
+    const nextText = '.'
+    const expected = '言語'
+    expect(insertSeparatorsToText(currentText, nextText, options)).toEqual(expected)
+  })
+
   it('does not insert a thin space before a line fead', () => {
     const currentText = 'です。'
     const nextText = '\n'