Class: Slideshow::Gen

Inherits:
Object
  • Object
show all
Includes:
LogUtils::Logging, BackgroundHelper, DebugFilter, DirectiveHelper, HeadersFilter, MarkdownEngines, SlideFilter, SourceHelper, StepHelper, Syntax::CodeRayHelper, Syntax::ShHelper, Syntax::UvHelper, TextFilter
Defined in:
lib/slideshow/markdown.rb,
lib/slideshow/commands/gen.rb,
lib/slideshow/filters/text_filter.rb,
lib/slideshow/helpers/step_helper.rb,
lib/slideshow/filters/debug_filter.rb,
lib/slideshow/filters/slide_filter.rb,
lib/slideshow/helpers/source_helper.rb,
lib/slideshow/filters/headers_filter.rb,
lib/slideshow/helpers/directive_helper.rb,
lib/slideshow/helpers/syntax/sh_helper.rb,
lib/slideshow/helpers/syntax/uv_helper.rb,
lib/slideshow/helpers/background_helper.rb,
lib/slideshow/helpers/syntax/coderay_helper.rb

Overview

module Slideshow

Constant Summary

Constants included from Syntax::CodeRayHelper

Syntax::CodeRayHelper::CR_LANG, Syntax::CodeRayHelper::CR_LINE_NUMBERS

Constants included from Syntax::UvHelper

Syntax::UvHelper::UV_LANG, Syntax::UvHelper::UV_LINE_NUMBERS, Syntax::UvHelper::UV_THEME

Constants included from Syntax::ShHelper

Syntax::ShHelper::SH_LANG, Syntax::ShHelper::SH_LINE_NUMBERS

Constants included from TextFilter

TextFilter::DIRECTIVES_EXPRS, TextFilter::DIRECTIVES_RENAMES, TextFilter::DIRECTIVES_UNPARSED

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Syntax::CodeRayHelper

#coderay, #coderay_worker

Methods included from BackgroundHelper

#background, #color, #gradient, #gradient_from_headers

Methods included from Syntax::UvHelper

#uv, #uv_worker

Methods included from Syntax::ShHelper

#sh_worker, #sv

Methods included from DirectiveHelper

#css, #slide, #style

Methods included from HeadersFilter

#leading_headers

Methods included from SourceHelper

#source

Methods included from SlideFilter

#takahashi_slide_breaks

Methods included from DebugFilter

#dump_content_to_file_debug_html, #dump_content_to_file_debug_text, #dump_content_to_file_debug_text_erb

Methods included from StepHelper

#step

Methods included from TextFilter

#directives_bang_style_to_percent_style, #directives_percent_style, #erb_rename_helper_hack

Methods included from MarkdownEngines

#markdown_to_html

Constructor Details

#initialize(config, headers, session = {}, content_for = {}) ⇒ Gen

Returns a new instance of Gen.



13
14
15
16
17
18
19
# File 'lib/slideshow/commands/gen.rb', line 13

def initialize( config, headers, session={}, content_for={} )
  @config      = config
  @headers     = headers
  
  @session     = session
  @content_for = content_for
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



21
22
23
# File 'lib/slideshow/commands/gen.rb', line 21

def config
  @config
end

#headersObject (readonly)

Returns the value of attribute headers.



21
22
23
# File 'lib/slideshow/commands/gen.rb', line 21

def headers
  @headers
end

#outdirObject (readonly)

NB: “initalized” in create_slideshow



26
27
28
# File 'lib/slideshow/commands/gen.rb', line 26

def outdir
  @outdir
end

#sessionObject (readonly)

give helpers/plugins a session-like hash



22
23
24
# File 'lib/slideshow/commands/gen.rb', line 22

def session
  @session
end

#srcdirObject (readonly)

NB: “initalized” in create_slideshow



26
27
28
# File 'lib/slideshow/commands/gen.rb', line 26

def srcdir
  @srcdir
end

#usrdirObject (readonly)

todo/check: usrdir needed for something (e.g. why keep it?) - remove? why? why not??



25
26
27
# File 'lib/slideshow/commands/gen.rb', line 25

def usrdir
  @usrdir
end

Instance Method Details

#guard_block(text) ⇒ Object

use/rename to guard_text_block - why? why not?



76
77
78
79
# File 'lib/slideshow/commands/gen.rb', line 76

def guard_block( text )   ## use/rename to guard_text_block - why? why not?
  # wrap in newlines to avoid runons
  "\n\n#{text}\n\n"
end

#guard_inline(text) ⇒ Object

use/rename to guard_text_inline - why? why not?



81
82
83
# File 'lib/slideshow/commands/gen.rb', line 81

def guard_inline( text )   ## use/rename to guard_text_inline - why? why not?
  wrap_markup( text )
end

#guard_text(text) ⇒ Object

some markdown guard helpers

(e.g. guard text/mark text for do NOT convert)


63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/slideshow/commands/gen.rb', line 63

def guard_text( text )
  # todo/fix 2: note we need to differentiate between blocks and inline
  #   thus, to avoid runs - use guard_block (add a leading newline to avoid getting include in block that goes before)
  
  # todo/fix: remove wrap_markup; replace w/ guard_text
  #   why: text might be css, js, not just html
  
  ###  !!!!!!!!!!!!
  ## todo: add print depreciation warning
  
  wrap_markup( text )
end

#render(content, ctx) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/slideshow/commands/gen.rb', line 29

def render( content, ctx )
  
  ####################
  ## todo/fix: move ctx to Gen.initialize - why? why not?
  @name     = ctx[:name]

  @outdir   = ctx[:outdir]
  @srcdir   = ctx[:srcdir]
  @usrdir   = ctx[:usrdir]
  
  # run text filters

  config.text_filters.each do |filter|
    mn = filter.tr( '-', '_' ).to_sym  # construct method name (mn)
    puts "  run filter #{mn}..."
    content = send( mn, content )   # call filter e.g.  include_helper_hack( content )  
  end

  if config.takahashi?
    content = takahashi_slide_breaks( content )
  end

  # convert light-weight markup to hypertext

  content = markdown_to_html( content )
  content
end

#wrap_markup(text) ⇒ Object



85
86
87
88
# File 'lib/slideshow/commands/gen.rb', line 85

def wrap_markup( text )
  # saveguard with wrapper etc./no further processing needed - check how to do in markdown
  text
end