Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions haml-contrib.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ Gem::Specification.new do |spec|

spec.add_dependency "haml", ">= 3.2.0.alpha.13"
spec.add_development_dependency "minitest"
spec.add_development_dependency "asciidoctor"

end
4 changes: 4 additions & 0 deletions lib/haml/filters/asciidoc.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Haml::Filters.register_tilt_filter 'AsciiDoc'
Haml::Filters::AsciiDoc.options[:safe] = :safe
Haml::Filters::AsciiDoc.options[:attributes] ||= {}
Haml::Filters::AsciiDoc.options[:attributes]['notitle!'] = ''
22 changes: 22 additions & 0 deletions test/asciidoc_filter_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'test_helper'
require 'haml/filters/asciidoc'

class AsciiDocFilterTest < MiniTest::Unit::TestCase
def test_should_render_asciidoc_content
haml = ":asciidoc\n *hello*\n"
html = "<div class=\"paragraph\">\n<p><strong>hello</strong></p>\n</div>"
assert_equal(html, render(haml).rstrip.gsub(/^ *(\n|(?=[^ ]))/, ''))
end

def test_should_render_h1_header
haml = ":asciidoc\n = Title\n\n content"
html = "<h1>Title</h1>"
assert render(haml).start_with?(html)
end

def test_should_render_inline_asciidoc_content
haml = ":asciidoc\n :doctype: inline\n *hello*\n"
html = "<strong>hello</strong>"
assert_equal(html, render(haml).rstrip)
end
end