Skip to content

Commit

Permalink
Merge pull request #1301 from qichunren/fix_markdown_sub_sup
Browse files Browse the repository at this point in the history
Support sub and sup tag in post markdown editor. Fixed issue #1126
  • Loading branch information
huacnlee authored Oct 9, 2021
2 parents 7fe2a0a + 74eead6 commit 45a51b3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/homeland/sanitize/topic_scrubber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def initialize
self.tags = %w[
p br img h1 h2 h3 h4 h5 h6 blockquote pre code b i del
strong em table tr td tbody th strike del u a ul ol li span hr
sub sup
]

self.attributes = %w[
Expand Down
4 changes: 4 additions & 0 deletions test/helpers/application_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ def current_page?(url)
assert_equal "<p>Hello world alert()</p>", sanitize_markdown("<p>Hello world <script>alert()</script></p>")
end

test "sanitize_markdown sup and sub" do
assert_equal "<p>L<sup>A</sup>T<sub>E</sub>X 结构化的路径覆盖(C<sub>i</sub>(k)-覆盖)</p>", sanitize_markdown("<p>L<sup>A</sup>T<sub>E</sub>X 结构化的路径覆盖(C<sub>i</sub>(k)-覆盖)</p>")
end

test "admin?" do
user = create :user
admin = create :admin
Expand Down
4 changes: 4 additions & 0 deletions test/lib/markdown_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ def foo
end
end

test "sup and sub" do
assert_markdown_render %(<p>L<sup>A</sup>T<sub>E</sub>X 结构化的路径覆盖(C<sub>i</sub>(k)-覆盖)</p>), "L<sup>A</sup>T<sub>E</sub>X结构化的路径覆盖(C<sub>i</sub>(k)-覆盖)"
end

test "footnotes" do
assert_markdown_render %(<p>some ^strikethrough^</p>), "some ^strikethrough^"
end
Expand Down

0 comments on commit 45a51b3

Please # to comment.