module JekyllPangu
Add a hook to automatically convert posts, pages and documents with their 'page.lang' setting to CJK, i.e., starting with zh, jp, or ko. TODO: Give an option to enable globally
Also provide a filter to manually call the function in templates.
The module Pangu is copied from the repo: github.com/dlackty/pangu.rb under MIT License. Then modified to use unicode 'u2006', i.e., “SIX-PER-EM SPACE” for better looking, as well as ignoring backquote '`' since it will be handled by <code> tags.
Constants
- CJK_BRACKETFIX_RE
- CJK_BRACKET_L_RE
- CJK_BRACKET_RE
- CJK_BRACKET_R_RE
- CJK_HASH_L_RE
- CJK_HASH_R_RE
- CJK_L_RE
- CJK_QUOTE_FIX_RE
- CJK_QUOTE_L_RE
- CJK_QUOTE_R_RE
- CJK_R_RE
Public Class Methods
spacing(text)
click to toggle source
# File lib/jekyll-pangu/pangu.rb, line 21 def self.spacing(text) text = text.dup text.gsub!(CJK_QUOTE_L_RE, "\\1\u2006\\2") text.gsub!(CJK_QUOTE_R_RE, "\\1\u2006\\2") text.gsub!(CJK_QUOTE_FIX_RE, "\\1\\3\\5") old_text = text new_text = old_text.gsub(CJK_BRACKET_RE, "\\1\u2006\\2\u2006\\4") text = new_text if old_text == new_text text.gsub!(CJK_BRACKET_L_RE, "\\1\u2006\\2") text.gsub!(CJK_BRACKET_R_RE, "\\1\u2006\\2") end text.gsub!(CJK_BRACKETFIX_RE, "\\1\\3\\5") text.gsub!(CJK_HASH_L_RE, "\\1\u2006\\2") text.gsub!(CJK_HASH_R_RE, "\\1\u2006\\3") text.gsub!(CJK_L_RE, "\\1\u2006\\2") text.gsub!(CJK_R_RE, "\\1\u2006\\2") text end