Skip to content

feat: add fail-safe Markdown punctuation mode - #131

Open
xuke57 wants to merge 1 commit into
runjuu:mainfrom
xuke57:codex/markdown-mode-pr
Open

feat: add fail-safe Markdown punctuation mode#131
xuke57 wants to merge 1 commit into
runjuu:mainfrom
xuke57:codex/markdown-mode-pr

Conversation

@xuke57

@xuke57 xuke57 commented Aug 30, 2026

Copy link
Copy Markdown

Summary

Adds an opt-in, system-wide Markdown Mode for CJK input sources.

When enabled, it replaces:

  • the middle-dot key (·) with a backtick
  • ¥ with $
  • with >
  • 【】 with []
  • typing inserts 《》

Other Chinese prose punctuation, including quotes and parentheses, remains unchanged.

Safety

Because punctuation replacement uses a keyboard event tap, this change is fail-open:

  • requires Input Monitoring and Accessibility permissions
  • refuses to enable while another Input Source Pro instance is running
  • marks generated events to prevent reprocessing
  • disables itself if macOS disables the event tap or handling exceeds 50 ms
  • resets the setting toggle and shows a visible safety warning

The existing per-app “Force English Punctuation” behavior is preserved.

Testing

  • xcodebuild -scheme "Input Source Pro" -configuration Debug test
  • Existing 48 tests passed
  • Manual single-instance verification with macOS Simplified Pinyin

@runjuu runjuu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for the contribution. I found several issues that need to be addressed before merging:

  1. Markdown Mode applies its ANSI-key map to every isCJKVR source, but that predicate includes Russian. With the standard Russian layout, ordinary letters such as ё, х, ъ, Б, and Ю are globally replaced. Please restrict the mode to supported Chinese input sources or resolve the actual character produced by the active layout.

  2. The 500 ms input-source cache is not invalidated when TIS changes sources. Switching quickly from Chinese to English can make Shift+comma insert 《》 instead of <; the reverse transition can miss a Markdown replacement. Please invalidate the cache on source changes or avoid it for non-identity Markdown substitutions.

  3. When permissions are missing, IndicatorVM immediately resets isMarkdownModeEnabled to false, while the permission buttons are only visible when that same setting is true. On a fresh permission state the toggle snaps off before the actionable controls render. Please provide a permission-request flow that remains accessible after rollback.

  4. The new timeout and tap-disabled shutdown path is mode-blind. A timeout while only the existing per-app .appEnglish mode is active disables that service and displays a Markdown safety warning. Please make the callback mode-aware and keep Markdown-specific state changes limited to Markdown failures.

  5. isMarkdownModeEnabled is missing from SettingsBackupPreferences, so settings export and scriptable restore do not preserve the new option. Please add the optional field to declaration, export, and apply paths, with a round-trip test.

The README should also retain the existing per-app Force English Punctuation documentation instead of describing the upstream project as a customized build.

I verified commit 950380a: Debug and Release builds, Xcode analysis, localization validation, and all 48 existing tests pass. The issues above are runtime and state-transition cases not covered by the current tests.

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.

2 participants