source2md 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +196 -40
  3. data/Rakefile +26 -0
  4. data/doc/0100_top.rb +17 -0
  5. data/doc/0110_code_small.rb +23 -0
  6. data/doc/0120_code_long.rb +23 -0
  7. data/doc/0130_title.rb +21 -0
  8. data/doc/0140_md_like_title.rb +21 -0
  9. data/doc/0150_table.rb +35 -0
  10. data/doc/0160_method.rb +37 -0
  11. data/doc/0170_alert.rb +25 -0
  12. data/doc/0180_text.rb +15 -0
  13. data/doc/0190_raw.rb +19 -0
  14. data/doc/setup.rb +4 -0
  15. data/examples/element_alert.rb +22 -0
  16. data/examples/element_deep_comment.rb +12 -16
  17. data/examples/element_include.rb +20 -0
  18. data/examples/element_md_header.rb +4 -4
  19. data/examples/element_md_title.rb +14 -0
  20. data/examples/element_method.rb +3 -3
  21. data/examples/{element_pre.rb → element_partial_code.rb} +5 -5
  22. data/examples/element_source_block.rb +28 -0
  23. data/examples/element_table.rb +17 -25
  24. data/examples/element_text.rb +1 -1
  25. data/examples/{element_title2.rb → element_title.rb} +12 -8
  26. data/examples/element_warn.rb +22 -0
  27. data/examples/input.rb +11 -7
  28. data/examples/input.yml +3 -0
  29. data/examples/output.md +7 -22
  30. data/examples/scanner.rb +24 -0
  31. data/examples/setup.rb +1 -1
  32. data/lib/source2md/cli.rb +8 -1
  33. data/lib/source2md/code_block.rb +21 -2
  34. data/lib/source2md/element.rb +36 -13
  35. data/lib/source2md/generator.rb +4 -4
  36. data/lib/source2md/scanner.rb +34 -0
  37. data/lib/source2md/{file_block.rb → section.rb} +4 -5
  38. data/lib/source2md/text_helper.rb +1 -1
  39. data/lib/source2md/type/base.rb +4 -19
  40. data/lib/source2md/type/element_alert.rb +17 -0
  41. data/lib/source2md/type/element_else.rb +18 -0
  42. data/lib/source2md/type/element_include.rb +45 -0
  43. data/lib/source2md/type/element_md_title.rb +13 -0
  44. data/lib/source2md/type/element_method.rb +1 -1
  45. data/lib/source2md/type/{element_pre.rb → element_partial_code.rb} +2 -2
  46. data/lib/source2md/type/element_source_block.rb +25 -0
  47. data/lib/source2md/type/element_table.rb +4 -4
  48. data/lib/source2md/type/element_title.rb +35 -0
  49. data/lib/source2md/type/element_uncomment.rb +24 -0
  50. data/lib/source2md/type/element_warn.rb +19 -0
  51. data/lib/source2md/version.rb +1 -1
  52. data/lib/source2md.rb +2 -0
  53. data/source2md.gemspec +4 -3
  54. data/spec/code_block_spec.rb +1 -1
  55. data/spec/scanner_spec.rb +26 -0
  56. data/spec/spec_helper.rb +1 -0
  57. data/spec/text_helper_spec.rb +15 -0
  58. data/spec/type/element_alert_spec.rb +16 -0
  59. data/spec/type/element_include_spec.rb +40 -0
  60. data/spec/type/element_md_header_spec.rb +1 -17
  61. data/spec/type/{element_title2_spec.rb → element_md_title_spec.rb} +3 -3
  62. data/spec/type/element_method_spec.rb +5 -5
  63. data/spec/type/{element_pre_spec.rb → element_partial_code_spec.rb} +3 -3
  64. data/spec/type/element_reject_spec.rb +1 -1
  65. data/spec/type/element_source_block_spec.rb +31 -0
  66. data/spec/type/element_table_spec.rb +14 -1
  67. data/spec/type/element_text_spec.rb +1 -1
  68. data/spec/type/{element_deep_comment_spec.rb → element_title_spec.rb} +3 -5
  69. data/spec/type/element_warn_spec.rb +16 -0
  70. data/spec/type/sample.yml +1 -0
  71. metadata +70 -17
  72. data/lib/source2md/type/element_text.rb +0 -26
  73. data/lib/source2md/type/element_title2.rb +0 -14
@@ -1,9 +1,9 @@
1
1
  require "./setup"
2
2
 
3
3
  puts Source2MD::Element.new(<<~EOS).to_md
4
- # name: (name)
5
- # desc: (desc)
6
- # comment: (comment)
4
+ #+name: (name)
5
+ #+desc: (desc)
6
+ #+comment: (comment)
7
7
  code1
8
8
  #
9
9
  code2
@@ -1,22 +1,22 @@
1
1
  require "./setup"
2
2
 
3
3
  puts Source2MD::Element.new(<<~EOS).to_md
4
- code
4
+ (foo)
5
5
  EOS
6
6
  # >> --------------------------------------------------------------------------------
7
- # >> Source2MD::Type::ElementPre
7
+ # >> Source2MD::Type::ElementPartialCode
8
8
  # >>
9
9
  # >> head:
10
10
  # >> {}
11
11
  # >>
12
12
  # >> in:
13
- # >> code
13
+ # >> (foo)
14
14
  # >>
15
15
  # >> out:
16
16
  # >> ```ruby
17
- # >> code
17
+ # >> (foo)
18
18
  # >> ```
19
19
  # >> --------------------------------------------------------------------------------
20
20
  # >> ```ruby
21
- # >> code
21
+ # >> (foo)
22
22
  # >> ```
@@ -0,0 +1,28 @@
1
+ require "./setup"
2
+
3
+ puts Source2MD::Element.new(<<~EOS).to_md
4
+ #+BEGIN_SRC diff xxx:yyy
5
+ (foo)
6
+ #+END_SRC
7
+ EOS
8
+ # >> --------------------------------------------------------------------------------
9
+ # >> Source2MD::Type::ElementSourceBlock
10
+ # >>
11
+ # >> head:
12
+ # >> {}
13
+ # >>
14
+ # >> in:
15
+ # >> #+BEGIN_SRC diff xxx:yyy
16
+ # >> (foo)
17
+ # >> #+END_SRC
18
+ # >>
19
+ # >> out:
20
+ # >> ```diff xxx:yyy
21
+ # >> diff xxx:yyy
22
+ # >> (foo)
23
+ # >> ```
24
+ # >> --------------------------------------------------------------------------------
25
+ # >> ```diff xxx:yyy
26
+ # >> diff xxx:yyy
27
+ # >> (foo)
28
+ # >> ```
@@ -2,33 +2,25 @@ require "./setup"
2
2
 
3
3
  puts Source2MD::Element.new(<<~EOS).to_md
4
4
  # |---+---+---|
5
- # | x | x | x |
5
+ # | 1 | 1 | 1 |
6
6
  # |---+---+---|
7
- # | x | x | x |
8
- # | x | x | x |
7
+ # | 1 | 1 | 1 |
8
+ # | 1 | 1 | 1 |
9
9
  # |---+---+---|
10
10
  EOS
11
- # >> --------------------------------------------------------------------------------
12
- # >> Source2MD::Type::ElementTable
13
- # >>
14
- # >> head:
15
- # >> {}
16
- # >>
17
- # >> in:
18
- # >> # |---+---+---|
19
- # >> # | x | x | x |
20
- # >> # |---+---+---|
21
- # >> # | x | x | x |
22
- # >> # | x | x | x |
23
- # >> # |---+---+---|
24
- # >>
25
- # >> out:
26
- # >> | x | x | x |
11
+
12
+ puts Source2MD::Element.new(<<~EOS).to_md
13
+ # | 2 | 2 | 2 |
14
+ # |---+---+---|
15
+ # | 2 | 2 | 2 |
16
+ # | 2 | 2 | 2 |
17
+ EOS
18
+
19
+ # >> | 1 | 1 | 1 |
27
20
  # >> |---|---|---|
28
- # >> | x | x | x |
29
- # >> | x | x | x |
30
- # >> --------------------------------------------------------------------------------
31
- # >> | x | x | x |
21
+ # >> | 1 | 1 | 1 |
22
+ # >> | 1 | 1 | 1 |
23
+ # >> | 2 | 2 | 2 |
32
24
  # >> |---|---|---|
33
- # >> | x | x | x |
34
- # >> | x | x | x |
25
+ # >> | 2 | 2 | 2 |
26
+ # >> | 2 | 2 | 2 |
@@ -5,7 +5,7 @@ puts Source2MD::Element.new(<<~EOS).to_md
5
5
  # https://example.com/
6
6
  EOS
7
7
  # >> --------------------------------------------------------------------------------
8
- # >> Source2MD::Type::ElementText
8
+ # >> Source2MD::Type::ElementUncomment
9
9
  # >>
10
10
  # >> head:
11
11
  # >> {}
@@ -1,20 +1,24 @@
1
1
  require "./setup"
2
2
 
3
3
  puts Source2MD::Element.new(<<~EOS).to_md
4
- # title2: (foo)
4
+ #+title2: (foo)
5
5
  EOS
6
6
  # >> title2: (foo)
7
7
  # >> --------------------------------------------------------------------------------
8
- # >> Source2MD::Type::ElementTitle2
9
- # >>
8
+ # >> Source2MD::Type::ElementTitle
9
+ # >>
10
10
  # >> head:
11
11
  # >> {:title2=>"(foo)"}
12
- # >>
12
+ # >>
13
13
  # >> in:
14
- # >>
15
- # >>
14
+ # >>
15
+ # >>
16
16
  # >> out:
17
- # >> ## (foo) ##
17
+ # >>
18
+ # >> (foo)
19
+ # >>
18
20
  # >> --------------------------------------------------------------------------------
19
21
  # >> title2: (foo)
20
- # >> ## (foo) ##
22
+ # >>
23
+ # >> (foo)
24
+ # >>
@@ -0,0 +1,22 @@
1
+ require "./setup"
2
+
3
+ puts Source2MD::Element.new(<<~EOS).to_md
4
+ #+info: (foo)
5
+ EOS
6
+ # >> --------------------------------------------------------------------------------
7
+ # >> Source2MD::Type::ElementInfo
8
+ # >>
9
+ # >> head:
10
+ # >> {:info=>"(foo)"}
11
+ # >>
12
+ # >> in:
13
+ # >>
14
+ # >>
15
+ # >> out:
16
+ # >> :::message
17
+ # >> (foo)
18
+ # >> :::
19
+ # >> --------------------------------------------------------------------------------
20
+ # >> :::message
21
+ # >> (foo)
22
+ # >> :::
data/examples/input.rb CHANGED
@@ -1,13 +1,13 @@
1
- # title2: (title)
1
+ #+title2: (title)
2
2
 
3
- # name: (name1)
4
- # desc: (desc1)
5
- # comment: (comment1)
3
+ #+name: (name1)
4
+ #+desc: (desc1)
5
+ #+comment: (comment1)
6
6
  "foo1".size # => 4
7
7
 
8
- # name: (name2)
9
- # desc: (desc2)
10
- # comment: (comment2)
8
+ #+name: (name2)
9
+ #+desc: (desc2)
10
+ #+comment: (comment2)
11
11
  "foo2".size # => 4
12
12
 
13
13
  # |---+---+---|
@@ -16,3 +16,7 @@
16
16
  # | x | x | x |
17
17
  # | x | x | x |
18
18
  # |---+---+---|
19
+
20
+ #+BEGIN_SRC
21
+ 1 + 2 # => 3
22
+ #+END_SRC
@@ -0,0 +1,3 @@
1
+ ---
2
+ one:
3
+ foo: 1
data/examples/output.md CHANGED
@@ -1,26 +1,11 @@
1
- ## (title) ##
2
-
3
- ### (name1)
4
-
5
- (desc1)
6
-
7
1
  ```ruby
8
- "foo1".size # => 4
2
+ # ```yaml:config.yml
3
+ # frequencies: frequencies1.rb
4
+ # ```
9
5
  ```
10
6
 
11
- (comment1)
12
-
13
- ### (name2)
14
-
15
- (desc2)
16
-
17
- ```ruby
18
- "foo2".size # => 4
7
+ ```ruby:frequencies1.rb
8
+ def frequencies(words)
9
+ words.tally.sort_by { -_2 }.take(25)
10
+ end
19
11
  ```
20
-
21
- (comment2)
22
-
23
- | x | x | x |
24
- |---|---|---|
25
- | x | x | x |
26
- | x | x | x |
@@ -0,0 +1,24 @@
1
+ require "./setup"
2
+
3
+ Source2MD::Scanner.new(<<~EOS).to_a # => ["foo", "#+BEGIN_SRC\n\nfoo\n\n#+END_SRC", "foo"]
4
+ foo
5
+
6
+ #+BEGIN_SRC
7
+
8
+ foo
9
+
10
+ #+END_SRC
11
+
12
+ foo
13
+ EOS
14
+
15
+ Source2MD::Scanner.new(<<~EOS).to_a # => ["foo", "# ```yaml\n#+foo:\n# a\n# ```", "bar"]
16
+ foo
17
+
18
+ # ```yaml
19
+ #+foo:
20
+ # a
21
+ # ```
22
+
23
+ bar
24
+ EOS
data/examples/setup.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  $LOAD_PATH.unshift("#{__dir__}/../lib")
2
2
  require "source2md"
3
- Source2MD.logger.level = :debug
3
+ Source2MD.logger.level = :debug if true
data/lib/source2md/cli.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  module Source2MD
2
2
  class Cli < Thor
3
- class_option :debug, type: :boolean, aliases: "-d", default: false
3
+ class_option :debug, type: :boolean, aliases: "-d", default: false
4
+ class_option :xmp_out_exclude, type: :boolean, aliases: "-x", default: false
4
5
 
5
6
  def initialize(...)
6
7
  super
@@ -9,8 +10,14 @@ module Source2MD
9
10
  Source2MD.logger.level = :debug
10
11
  Source2MD.debug = true
11
12
  end
13
+
14
+ Source2MD.xmp_out_exclude = options[:xmp_out_exclude]
15
+
16
+ tp Source2MD.config
12
17
  end
13
18
 
19
+ # default_command :generate
20
+
14
21
  map "g" => :generate
15
22
  desc "generate [files]", "Markdown generation"
16
23
  option :output_file, type: :string, aliases: "-o", default: "output.md"
@@ -5,13 +5,16 @@ module Source2MD
5
5
 
6
6
  attr_accessor :code
7
7
 
8
- def initialize(code)
8
+ def initialize(code, options = {})
9
9
  @code = code
10
+ @options = {
11
+ lang: "ruby",
12
+ }.merge(options)
10
13
  end
11
14
 
12
15
  def to_md
13
16
  [
14
- "```ruby",
17
+ "```#{code_block_head}",
15
18
  normalized_code,
16
19
  "```",
17
20
  ] * "\n"
@@ -19,6 +22,22 @@ module Source2MD
19
22
 
20
23
  private
21
24
 
25
+ def code_block_head
26
+ o = []
27
+ if s = @options[:desc]
28
+ o << s
29
+ else
30
+ if s = @options[:lang]
31
+ o << s
32
+ end
33
+ if s = @options[:name]
34
+ o << ":"
35
+ o << s
36
+ end
37
+ end
38
+ o.join
39
+ end
40
+
22
41
  def normalized_code
23
42
  lines.collect(&method(:normalize)) * "\n"
24
43
  end
@@ -1,16 +1,21 @@
1
1
  module Source2MD
2
2
  class Element
3
- KEY_VALUE = /^# (\w+):\s+(.*)\R?/
3
+ KEY_VALUE = /^#\+(\S+):\s*(.*)\R?/
4
4
 
5
5
  PLUGINS = [
6
- Type::ElementReject,
7
- Type::ElementMdHeader,
8
- Type::ElementTitle2,
9
- Type::ElementMethod,
10
- Type::ElementTable,
11
- Type::ElementDeepComment,
12
- Type::ElementText,
13
- Type::ElementPre,
6
+ Type::ElementReject, # require "setup"
7
+ Type::ElementMdHeader, # ---
8
+ Type::ElementMdTitle, # ## foo ##
9
+ Type::ElementInclude, # #+include: foo.txt
10
+ Type::ElementTitle, # #+title2: foo
11
+ Type::ElementWarn, # #+warn: foo
12
+ Type::ElementAlert, # #+alert: foo
13
+ Type::ElementMethod, # #+name: foo
14
+ Type::ElementTable, # |-
15
+ Type::ElementSourceBlock, # #+BEGIN_SRC
16
+ Type::ElementUncomment, # foo
17
+ Type::ElementPartialCode, # 1 + 2 # => 3
18
+ Type::ElementElse,
14
19
  ]
15
20
 
16
21
  def initialize(content)
@@ -18,21 +23,39 @@ module Source2MD
18
23
  end
19
24
 
20
25
  def to_md
21
- support_klass.new(self).to_md
26
+ object = support_klass.new(self)
27
+ debug_log(object)
28
+ object.to_md
22
29
  end
23
30
 
24
31
  def head
25
- @content.scan(KEY_VALUE).to_h.symbolize_keys
32
+ @head ||= @content.scan(KEY_VALUE).to_h.symbolize_keys.freeze
26
33
  end
27
34
 
28
35
  def body
29
- @content.remove(KEY_VALUE).strip
36
+ @body ||= @content.remove(KEY_VALUE).strip.freeze
30
37
  end
31
38
 
32
39
  private
33
40
 
34
41
  def support_klass
35
- PLUGINS.find { |e| e.accept?(self) }
42
+ @support_klass ||= PLUGINS.find { |e| e.accept?(self) }
43
+ end
44
+
45
+ def debug_log(object)
46
+ Source2MD.logger.debug do
47
+ o = []
48
+ o << "-" * 80 + " " + object.class.name
49
+ o << head
50
+ o << "-" * 60 + " " + "in"
51
+ o << body
52
+ o << ""
53
+ o << "-" * 60 + " " + "out"
54
+ o << object.to_md
55
+ o << "-" * 60
56
+ s = o.compact * "\n"
57
+ s.gsub(/^/, "> ")
58
+ end
36
59
  end
37
60
  end
38
61
  end
@@ -14,13 +14,13 @@ module Source2MD
14
14
  private
15
15
 
16
16
  def to_md
17
- s = file_blocks.collect(&:to_md) * "\n\n"
18
- s = TextHelper.text_squish(s)
17
+ s = sections.collect(&:to_md) * "\n\n"
18
+ s = TextHelper.blank_lines_squish(s)
19
19
  s = TextHelper.add_newline_at_end_of_text(s)
20
20
  end
21
21
 
22
- def file_blocks
23
- @file_blocks ||= files.collect { |e| FileBlock.new(e) }
22
+ def sections
23
+ @sections ||= files.collect { |e| Section.new(e.read) }
24
24
  end
25
25
 
26
26
  def files
@@ -0,0 +1,34 @@
1
+ module Source2MD
2
+ class Scanner
3
+ SEPARATOR = "\\R{2,}"
4
+
5
+ MD_CODE_BLOCK_REGEXP = /^# ```.*?^# ```/m
6
+
7
+ BEGIN_KEY = "BEGIN_SRC"
8
+ END_KEY = "END_SRC"
9
+ SOURCE_BLOCK_REGEXP = /^#\+#{BEGIN_KEY}.*?^#\+#{END_KEY}/m
10
+
11
+ NORMAL_BLOCK_REGEXP = /.*?#{SEPARATOR}/m
12
+
13
+ PARAGRAPH_REGEXP = Regexp.union [
14
+ MD_CODE_BLOCK_REGEXP,
15
+ SOURCE_BLOCK_REGEXP,
16
+ NORMAL_BLOCK_REGEXP,
17
+ ]
18
+
19
+ def initialize(content)
20
+ @content = content
21
+ end
22
+
23
+ def to_a
24
+ v = @content
25
+ if Source2MD.xmp_out_exclude
26
+ v = v.remove(/^# >>.*$/)
27
+ end
28
+ v = v + "\n\n"
29
+ v = v.scan(PARAGRAPH_REGEXP)
30
+ v = v.collect(&:strip)
31
+ v = v.find_all(&:present?)
32
+ end
33
+ end
34
+ end
@@ -1,8 +1,7 @@
1
1
  module Source2MD
2
- class FileBlock
3
- def initialize(file)
4
- @file = file
5
- puts "read: #{file}"
2
+ class Section
3
+ def initialize(content)
4
+ @content = content
6
5
  end
7
6
 
8
7
  def to_md
@@ -12,7 +11,7 @@ module Source2MD
12
11
  private
13
12
 
14
13
  def elements
15
- @elements ||= @file.read.strip.split(/\n{2,}/).collect do |e|
14
+ @elements ||= Scanner.new(@content).to_a.collect do |e|
16
15
  Element.new(e)
17
16
  end
18
17
  end
@@ -2,7 +2,7 @@ module Source2MD
2
2
  module TextHelper
3
3
  extend self
4
4
 
5
- def text_squish(text)
5
+ def blank_lines_squish(text)
6
6
  text.gsub(/\n{2,}/, "\n\n")
7
7
  end
8
8
 
@@ -9,27 +9,12 @@ module Source2MD
9
9
 
10
10
  def initialize(element)
11
11
  @element = element
12
-
13
- Source2MD.logger.debug do
14
- o = []
15
- o << "-" * 80
16
- o << self.class.name
17
- o << ""
18
- o << "head:"
19
- o << element.head
20
- o << ""
21
- o << "in:"
22
- o << element.body
23
- o << ""
24
- o << "out:"
25
- o << to_md
26
- o << "-" * 80
27
- o.compact * "\n"
28
- end
29
12
  end
30
13
 
31
- def to_md
32
- end
14
+ # def to_md
15
+ #
16
+ # to_md
17
+ # end
33
18
  end
34
19
  end
35
20
  end
@@ -0,0 +1,17 @@
1
+ module Source2MD
2
+ module Type
3
+ class ElementAlert < Base
4
+ def self.accept?(element)
5
+ element.head[:alert]
6
+ end
7
+
8
+ def to_md
9
+ [
10
+ ":::message alert",
11
+ element.head[:alert],
12
+ ":::",
13
+ ] * "\n"
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ module Source2MD
2
+ module Type
3
+ class ElementElse < Base
4
+ def self.accept?(element)
5
+ true
6
+ end
7
+
8
+ def to_md
9
+ p "-" * 80
10
+ p element.head
11
+ p element.body
12
+ p element
13
+ p "-" * 80
14
+ abort
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,45 @@
1
+ module Source2MD
2
+ module Type
3
+ class ElementInclude < Base
4
+ def self.accept?(element)
5
+ element.head[:include]
6
+ end
7
+
8
+ def initialize(...)
9
+ super
10
+
11
+ @user_define_path, @desc = element.head[:include].split(/\s+/, 2)
12
+ end
13
+
14
+ def to_md
15
+ CodeBlock.new(body, code_block_options).to_md
16
+ end
17
+
18
+ private
19
+
20
+ def path
21
+ Pathname(@user_define_path).expand_path
22
+ end
23
+
24
+ def body
25
+ path.read.strip
26
+ end
27
+
28
+ def code_block_options
29
+ options = element.head.dup
30
+ options[:desc] ||= @desc
31
+ options[:lang] ||= auto_lang
32
+ options[:name] ||= path.basename
33
+ options
34
+ end
35
+
36
+ def auto_lang
37
+ {
38
+ # ".foo" => "bar",
39
+ }.fetch(path.extname) {
40
+ path.extname.scan(/\w+/).first
41
+ }
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,13 @@
1
+ module Source2MD
2
+ module Type
3
+ class ElementMdTitle < Base
4
+ def self.accept?(element)
5
+ element.head.blank? && element.body.match?(/\A(#+)\s+.*\s+\1\z/)
6
+ end
7
+
8
+ def to_md
9
+ element.body
10
+ end
11
+ end
12
+ end
13
+ end
@@ -7,7 +7,7 @@ module Source2MD
7
7
 
8
8
  def to_md
9
9
  [
10
- "### #{element.head[:name]}",
10
+ "### #{element.head[:name]} ###",
11
11
  element.head[:desc],
12
12
  body ? CodeBlock.new(body).to_md : nil,
13
13
  element.head[:comment],
@@ -1,8 +1,8 @@
1
1
  module Source2MD
2
2
  module Type
3
- class ElementPre < Base
3
+ class ElementPartialCode < Base
4
4
  def self.accept?(element)
5
- element.body.present?
5
+ !element.body.empty?
6
6
  end
7
7
 
8
8
  def to_md