Class: Decidim::ContentParsers::HashtagParser

Inherits:
TagParser show all
Defined in:
decidim-core/lib/decidim/content_parsers/hashtag_parser.rb

Overview

A parser that searches hashtags in content.

A word starting with ‘#` will be considered as a hashtag if it only contains letters, numbers or underscores. If the `#` is followed with an underscore, then it is not considered.

Defined Under Namespace

Classes: Metadata

Constant Summary collapse

HASHTAG_REGEX =

Matches a hashtag if it starts with a letter or number and only contains letters, numbers or underscores.

/(?:\A|\s\K)\B#([[:alnum:]](?:[[:alnum:]]|_)*)\b/i

Constants inherited from BaseParser

BaseParser::Metadata

Instance Attribute Summary

Attributes inherited from BaseParser

#content, #context

Instance Method Summary collapse

Methods inherited from TagParser

#rewrite

Methods inherited from BaseParser

#initialize, #rewrite

Methods included from Decidim::ContentProcessor::Common

#html_content?, #html_fragment

Constructor Details

This class inherits a constructor from Decidim::ContentParsers::BaseParser

Instance Method Details

#metadataObject



23
24
25
# File 'decidim-core/lib/decidim/content_parsers/hashtag_parser.rb', line 23

def 
  Metadata.new(.map { |content_hashtag| hashtag(content_hashtag) }.uniq)
end