Class: Jekyll::PandocExports::Hooks

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-pandoc-exports/hooks.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.post_conversion_hooksObject (readonly)

Returns the value of attribute post_conversion_hooks.



8
9
10
# File 'lib/jekyll-pandoc-exports/hooks.rb', line 8

def post_conversion_hooks
  @post_conversion_hooks
end

.pre_conversion_hooksObject (readonly)

Returns the value of attribute pre_conversion_hooks.



8
9
10
# File 'lib/jekyll-pandoc-exports/hooks.rb', line 8

def pre_conversion_hooks
  @pre_conversion_hooks
end

Class Method Details

.clear_hooksObject



32
33
34
35
# File 'lib/jekyll-pandoc-exports/hooks.rb', line 32

def clear_hooks
  @pre_conversion_hooks.clear
  @post_conversion_hooks.clear
end

.register_post_conversion(&block) ⇒ Object



14
15
16
# File 'lib/jekyll-pandoc-exports/hooks.rb', line 14

def register_post_conversion(&block)
  @post_conversion_hooks << block
end

.register_pre_conversion(&block) ⇒ Object



10
11
12
# File 'lib/jekyll-pandoc-exports/hooks.rb', line 10

def register_pre_conversion(&block)
  @pre_conversion_hooks << block
end

.run_post_conversion_hooks(content, format, config, context = {}) ⇒ Object



25
26
27
28
29
30
# File 'lib/jekyll-pandoc-exports/hooks.rb', line 25

def run_post_conversion_hooks(content, format, config, context = {})
  @post_conversion_hooks.each do |hook|
    content = hook.call(content, format, config, context) || content
  end
  content
end

.run_pre_conversion_hooks(html_content, config, context = {}) ⇒ Object



18
19
20
21
22
23
# File 'lib/jekyll-pandoc-exports/hooks.rb', line 18

def run_pre_conversion_hooks(html_content, config, context = {})
  @pre_conversion_hooks.each do |hook|
    html_content = hook.call(html_content, config, context) || html_content
  end
  html_content
end