Method: K4slide::Tasks::K4slideTasks#example_markdown_targets
- Defined in:
- lib/k4slide/tasks.rb
#example_markdown_targets ⇒ Object
Compiling example markdown file
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/k4slide/tasks.rb', line 128 def example_markdown_targets() target_files = [] example_dir = File.join(K4_ROOT, 'example') ext = 'md' filelist = FileList[File.join(example_dir, "*.#{ext}")] filelist.each do |source_path| source_basename = File.basename(source_path) next if source_basename =~ /^_/ source_basename = source_basename.gsub(/#{ext}$/, 'html') target_path = File.join(example_dir, source_basename) # File.delete(target_path) if File.exists?(target_path) file(target_path) do |t, args| puts t.name src = File.read(source_path) compiler_ = MarkdownCompiler.new(@compiler) html_source = compiler_.(src) File.open(target_path, 'w') do |io| io.write(html_source) end end target_files << target_path end return target_files end |