source2md 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +196 -40
- data/Rakefile +26 -0
- data/doc/0100_top.rb +17 -0
- data/doc/0110_code_small.rb +23 -0
- data/doc/0120_code_long.rb +23 -0
- data/doc/0130_title.rb +21 -0
- data/doc/0140_md_like_title.rb +21 -0
- data/doc/0150_table.rb +35 -0
- data/doc/0160_method.rb +37 -0
- data/doc/0170_alert.rb +25 -0
- data/doc/0180_text.rb +15 -0
- data/doc/0190_raw.rb +19 -0
- data/doc/setup.rb +4 -0
- data/examples/element_alert.rb +22 -0
- data/examples/element_deep_comment.rb +12 -16
- data/examples/element_include.rb +20 -0
- data/examples/element_md_header.rb +4 -4
- data/examples/element_md_title.rb +14 -0
- data/examples/element_method.rb +3 -3
- data/examples/{element_pre.rb → element_partial_code.rb} +5 -5
- data/examples/element_source_block.rb +28 -0
- data/examples/element_table.rb +17 -25
- data/examples/element_text.rb +1 -1
- data/examples/{element_title2.rb → element_title.rb} +12 -8
- data/examples/element_warn.rb +22 -0
- data/examples/input.rb +11 -7
- data/examples/input.yml +3 -0
- data/examples/output.md +7 -22
- data/examples/scanner.rb +24 -0
- data/examples/setup.rb +1 -1
- data/lib/source2md/cli.rb +8 -1
- data/lib/source2md/code_block.rb +21 -2
- data/lib/source2md/element.rb +36 -13
- data/lib/source2md/generator.rb +4 -4
- data/lib/source2md/scanner.rb +34 -0
- data/lib/source2md/{file_block.rb → section.rb} +4 -5
- data/lib/source2md/text_helper.rb +1 -1
- data/lib/source2md/type/base.rb +4 -19
- data/lib/source2md/type/element_alert.rb +17 -0
- data/lib/source2md/type/element_else.rb +18 -0
- data/lib/source2md/type/element_include.rb +45 -0
- data/lib/source2md/type/element_md_title.rb +13 -0
- data/lib/source2md/type/element_method.rb +1 -1
- data/lib/source2md/type/{element_pre.rb → element_partial_code.rb} +2 -2
- data/lib/source2md/type/element_source_block.rb +25 -0
- data/lib/source2md/type/element_table.rb +4 -4
- data/lib/source2md/type/element_title.rb +35 -0
- data/lib/source2md/type/element_uncomment.rb +24 -0
- data/lib/source2md/type/element_warn.rb +19 -0
- data/lib/source2md/version.rb +1 -1
- data/lib/source2md.rb +2 -0
- data/source2md.gemspec +4 -3
- data/spec/code_block_spec.rb +1 -1
- data/spec/scanner_spec.rb +26 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/text_helper_spec.rb +15 -0
- data/spec/type/element_alert_spec.rb +16 -0
- data/spec/type/element_include_spec.rb +40 -0
- data/spec/type/element_md_header_spec.rb +1 -17
- data/spec/type/{element_title2_spec.rb → element_md_title_spec.rb} +3 -3
- data/spec/type/element_method_spec.rb +5 -5
- data/spec/type/{element_pre_spec.rb → element_partial_code_spec.rb} +3 -3
- data/spec/type/element_reject_spec.rb +1 -1
- data/spec/type/element_source_block_spec.rb +31 -0
- data/spec/type/element_table_spec.rb +14 -1
- data/spec/type/element_text_spec.rb +1 -1
- data/spec/type/{element_deep_comment_spec.rb → element_title_spec.rb} +3 -5
- data/spec/type/element_warn_spec.rb +16 -0
- data/spec/type/sample.yml +1 -0
- metadata +70 -17
- data/lib/source2md/type/element_text.rb +0 -26
- 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
|