You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gta3script-specs/tools/asciidoctor-python3.rb

25 lines
597 B
Ruby

require 'asciidoctor'
require 'asciidoctor/extensions'
require 'open3'
include Asciidoctor
def python3_preprocessor(name)
klass = Class.new(Asciidoctor::Extensions::Preprocessor) do
class << self
attr_accessor :script
end
def process document, reader
script = self.class.script
out, err, s = Open3.capture3("python3 #{script}", :stdin_data => reader.read)
if not s.success?
$stderr.puts(err)
exit 1
end
return Reader.new out.split("\n")
end
end
klass.script = File.join(File.dirname(__FILE__), name)
return klass
end