Module: CustomFilters
- Includes:
- Jekyll::Filters
- Defined in:
- lib/liquidoc.rb
Overview
Extending Liquid filters/text manipulation
Instance Method Summary collapse
- #commentwrap(input) ⇒ Object
- #plainwrap(input) ⇒ Object
- #regexreplace(input, regex, replacement = '') ⇒ Object
- #slugify(input) ⇒ Object
-
#unwrap(input) ⇒ Object
Not fully functional; inserts explicit ‘n’.
Instance Method Details
#commentwrap(input) ⇒ Object
1079 1080 1081 |
# File 'lib/liquidoc.rb', line 1079 def commentwrap input input.wrap commentchar: "# " end |
#plainwrap(input) ⇒ Object
1076 1077 1078 |
# File 'lib/liquidoc.rb', line 1076 def plainwrap input input.wrap end |
#regexreplace(input, regex, replacement = '') ⇒ Object
1097 1098 1099 |
# File 'lib/liquidoc.rb', line 1097 def regexreplace input, regex, replacement='' input.to_s.gsub(Regexp.new(regex), replacement.to_s) end |
#slugify(input) ⇒ Object
1089 1090 1091 1092 1093 1094 1095 |
# File 'lib/liquidoc.rb', line 1089 def slugify input # Downcase # Turn unwanted chars into the seperator s = input.to_s.downcase s.gsub!(/[^a-zA-Z0-9\-_\+\/]+/i, "-") s end |
#unwrap(input) ⇒ Object
Not fully functional; inserts explicit ‘n’
1082 1083 1084 1085 1086 1087 |
# File 'lib/liquidoc.rb', line 1082 def unwrap input # Not fully functional; inserts explicit '\n' if input token = "[g59hj1k]" input.gsub(/\n\n/, token).gsub(/\n/, ' ').gsub(token, "\n\n") end end |