Module: MDLess

Extended by:
CLIMarkdown::Theme
Defined in:
lib/mdless.rb

Constant Summary

Constants included from CLIMarkdown::Theme

CLIMarkdown::Theme::THEME_DEFAULTS

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from CLIMarkdown::Theme

load_theme, load_theme_file

Class Attribute Details

.colsObject

Returns the value of attribute cols.



33
34
35
# File 'lib/mdless.rb', line 33

def cols
  @cols
end

.fileObject

Returns the value of attribute file.



33
34
35
# File 'lib/mdless.rb', line 33

def file
  @file
end

.metaObject

Returns the value of attribute meta.



33
34
35
# File 'lib/mdless.rb', line 33

def meta
  @meta
end

.optionsObject

Returns the value of attribute options.



33
34
35
# File 'lib/mdless.rb', line 33

def options
  @options
end

Class Method Details

.logObject



35
36
37
# File 'lib/mdless.rb', line 35

def log
  @log ||= Logger.new($stderr)
end

.log_level(level) ⇒ Object



39
40
41
# File 'lib/mdless.rb', line 39

def log_level(level)
  @log.level = level
end

.pygments_lexersObject



51
52
53
# File 'lib/mdless.rb', line 51

def pygments_lexers
  @pygments_lexers ||= read_pygments_lexers
end

.pygments_stylesObject



47
48
49
# File 'lib/mdless.rb', line 47

def pygments_styles
  @pygments_styles ||= read_pygments_styles
end

.read_pygments_lexersObject



62
63
64
65
66
67
68
69
70
# File 'lib/mdless.rb', line 62

def read_pygments_lexers
  MDLess.log.info 'Reading Pygments lexers'
  pyg = TTY::Which.which('pygmentize')
  res = `#{pyg} -L lexers`
  lexers = res.scan(/\* ([\w-]+(?:, [\w-]+)*):/).map { |l| l[0] }
  lexers_a = []
  lexers.each { |l| lexers_a.concat(l.split(/, /)) }
  lexers_a
end

.read_pygments_stylesObject



55
56
57
58
59
60
# File 'lib/mdless.rb', line 55

def read_pygments_styles
  MDLess.log.info 'Reading Pygments styles'
  pyg = TTY::Which.which('pygmentize')
  res = `#{pyg} -L styles`
  res.scan(/\* ([\w-]+):/).map { |l| l[0] }
end

.themeObject



43
44
45
# File 'lib/mdless.rb', line 43

def theme
  @theme ||= load_theme(@options[:theme])
end