Class: Decidim::ContentParsers::ResourceParser
- Inherits:
-
BaseParser
- Object
- BaseParser
- Decidim::ContentParsers::ResourceParser
- Defined in:
- lib/decidim/content_parsers/resource_parser.rb
Overview
A parser that searches mentions of Resources in content.
Constant Summary collapse
- URL_REGEX_SCHEME =
Matches a URL
'(?:http(s)?:\/\/)'
- URL_REGEX_CONTENT =
'[\w.-]+[\w\-\._~:\/?#\[\]@!\$&\'\(\)\*\+,;=.]+'
- URL_REGEX_END_CHAR =
'[\d]'
- ID_REGEX =
Matches a mentioned resource ID (~(d)+ expression)
/~(\d+)/
Constants inherited from BaseParser
Instance Attribute Summary
Attributes inherited from BaseParser
Instance Method Summary collapse
-
#rewrite ⇒ String
Replaces found mentions matching an existing Resource with a global id for that Resource.
Methods inherited from BaseParser
Methods included from Decidim::ContentProcessor::Common
#html_content?, #html_fragment
Constructor Details
This class inherits a constructor from Decidim::ContentParsers::BaseParser
Instance Method Details
#rewrite ⇒ String
Replaces found mentions matching an existing Resource with a global id for that Resource. Other mentions found that does not match an existing Resource are returned as they are.
21 22 23 24 |
# File 'lib/decidim/content_parsers/resource_parser.rb', line 21 def rewrite rewritten_content = parse_for_urls(content) parse_for_ids(rewritten_content) end |