fix mentions in code blocks
This commit is contained in:
parent
028cd348e1
commit
553a671fdb
|
@ -51,6 +51,9 @@ class PostAnalyzer
|
||||||
return @raw_mentions if @raw_mentions.present?
|
return @raw_mentions if @raw_mentions.present?
|
||||||
raw_stripped = @raw.gsub(/\[quote=(.*)\]([^\[]*?)\[\/quote\]/im, '')
|
raw_stripped = @raw.gsub(/\[quote=(.*)\]([^\[]*?)\[\/quote\]/im, '')
|
||||||
|
|
||||||
|
# Process markdown so that code blocks can be generated and subsequently ignored
|
||||||
|
raw_stripped = PrettyText.markdown(raw_stripped)
|
||||||
|
|
||||||
# Strip pre and code tags
|
# Strip pre and code tags
|
||||||
doc = Nokogiri::HTML.fragment(raw_stripped)
|
doc = Nokogiri::HTML.fragment(raw_stripped)
|
||||||
doc.search("pre").remove
|
doc.search("pre").remove
|
||||||
|
|
|
@ -188,6 +188,11 @@ describe PostAnalyzer do
|
||||||
post_analyzer.raw_mentions.should == ['jake']
|
post_analyzer.raw_mentions.should == ['jake']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "ignores code in markdown-formatted code blocks" do
|
||||||
|
post_analyzer = PostAnalyzer.new(" @Jake @Finn\n@Ryan", default_topic_id)
|
||||||
|
post_analyzer.raw_mentions.should == ['ryan']
|
||||||
|
end
|
||||||
|
|
||||||
it "ignores quotes" do
|
it "ignores quotes" do
|
||||||
post_analyzer = PostAnalyzer.new("[quote=\"Evil Trout\"]@Jake[/quote] @Finn", default_topic_id)
|
post_analyzer = PostAnalyzer.new("[quote=\"Evil Trout\"]@Jake[/quote] @Finn", default_topic_id)
|
||||||
post_analyzer.raw_mentions.should == ['finn']
|
post_analyzer.raw_mentions.should == ['finn']
|
||||||
|
|
Loading…
Reference in New Issue