Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MarlinFirmware/MarlinDocumentation.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Lahteine <github@thinkyhead.com>2019-07-14 12:24:51 +0300
committerScott Lahteine <github@thinkyhead.com>2019-07-14 12:24:51 +0300
commit145ea62b5c99110c239c3a3040feb0d864bdc822 (patch)
tree2defe8a182a0e16dd5997b7b6be192770d41248d /_plugins
parent2639b56857069a3d6df0e5694c3c17119449676d (diff)
Improve json search
Diffstat (limited to '_plugins')
-rw-r--r--_plugins/indexify_filter.rb18
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)