scripts: add docs-to-slides script

This commit is contained in:
Glenn Y. Rolland 2020-11-11 10:53:46 +01:00
parent dce9e69a35
commit a11b0657e9

24
scripts/docs-to-slides Executable file
View file

@ -0,0 +1,24 @@
#!/usr/bin/ruby
# vim: set ts=2 sw=2 et:
# frozen_string_literal: true
require 'fileutils'
require 'thor'
# Hop
class D2SCli < Thor
desc 'process FILE', 'Process file'
def process(file)
FileUtils.cp(file, file + '.bak')
content = File.read(file)
content.gsub!(/<!--\s*.*?_class:\s*chapter\s*.*?-->/m, '')
content.gsub!(/^.*images\/background.png.*$/, '')
content.gsub!(/^----?\s*$/, '')
content.gsub!(/\n\s*\n\s*\n/, "\n\n")
File.write(file, content)
end
default_task :process
end
D2SCli.start(ARGV)