diff --git a/Gemfile b/Gemfile index 18c90f2..f9269db 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ gemspec gem "rdf", github: "ruby-rdf/rdf", branch: "develop" gem "rdf-spec", github: "ruby-rdf/rdf-spec", branch: "develop" gem "rdf-xsd", github: "ruby-rdf/rdf-xsd", branch: "develop" -gem "nokogiri", '~> 1.13', '>= 1.13.4', platforms: [:mri, :jruby] +gem "nokogiri", '~> 1.14', platforms: [:mri, :jruby] gem 'equivalent-xml', '~> 0.6' group :development, :test do diff --git a/README.md b/README.md index 36beb04..3c4ad69 100755 --- a/README.md +++ b/README.md @@ -399,7 +399,7 @@ The template hash defines four Haml templates: ## Dependencies * [Ruby](https://ruby-lang.org/) (>= 2.6) * [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.2) -* [Haml](https://rubygems.org/gems/haml) (~> 5.2) +* [Haml](https://rubygems.org/gems/haml) (>- 5.2, < 7) * [HTMLEntities](https://rubygems.org/gems/htmlentities) (~> 4.3) * Soft dependency on [Nokogiri](https://rubygems.org/gems/nokogiri) (~> 1.12) diff --git a/lib/rdf/rdfa/writer.rb b/lib/rdf/rdfa/writer.rb index 97af1fd..50ed098 100644 --- a/lib/rdf/rdfa/writer.rb +++ b/lib/rdf/rdfa/writer.rb @@ -721,6 +721,8 @@ def get_curie(resource) # @return [String] # Entity-encoded string def escape_entities(str) + # Haml 6 does escaping + return str if Haml.const_defined?(:Template) CGI.escapeHTML(str).gsub(/[\n\r]/) {|c| '&#x' + c.unpack('h').first + ';'} end @@ -761,7 +763,13 @@ def hamlify(template, locals = {}) template = template.align_left log_debug {"hamlify locals: #{locals.inspect}"} - Haml::Engine.new(template, @options[:haml_options] || HAML_OPTIONS).render(self, locals) do |*args| + haml_opts = @options[:haml_options] || HAML_OPTIONS + haml_runner = if Haml.const_defined?(:Template) + Haml::Template.new(**haml_opts) {template} + else + Haml::Engine.new(template, **haml_opts) + end + haml_runner.render(self, locals) do |*args| yield(*args) if block_given? end rescue Haml::Error => e diff --git a/lib/rdf/rdfa/writer/haml_templates.rb b/lib/rdf/rdfa/writer/haml_templates.rb index 8ae19d0..4d20fa1 100644 --- a/lib/rdf/rdfa/writer/haml_templates.rb +++ b/lib/rdf/rdfa/writer/haml_templates.rb @@ -10,11 +10,11 @@ class Writer doc: %q( !!! XML !!! 5 - %html{xmlns: "http://www.w3.org/1999/xhtml", lang: lang, prefix: prefix} + %html{**{xmlns: "http://www.w3.org/1999/xhtml", lang: lang, prefix: prefix}.compact} - if base || title %head - if base - %base{href: base} + %base{**{href: base}.compact} - if title %title= title %body @@ -33,13 +33,13 @@ class Writer # Yield: predicates.each subject: %q( - if element == :li - %li{rel: rel, resource: (about || resource), typeof: typeof, inlist: inlist} + %li{**{rel: rel, resource: (about || resource), typeof: typeof, inlist: inlist}.compact} - if typeof %span.type!= typeof - predicates.each do |predicate| != yield(predicate) - else - %div{rel: rel, resource: (about || resource), typeof: typeof, inlist: inlist} + %div{**{rel: rel, resource: (about || resource), typeof: typeof, inlist: inlist}.compact} - if typeof %span.type!= typeof - predicates.each do |predicate| @@ -53,7 +53,7 @@ class Writer # Otherwise, render result property_value: %q( - if heading_predicates.include?(predicate) && object.literal? - %h1{property: get_curie(predicate), content: get_content(object), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}= escape_entities(get_value(object)) + %h1{**{property: get_curie(predicate), content: get_content(object), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}.compact}= escape_entities(get_value(object)) - else %div.property %span.label @@ -63,13 +63,13 @@ class Writer - elsif get_curie(object) == 'rdf:nil' %span{rel: get_curie(predicate), inlist: ''} - elsif object.node? - %span{property: get_curie(predicate), resource: get_curie(object), inlist: inlist}= get_curie(object) + %span{**{property: get_curie(predicate), resource: get_curie(object), inlist: inlist}.compact}= get_curie(object) - elsif object.uri? - %a{property: get_curie(predicate), href: object.to_s, inlist: inlist}= object.to_s + %a{**{property: get_curie(predicate), href: object.to_s, inlist: inlist}.compact}= object.to_s - elsif object.datatype == RDF.XMLLiteral - %span{property: get_curie(predicate), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist} 3.2' gem.add_runtime_dependency 'rdf-vocab', '~> 3.2' - gem.add_runtime_dependency 'haml', '~> 5.2' + gem.add_runtime_dependency 'haml', '>= 5.2', "< 7" gem.add_runtime_dependency 'rdf-xsd', '~> 3.2' gem.add_runtime_dependency 'rdf-aggregate-repo', '~> 3.2' gem.add_runtime_dependency 'htmlentities', '~> 4.3' diff --git a/script/tc b/script/tc index f04650e..8f0f281 100755 --- a/script/tc +++ b/script/tc @@ -92,7 +92,7 @@ options = { opts = GetoptLong.new( ["--help", "-?", GetoptLong::NO_ARGUMENT], - ["--dbg", GetoptLong::NO_ARGUMENT], + ["--debug", GetoptLong::NO_ARGUMENT], ["--format", GetoptLong::REQUIRED_ARGUMENT], ["--host-language", "-h", GetoptLong::REQUIRED_ARGUMENT], ["--library", GetoptLong::REQUIRED_ARGUMENT], @@ -107,7 +107,7 @@ def help(options) puts "Usage: #{$0} [options] [test-number ...]" puts "Options:" puts " --dump: Dump raw output, otherwise serialize to Ruby" - puts " --dbg: Display detailed debug output" + puts " --debug: Display detailed debug output" puts " --expand Expand graph with vocab_expansion option" puts " --format: Format for output, defaults to #{options[:format].inspect}" puts " --host-language: Run for specified host language, defaults to #{options[:host_language]}" @@ -124,7 +124,7 @@ end opts.each do |opt, arg| case opt when '--help' then help(options) - when '--dbg' then logger.level = Logger::DEBUG + when '--debug' then logger.level = Logger::DEBUG when '--format' then options[:format] = arg.to_sym when '--host-language' then options[:host_language] = arg when '--library' then options[:library] = arg.to_sym @@ -142,7 +142,7 @@ result_count = {} Fixtures::TestCase.for_specific(options[:host_language], options[:version]) do |tc| next unless ARGV.empty? || ARGV.any? {|n| tc.num.match(/#{n}/)} next if tc.classification.to_s =~ /deprecated/ - run_tc(tc, options.merge(result_count: result_count)) + run_tc(tc, **options.merge(result_count: result_count)) end result_count.each do |result, count|