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,26 +0,0 @@
1
- # > # foo
2
- # > # bar
3
- # > ↓
4
- # > foo
5
- # > bar
6
- module Source2MD
7
- module Type
8
- class ElementText < Base
9
- def self.accept?(element)
10
- if element.head.blank?
11
- element.body.lines.all? { |e| e.start_with?("# ") }
12
- end
13
- end
14
-
15
- def to_md
16
- body
17
- end
18
-
19
- private
20
-
21
- def body
22
- element.body.gsub(/^# /, "")
23
- end
24
- end
25
- end
26
- end
@@ -1,14 +0,0 @@
1
- module Source2MD
2
- module Type
3
- class ElementTitle2 < Base
4
- def self.accept?(element)
5
- element.head[:title2]
6
- end
7
-
8
- def to_md
9
- Source2MD.logger.info { "title2: #{element.head[:title2]}" }
10
- "## #{element.head[:title2]} ##"
11
- end
12
- end
13
- end
14
- end