Sha256: 3b71d65062a29a41d3db4145e4c1cd45ea0c5a193961deb52b3b5e25d04a0a85
Contents?: true
Size: 1.8 KB
Versions: 1
Compression:
Stored size: 1.8 KB
Contents
require "pangu/version" module Pangu CJK_QUOTE_L_RE = /([\u3040-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])(["\'])/i CJK_QUOTE_R_RE = /(["\'])([\u3040-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])/i CJK_QUOTE_FIX_RE = /(["\']+)(\s*)(.+?)(\s*)(["\']+)/i CJK_BRACKET_RE = /([\u3040-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])([<\[\{\(]+(.*?)[>\]\}\)]+)([\u3040-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])/i CJK_BRACKETFIX_RE = /([<\[\{\(]+)(\s*)(.+?)(\s*)([>\]\}\)]+)/i CJK_BRACKET_L_RE = /([\u3040-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])([<>\[\]\{\}\(\)])/i CJK_BRACKET_R_RE = /([<>\[\]\{\}\(\)])([\u3040-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])/i CJK_HASH_L_RE = /([\u3040-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])(#(\S+))/i CJK_HASH_R_RE = /((\S+)#)([\u3040-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])/i CJK_L_RE = /([\u3040-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])([a-z0-9`@&%=\$\^\*\-\+\|\/\\])/i CJK_R_RE = /([a-z0-9`~!%&=;\|\,\.\:\?\$\^\*\-\+\/\\])([\u3040-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])/i def self.spacing(text) text = text.dup text.gsub!(CJK_QUOTE_L_RE, "\\1 \\2") text.gsub!(CJK_QUOTE_R_RE, "\\1 \\2") text.gsub!(CJK_QUOTE_FIX_RE, "\\1\\3\\5") old_text = text new_text = old_text.gsub(CJK_BRACKET_RE, "\\1 \\2 \\4") text = new_text if old_text == new_text text.gsub!(CJK_BRACKET_L_RE, "\\1 \\2") text.gsub!(CJK_BRACKET_R_RE, "\\1 \\2") end text.gsub!(CJK_BRACKETFIX_RE, "\\1\\3\\5") text.gsub!(CJK_HASH_L_RE, "\\1 \\2") text.gsub!(CJK_HASH_R_RE, "\\1 \\3") text.gsub!(CJK_L_RE, "\\1 \\2") text.gsub!(CJK_R_RE, "\\1 \\2") text end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pangu-1.0.0 | lib/pangu.rb |