Class: Banzai::Filter::WikiLinkFilter
- Inherits:
-
HTML::Pipeline::Filter
- Object
- HTML::Pipeline::Filter
- Banzai::Filter::WikiLinkFilter
- Includes:
- Gitlab::Utils::SanitizeNodeLink
- Defined in:
- lib/banzai/filter/wiki_link_filter.rb,
lib/banzai/filter/wiki_link_filter/rewriter.rb
Overview
HTML filter that “fixes” links to pages/files in a wiki. Rewrite rules are documented in the `WikiPipeline` spec.
Context options:
:wiki
Defined Under Namespace
Classes: Rewriter
Constant Summary
Constants included from Gitlab::Utils::SanitizeNodeLink
Gitlab::Utils::SanitizeNodeLink::ATTRS_TO_SANITIZE, Gitlab::Utils::SanitizeNodeLink::UNSAFE_PROTOCOLS
Instance Method Summary collapse
Methods included from Gitlab::Utils::SanitizeNodeLink
#remove_unsafe_links, #safe_protocol?
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/banzai/filter/wiki_link_filter.rb', line 13 def call return doc unless wiki? doc.search('a:not(.gfm)').each { |el| process_link(el.attribute('href'), el) } doc.search('video, audio').each { |el| process_link(el.attribute('src'), el) } doc.search('img').each do |el| attr = el.attribute('data-src') || el.attribute('src') process_link(attr, el) end doc end |