class Nexmo::Markdown::TooltipFilter

Public Instance Methods

call(input) click to toggle source
# File lib/nexmo_markdown_renderer/filters/tooltip_filter.rb, line 4
      def call(input)
        input.gsub(/\^\[([\p{Han}a-zA-Z0-9\s:\-]+)\]\((.+?)\)/) do
          tooltip = <<~HEREDOC
            <span class="Vlt-tooltip Vlt-tooltip--top" title="#{$2}" tabindex="0">
              #{$1}&nbsp;
              <svg class="Vlt-icon Vlt-icon--smaller Vlt-icon--text-bottom Vlt-blue" aria-hidden="true"><use xlink:href="/symbol/volta-icons.svg#Vlt-icon-help-negative"/></svg>
            </span>
          HEREDOC
    
          "FREEZESTART#{Base64.urlsafe_encode64(tooltip)}FREEZEEND"
        end
      end