Skip to content

Commit 3958301

Browse files
committed
Fix ruby-china#226 escape HTML tag, don't remove it.
1 parent 9b47ed2 commit 3958301

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/markdown.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class HTMLwithSyntaxHighlight < HTML
1414
def initialize(extensions={})
1515
super(extensions.merge(:xhtml => true,
1616
:no_styles => true,
17-
:filter_html => true,
17+
:escape_html => true,
1818
:hard_wrap => true))
1919
end
2020

spec/lib/markdown_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,5 +259,22 @@ class Foo; end
259259
specify { doc.css('pre').should be_empty }
260260
end
261261
end
262+
263+
describe 'Escape HTML tags' do
264+
context '<xxx> or a book names' do
265+
let(:raw) { "<Enterprise Integration Patterns> book" }
266+
its(:inner_html) { should == "<p>&lt;Enterprise Integration Patterns&gt; book</p>" }
267+
end
268+
269+
context '<img> tag' do
270+
let(:raw) { "<img src='aaa.jpg' /> aaa" }
271+
its(:inner_html) { should == "<p>&lt;img src='aaa.jpg' /&gt; aaa</p>" }
272+
end
273+
274+
context '<b> tag' do
275+
let(:raw) { "<b>aaa</b>" }
276+
its(:inner_html) { should == "<p>&lt;b&gt;aaa&lt;/b&gt;</p>" }
277+
end
278+
end
262279
end
263280
end

0 commit comments

Comments
 (0)