From 6ddf8c757676f619926107f810e56663bf76c879 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Sat, 11 Jun 2016 07:45:26 +0100 Subject: [PATCH] Use "safe: :unsafe" to ensure included snippets work Also copy the document attributes over and re-use them so any variables that need to be resolved are there. Code copied from https://github.com/asciidoctor/asciidoctor-extensions-lab/blob/master/scripts/asciidoc-coalescer.rb --- docs/src/main/ruby/generate_readme.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/src/main/ruby/generate_readme.sh b/docs/src/main/ruby/generate_readme.sh index 79aadce4e..6d0ce9dc5 100755 --- a/docs/src/main/ruby/generate_readme.sh +++ b/docs/src/main/ruby/generate_readme.sh @@ -16,9 +16,16 @@ end file = ARGV[0] if ARGV.length>0 -srcDir = File.dirname(file) +# Copied from https://github.com/asciidoctor/asciidoctor-extensions-lab/blob/master/scripts/asciidoc-coalescer.rb +doc = Asciidoctor.load_file file, safe: :unsafe, header_only: true, attributes: options[:attributes] +header_attr_names = (doc.instance_variable_get :@attributes_modified).to_a +header_attr_names.each {|k| doc.attributes[%(#{k}!)] = '' unless doc.attr? k } +attrs = doc.attributes +attrs['allow-uri-read'] = true +puts attrs + out = "// Do not edit this file (e.g. go instead to src/main/asciidoc)\n\n" -doc = Asciidoctor.load_file file, safe: :safe, parse: false, attributes: 'allow-uri-read' +doc = Asciidoctor.load_file file, safe: :unsafe, parse: false, attributes: attrs out << doc.reader.read unless options[:to_file]