diff options
author | Scott Lahteine <github@thinkyhead.com> | 2019-07-14 12:24:51 +0300 |
---|---|---|
committer | Scott Lahteine <github@thinkyhead.com> | 2019-07-14 12:24:51 +0300 |
commit | 145ea62b5c99110c239c3a3040feb0d864bdc822 (patch) | |
tree | 2defe8a182a0e16dd5997b7b6be192770d41248d /_plugins | |
parent | 2639b56857069a3d6df0e5694c3c17119449676d (diff) |
Improve json search
Diffstat (limited to '_plugins')
-rw-r--r-- | _plugins/indexify_filter.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/_plugins/indexify_filter.rb b/_plugins/indexify_filter.rb new file mode 100644 index 00000000..77df7f9c --- /dev/null +++ b/_plugins/indexify_filter.rb @@ -0,0 +1,18 @@ +module Jekyll + module IndexifyFilter + def indexify(input) + re0 = /<[^>]*>/ + re1 = /(\b(a[mnst]?|[a-z][a-z]|a(ll|nd|re)|but|can(\'t|not)?|d(id|oes)(n\'t)?|end|for|it\'?s|odd|the|use[ds]?|was|wh[oy]|your?|even|from|many|more|much|some|th[ae]n|that|the[my]|this|were|what|when|will|other|th[eo]se|the(ir|re)|users?|wh(ere|ich)|people|(al)?though)\b)|(\s+)/ + re2 = /!\[[^\]]+\]\([^\)]+\)\s*(\{[^\}]+\})?/ + re3 = /\[([^\]]+)\]\([^\)]+\)\s*(\{[^\}]+\})?/ + re4 = /\\q/ + re5 = /(EN|DIS)ABLED\(([^\)]+)\)/i + re6 = /([[:punct:]]|:| [a-z])[ \t\n]+|[\n\r]+|\\[nr]/ + re7 = /[`\(\)\[\]:]+/ + # This will be returned + input.downcase.gsub(re0, '').gsub(re1, ' ').gsub(re2, ' ').gsub(re3, '\1').gsub(re4, '\1').gsub(re5, '\2').gsub(re6, ' ').gsub(re7, '').split(' ').compact.uniq.join(' ') + end + end +end + +Liquid::Template.register_filter(Jekyll::IndexifyFilter) |