File: del.rb

package info (click to toggle)
ruby-reverse-markdown 3.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 440 kB
  • sloc: ruby: 1,452; makefile: 4
file content (26 lines) | stat: -rw-r--r-- 570 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module ReverseMarkdown
  module Converters
    class Del < Base
      def convert(node, state = {})
        content = treat_children(node, state.merge(already_crossed_out: true))
        if disabled? || content.strip.empty? || state[:already_crossed_out]
          content
        else
          "~~#{content}~~"
        end
      end

      def enabled?
        ReverseMarkdown.config.github_flavored
      end

      def disabled?
        !enabled?
      end
    end

    register :strike, Del.new
    register :s,      Del.new
    register :del,    Del.new
  end
end