CJK Formatter Plugin

AI-generated summary

The fokx plugin, titled ‘CJK Formatter Plugin’, automatically reformats topic titles and post content containing mixed CJK (Chinese, Japanese, Korean) and Latin characters. It adds appropriate spacing between CJK (full-width) and Latin (half-width) characters, and corrects punctuation to match the adjacent character type — full-width next to CJK, half-width next to Latin — using the [autocorrect-rb](https://github.com/huacnlee/autocorrect/tree/main/auto correct-rb) library. The plugin activates on new or updated posts after installation. To apply formatting to existing posts, run rake cjk:reformat and rake posts:rebake. Users are strongly advised to review how autocorrect modifies content and to backup data before use. The plugin acknowledges contributions from huacnlee/autocorrect and openSUSE-zh/discourse-cjk-text-spacing. Installation instructions are available via How to install plugins in Discourse.

:information_source: Summary reformat topic titles and post texts with mixed CJK and Latin characters, support auto space padding and punctuations correction
:hammer_and_wrench: Repository Link https://github.com/fokx/discourse-cjk-formatter
:open_book: Install Guide How to install plugins in Discourse

Features

Writing mixed CJK(Chinese, Japanese, Korean) characters and Latin characters can be a pain because of the special effort to take on the format. This plugin comes in to automatically reformat topic titles and post contents for you, utilizing autocorrect-rb.

Every time a topic/post is created or updated, its content (and title) will get:

  • added space between CJK (full width) and Latin (half-width) character
  • corrected punctuation adjacent to CJK character into full-width
  • corrected punctuation adjacent to Latin character into half-width

Configuration

After installation, it will work for new posts.

To reformat all historic posts, use rake:

rake cjk:reformat
rake posts:rebake

Disclaimer

Before use, be sure to learn about how the autocorrect tool will modify your content and backup your data before continue!

Acknowledgement

4 Likes