summaryrefslogtreecommitdiff
path: root/lib/banzai/reference_parser
diff options
context:
space:
mode:
authorErshad Kunnakkadan <ershad92@gmail.com>2016-12-05 17:42:22 +0530
committerErshad Kunnakkadan <ershad92@gmail.com>2017-02-08 21:53:34 +0530
commit3a23639bc04729cfdc37e4b8ebf46358c3d5a137 (patch)
treedb89ec896fd36ace8c2fc642e66106d9dfbec903 /lib/banzai/reference_parser
parent11d33873a8da5f90fd00bf0909dd1e9f8fca1448 (diff)
downloadgitlab-ce-3a23639bc04729cfdc37e4b8ebf46358c3d5a137.tar.gz
Create directly_addressed Todos when mentioned in beginning of a line
Diffstat (limited to 'lib/banzai/reference_parser')
-rw-r--r--lib/banzai/reference_parser/base_parser.rb5
-rw-r--r--lib/banzai/reference_parser/directly_addressed_user_parser.rb8
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/banzai/reference_parser/base_parser.rb b/lib/banzai/reference_parser/base_parser.rb
index d8a855ec1fe..2058a58d0ae 100644
--- a/lib/banzai/reference_parser/base_parser.rb
+++ b/lib/banzai/reference_parser/base_parser.rb
@@ -33,7 +33,7 @@ module Banzai
# they have access to.
class BaseParser
class << self
- attr_accessor :reference_type
+ attr_accessor :reference_type, :reference_options
end
# Returns the attribute name containing the value for every object to be
@@ -182,9 +182,10 @@ module Banzai
# the references.
def process(documents)
type = self.class.reference_type
+ reference_options = self.class.reference_options
nodes = documents.flat_map do |document|
- Querying.css(document, "a[data-reference-type='#{type}'].gfm").to_a
+ Querying.css(document, "a[data-reference-type='#{type}'].gfm", reference_options).to_a
end
gather_references(nodes)
diff --git a/lib/banzai/reference_parser/directly_addressed_user_parser.rb b/lib/banzai/reference_parser/directly_addressed_user_parser.rb
new file mode 100644
index 00000000000..77df9bbd024
--- /dev/null
+++ b/lib/banzai/reference_parser/directly_addressed_user_parser.rb
@@ -0,0 +1,8 @@
+module Banzai
+ module ReferenceParser
+ class DirectlyAddressedUserParser < UserParser
+ self.reference_type = :user
+ self.reference_options = { location: :beginning }
+ end
+ end
+end