https://sources.debian.org/patches/asciidoctor/2.0.18-2/0001-Port-tests-to-haml-6.patch/ (backport) https://github.com/asciidoctor/asciidoctor/pull/4395 From 25ee484dd66cc813eaa421d1c104ae64478e51ff Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Mon, 26 Dec 2022 13:11:36 -0300 Subject: [PATCH] Port tests to haml 6 Forwarded: https://github.com/asciidoctor/asciidoctor/pull/4395 Fixes: #4382 --- a/asciidoctor.gemspec +++ b/asciidoctor.gemspec @@ -38,7 +38,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'cucumber', '~> 3.1.0' # erubi is needed for testing alternate eRuby impls s.add_development_dependency 'erubi', '~> 1.10.0' - s.add_development_dependency 'haml', '~> 5.2.0' + s.add_development_dependency 'haml', '~> 6.1' s.add_development_dependency 'minitest', '~> 5.14.0' s.add_development_dependency 'nokogiri', '~> 1.10.0' s.add_development_dependency 'rake', '~> 12.3.0' --- a/lib/asciidoctor/converter/template.rb +++ b/lib/asciidoctor/converter/template.rb @@ -29,7 +29,7 @@ class Converter::TemplateConverter < Con erb: { trim: 0 }, # TODO line 466 of haml/compiler.rb sorts the attributes; file an issue to make this configurable # NOTE AsciiDoc syntax expects HTML/XML output to use double quotes around attribute values - haml: { format: :xhtml, attr_wrapper: '"', escape_attrs: false, ugly: true }, + haml: { format: :xhtml, attr_quote: '"', escape_attrs: false, ugly: true }, slim: { disable_escape: true, sort_attrs: false, pretty: false }, } --- a/test/converter_test.rb +++ b/test/converter_test.rb @@ -9,7 +9,7 @@ context 'Converter' do assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter selected = doc.converter.find_converter('paragraph') assert_kind_of Asciidoctor::Converter::TemplateConverter, selected - assert_kind_of Tilt::HamlTemplate, selected.templates['paragraph'] + assert_kind_of Haml::Template, selected.templates['paragraph'] assert_equal :html5, selected.templates['paragraph'].options[:format] end @@ -18,7 +18,7 @@ context 'Converter' do assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter selected = doc.converter.find_converter('paragraph') assert_kind_of Asciidoctor::Converter::TemplateConverter, selected - assert_kind_of Tilt::HamlTemplate, selected.templates['paragraph'] + assert_kind_of Haml::Template, selected.templates['paragraph'] assert_equal :xhtml, selected.templates['paragraph'].options[:format] end @@ -95,7 +95,7 @@ context 'Converter' do %w(paragraph sidebar).each do |node_name| selected = doc.converter.find_converter node_name assert_kind_of Asciidoctor::Converter::TemplateConverter, selected - assert_kind_of Tilt::HamlTemplate, selected.templates[node_name] + assert_kind_of Haml::Template, selected.templates[node_name] assert_equal %(block_#{node_name}.html.haml), File.basename(selected.templates[node_name].file) end end @@ -126,7 +126,7 @@ context 'Converter' do %w(paragraph).each do |node_name| selected = doc.converter.find_converter node_name assert_kind_of Asciidoctor::Converter::TemplateConverter, selected - assert_kind_of Tilt::HamlTemplate, selected.templates[node_name] + assert_kind_of Haml::Template, selected.templates[node_name] assert_equal %(block_#{node_name}.xml.haml), File.basename(selected.templates[node_name].file) end end @@ -215,7 +215,7 @@ context 'Converter' do refute_empty caches[:templates] paragraph_template = caches[:templates].values.find {|t| File.basename(t.file) == 'block_paragraph.html.haml' } refute_nil paragraph_template - assert_kind_of ::Tilt::HamlTemplate, paragraph_template + assert_kind_of Haml::Template, paragraph_template end test 'should be able to disable template cache' do --- a/test/fixtures/custom-backends/haml/docbook5/block_paragraph.xml.haml +++ b/test/fixtures/custom-backends/haml/docbook5/block_paragraph.xml.haml @@ -1,6 +1,6 @@ - if title? %formalpara{'xml:id'=>@id, role: (attr :role), xreflabel: (attr :reftext)} - %title=title - %para=content + %title!=title + %para!=content - else - %para{'xml:id'=>@id, role: (attr :role), xreflabel: (attr :reftext)}=content + %para{'xml:id'=>@id, role: (attr :role), xreflabel: (attr :reftext)}!=content --- a/test/fixtures/custom-backends/haml/html5-tweaks/block_paragraph.html.haml +++ b/test/fixtures/custom-backends/haml/html5-tweaks/block_paragraph.html.haml @@ -1 +1 @@ -%p=content +%p!=content --- a/test/fixtures/custom-backends/haml/html5-tweaks/embedded.html.haml +++ b/test/fixtures/custom-backends/haml/html5-tweaks/embedded.html.haml @@ -1 +1 @@ -=content +!=content --- a/test/fixtures/custom-backends/haml/html5/block_paragraph.html.haml +++ b/test/fixtures/custom-backends/haml/html5/block_paragraph.html.haml @@ -1,3 +1,3 @@ - if title? - .title=title -%p{id: @id, class: (attr 'role')}=content + .title!=title +%p{id: @id, class: (attr 'role')}!=content --- a/test/fixtures/custom-backends/haml/html5/block_sidebar.html.haml +++ b/test/fixtures/custom-backends/haml/html5/block_sidebar.html.haml @@ -1,5 +1,5 @@ %aside{id: @id, class: (attr 'role')} - if title? %header - %h1=title - =content.chomp + %h1!=title + !=content.chomp --- a/test/invoker_test.rb +++ b/test/invoker_test.rb @@ -616,7 +616,7 @@ context 'Invoker' do assert_kind_of Asciidoctor::Converter::CompositeConverter, doc.converter selected = doc.converter.find_converter 'paragraph' assert_kind_of Asciidoctor::Converter::TemplateConverter, selected - assert_kind_of Tilt::HamlTemplate, selected.templates['paragraph'] + assert_kind_of Haml::Template, selected.templates['paragraph'] end test 'should load custom templates from multiple template directories' do