Class: Togglate::BlockWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/togglate/block_wrapper.rb

Instance Method Summary collapse

Constructor Details

#initialize(text, wrapper: %w(<!--original -->),, pretext: "[translation here]", wrap_exceptions: [], **opts) ⇒ BlockWrapper



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/togglate/block_wrapper.rb', line 4

def initialize(text,
               wrapper:%w(<!--original -->),
               pretext:"[translation here]",
               wrap_exceptions:[],
               **opts)
  @text = text
  @wrapper = wrapper
  @pretext = pretext
  @translate = set_translate_opt(opts[:translate])
  @timeout = opts.fetch(:timeout, 5)
  @email = opts[:email]
  @blank_line_re = /^\s*$/
  @indent_re = /^\s{4,}\S/
  @block_tags = {
    fenced: /^```/,
    liquid: /^{%/
  }
  @wrap_exceptions = wrap_exceptions.map { |key| @block_tags[key] }
end

Instance Method Details

#runObject



24
25
26
# File 'lib/togglate/block_wrapper.rb', line 24

def run
  wrap_chunks build_chunks
end