Sha256: 52792943df9eead281bafd09d6e2110d161d14fefbf001c2f8410a005a7acb25

Contents?: true

Size: 511 Bytes

Versions: 3

Compression:

Stored size: 511 Bytes

Contents

module ReverseMarkdown
  module Converters
    class Strong < Base
      def convert(node)
        content = treat_children(node)
        if content.strip.empty? || already_strong?(node)
          content
        else
          "#{content[/^\s*/]}**#{content.strip}**#{content[/\s*$/]}"
        end
      end

      def already_strong?(node)
        node.ancestors('strong').size > 0 || node.ancestors('b').size > 0
      end
    end

    register :strong, Strong.new
    register :b,      Strong.new
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
reverse_markdown-0.8.2 lib/reverse_markdown/converters/strong.rb
reverse_markdown-0.8.1 lib/reverse_markdown/converters/strong.rb
reverse_markdown-0.8.0 lib/reverse_markdown/converters/strong.rb