Class: Storyblok::Richtext::Marks::Link

Inherits:
Mark
  • Object
show all
Defined in:
lib/storyblok/richtext/html_renderer/marks/link.rb

Instance Attribute Summary

Attributes inherited from Mark

#type

Instance Method Summary collapse

Methods inherited from Mark

#initialize

Constructor Details

This class inherits a constructor from Storyblok::Richtext::Marks::Mark

Instance Method Details

#matchingObject



5
6
7
# File 'lib/storyblok/richtext/html_renderer/marks/link.rb', line 5

def matching
  @node['type'] === 'link'
end

#tagObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/storyblok/richtext/html_renderer/marks/link.rb', line 9

def tag
  attrs = @node['attrs']

  if attrs['anchor'].is_a?(String) and !attrs['anchor'].empty?
    attrs['href'] = "#{attrs['href']}##{attrs['anchor']}"
  end

  [{
    tag: "a",
    attrs: attrs.slice('href', 'target')
  }]
end