Class: Html2rss::AttributePostProcessors::HtmlTransformers::WrapImgInA
- Inherits:
-
Object
- Object
- Html2rss::AttributePostProcessors::HtmlTransformers::WrapImgInA
- Defined in:
- lib/html2rss/attribute_post_processors/html_transformers/wrap_img_in_a.rb
Overview
Transformer that wraps <img> tags into <a> tags linking to ‘img.src`.
Instance Method Summary collapse
- #already_wrapped?(node_name, node) ⇒ Boolean
-
#call(node_name:, node:, **_env) ⇒ nil
Wraps <img> tags into <a> tags that link to ‘img.src`.
Instance Method Details
#already_wrapped?(node_name, node) ⇒ Boolean
21 22 23 |
# File 'lib/html2rss/attribute_post_processors/html_transformers/wrap_img_in_a.rb', line 21 def already_wrapped?(node_name, node) node_name == 'img' && node.parent.name != 'a' end |
#call(node_name:, node:, **_env) ⇒ nil
Wraps <img> tags into <a> tags that link to ‘img.src`.
15 16 17 18 19 |
# File 'lib/html2rss/attribute_post_processors/html_transformers/wrap_img_in_a.rb', line 15 def call(node_name:, node:, **_env) return unless already_wrapped?(node_name, node) wrap_image_in_anchor(node) end |