Module: TextUtils

Defined in:
lib/text_utils.rb,
lib/kit/kit_text_utils.rb

Defined Under Namespace

Classes: CodeHighlighter, CustomMarkdown, EnsureUtf, FormatQualifier, HtmlSanitizer, Markdown, Pipe, Processor, Truncate

Class Method Summary collapse

Class Method Details

.markup(data) ⇒ Object

TODO2 rename



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/kit/kit_text_utils.rb', line 6

def markup data
  ps = []
  ps << EnsureUtf
  ps << HtmlSanitizer
  ps << FormatQualifier
  ps << CodeHighlighter if rad.config.use_code_highlighter
  ps << CustomMarkdown
  ps << Markdown

  markup = Pipe.new *ps
  markup.call data
end

.truncate(data, length) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/kit/kit_text_utils.rb', line 20

def truncate data, length
  truncate = Pipe.new(
    EnsureUtf,
    HtmlSanitizer,
    FormatQualifier,
    [Truncate, length]
  )
  truncate.call data
end