Skip to content
代码片段 群组 项目
未验证 提交 85f37f3b 编辑于 作者: Brett Walker's avatar Brett Walker 提交者: GitLab
浏览文件

Merge branch '463330-bubbis-link-in-math-bug' into 'master'

No related branches found
No related tags found
2 合并请求!3031Merge per-main-jh to main-jh by luzhiyuan,!3030Merge per-main-jh to main-jh
......@@ -40,7 +40,7 @@ class SpacedLinkFilter < HTML::Pipeline::Filter
)
# Text matching LINK_OR_IMAGE_PATTERN inside these elements will not be linked
IGNORE_PARENTS = %w[a code kbd pre script style].to_set
IGNORE_PARENTS = %w[a code kbd pre script style span[@data-math-style]].to_set
# The XPath query to use for finding text nodes to parse.
TEXT_QUERY = %(descendant-or-self::text()[
......
......@@ -93,9 +93,10 @@
expect(found_images[0]['alt']).to eq 'example'
end
described_class::IGNORE_PARENTS.each do |elem|
it "ignores valid links contained inside '#{elem}' element" do
exp = act = "<#{elem}>See #{link}</#{elem}>"
described_class::IGNORE_PARENTS.each do |xpath|
it "ignores valid links contained inside '#{xpath}' element" do
match = xpath.match(/(?<element>\w+)(?:\[@(?<attribute>.*)\])?/)
exp = act = "<#{match[:element]}#{" #{match[:attribute]}" if match[:attribute]}>See #{link}</#{match[:element]}>"
expect(filter(act).to_html).to eq exp
end
......
......@@ -315,4 +315,17 @@
is_expected.to include '<span class="kc">true</span>'
end
end
describe 'math does not get rendered as link' do
[
"$[(a+b)c](d+e)$",
'$$[(a+b)c](d+e)$$',
'$`[(a+b)c](d+e)`$'
].each do |input|
it "when using '#{input}' as input" do
result = described_class.call(input, project: nil)[:output]
expect(result.css('a').first).to be_nil
end
end
end
end
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册