Skip to content

math_script_insensitive: Unicode coverage audit — combining macron (X̄), Greek subscripts U+1D66..U+1D6A, U+2094 schwa (cross-repo with ooxml-swift) #148

Description

@kiki830621

Problem

From verify of #115 (DA P2 #2 + Codex P2 #3):
「lib 的 mathScriptVariantMap 是手動列舉式,漏掉:(a) combining macron U+0304 — issue body 明確列 X̄ = X + ̄ 為典型 anchor pattern;(b) Greek subscripts U+1D66..U+1D6A (ᵦᵧᵨᵩᵪ) — 統計/物理論文 ΣᵦΠᵧ 等常用標記;(c) U+2094 (subscript schwa) — 罕見但若驗收標準是『完整 U+2090..U+209C』,這裡還不完整。」
— Source: team:devils-advocate (P2) + codex (P2/P3)
Verify report: #115 (comment)

Type

enhancement / cross-repo (ooxml-swift + che-word-mcp)

Affected location

  • packages/ooxml-swift/Sources/OOXMLSwift/Models/InsertLocation.swift:75-90 (mathScriptVariantMap)
  • Sources/CheWordMCP/Server.swift schema descriptions (跟 issue P3 配合)

Strategy

1. NFD normalization for combining marks

Combining macron U+0304 必須先 Unicode NFD decompose 再 strip。 在 NFC 是 X + ̄(2 char),NFD 同樣。strip combining marks 後得到 X。建議:

extension String {
    var stripCombiningMarks: String {
        let nfd = self.decomposedStringWithCanonicalMapping  // NSString.precomposedStringWithCanonicalMapping
        return String(nfd.unicodeScalars.filter { !$0.properties.isDiacritic })
    }
}

// In matcher:
let canonicalNeedle = mapToAscii(needle.stripCombiningMarks)
let canonicalHaystack = mapToAscii(haystack.stripCombiningMarks)

2. Greek subscript range U+1D66..U+1D6A

Code Char ASCII map
U+1D66 β
U+1D67 γ
U+1D68 ρ
U+1D69 φ
U+1D6A χ

加進 mathScriptVariantMap

3. U+2094 subscript schwa

(0x2094, "ə")

Test

  • (combining macron) flag on → match H
  • X̄ + Ȳ flag on → match needle X + Y
  • Σᵦ flag on → match Σβ
  • aₔb flag on → match aəb
  • 跨 case:X flag on 雙向 match

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions