summaryrefslogtreecommitdiff
path: root/lib/banzai/filter
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2016-05-30 15:55:11 +0200
committerYorick Peterse <yorickpeterse@gmail.com>2016-06-02 12:30:18 +0200
commit2fbfb85492401b2a8ac81f22b319b304afecf6c3 (patch)
treec968038517100ffc60eaa5b6078951e232c72722 /lib/banzai/filter
parentacfbeced52db321534c7b03a56a909e280d26914 (diff)
downloadgitlab-ce-2fbfb85492401b2a8ac81f22b319b304afecf6c3.tar.gz
Returning enums in ReferenceFilter#each_node
This changes ReferenceFilter#each_node so that when it's called without a block an Enumerator is returned.
Diffstat (limited to 'lib/banzai/filter')
-rw-r--r--lib/banzai/filter/reference_filter.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/banzai/filter/reference_filter.rb b/lib/banzai/filter/reference_filter.rb
index 41ae0e1f9cc..5eace574ab4 100644
--- a/lib/banzai/filter/reference_filter.rb
+++ b/lib/banzai/filter/reference_filter.rb
@@ -68,6 +68,8 @@ module Banzai
# by `ignore_ancestor_query`. Link tags are not processed if they have a
# "gfm" class or the "href" attribute is empty.
def each_node
+ return to_enum(__method__) unless block_given?
+
query = %Q{descendant-or-self::text()[not(#{ignore_ancestor_query})]
| descendant-or-self::a[
not(contains(concat(" ", @class, " "), " gfm ")) and not(@href = "")