source2md 0.0.18 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: afa045b32f44c8f86747fe720921365b18caa5a510f35dd7b093962ade54aa8e
4
- data.tar.gz: ebdd255858fb73a60ef6ff8df6a89d3a72d6310c8667a1927ca3a6808c437d91
3
+ metadata.gz: 27633f0c0b343c08b59225c30971fbcd2f70c8685c64f46aba8c7ee64827aeaf
4
+ data.tar.gz: f9e85e2afe2374c0b13a08369f279cd45cb0592746fca19d0ba3691a08c57977
5
5
  SHA512:
6
- metadata.gz: 360f9e298762344eb35bc92622bdba1b434edc3ee487cdf91f3a35f8f7240c0a99fd9c35a6e44daba531520e3b06ad31e87a4558db86c0582016e196eb4e1b7c
7
- data.tar.gz: cfa3e532bd2297f1493752dff9037c73fbd11e3bcc668ea206b016c550229e2fd0f5096c9c453cb31721c632d7ad0db8d2b4516f8e3540d4045d42c5f064b320
6
+ metadata.gz: 1d75891ce8bb4c77cec87c2f0d1390077ffe34970c24fe20acb563f72ebbd36ec7a5c05d5ebe5c84cc2646b543554b88f67ba4850304a5451e0c0101b6438cb8
7
+ data.tar.gz: de15373bb4c11f0cca950b9d0b1ab0f3f83162a3548681aeddae124281c9adacc6698b8669e842f90ba6bb56effd51fab7ee51b8b83378e803c6f3c9d02c7690
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # require "~/src/zenn/lib/default_task"
2
+
1
3
  require "bundler/gem_tasks"
2
4
 
3
5
  Pathname.glob("lib/source2md/tasks/**/*.rake").each { |file| load(file) }
@@ -3,11 +3,11 @@ require "./setup"
3
3
 
4
4
  puts Source2MD::Element.new(<<~EOS).to_md
5
5
  # ![](https://example.com/image.png)
6
- # **(alt)**
6
+ # *(alt)*
7
7
  EOS
8
8
 
9
9
  # >> head: {}
10
- # >> body: "# ![](https://example.com/image.png)\n# **(alt)**\n"
10
+ # >> body: "# ![](https://example.com/image.png)\n# *(alt)*\n"
11
11
  # >> Source2MD::Formatter::TypeHidden => false
12
12
  # >> Source2MD::Formatter::TypeEval =>
13
13
  # >> Source2MD::Formatter::TypeCodeInclude =>
@@ -28,13 +28,13 @@ EOS
28
28
  # >> > {}
29
29
  # >> > ------------------------------------------------------------ in
30
30
  # >> > # ![](https://example.com/image.png)
31
- # >> > # **(alt)**
31
+ # >> > # *(alt)*
32
32
  # >> >
33
33
  # >> >
34
34
  # >> > ------------------------------------------------------------ out
35
35
  # >> > ![](https://example.com/image.png)
36
- # >> > **(alt)**
36
+ # >> > *(alt)*
37
37
  # >> >
38
38
  # >> > ------------------------------------------------------------
39
39
  # >> ![](https://example.com/image.png)
40
- # >> **(alt)**
40
+ # >> *(alt)*
@@ -0,0 +1,39 @@
1
+ #+hidden: true
2
+ require "./setup"
3
+
4
+ puts Source2MD::Element.new(<<~EOS).to_md
5
+ # - a
6
+ # - b
7
+ EOS
8
+
9
+ # >> head: {}
10
+ # >> body: "# - a\n# - b\n"
11
+ # >> Source2MD::Formatter::TypeHidden => false
12
+ # >> Source2MD::Formatter::TypeEval =>
13
+ # >> Source2MD::Formatter::TypeCodeInclude =>
14
+ # >> Source2MD::Formatter::TypeRawInclude =>
15
+ # >> Source2MD::Formatter::TypeParseInclude =>
16
+ # >> Source2MD::Formatter::TypeTitle => false
17
+ # >> Source2MD::Formatter::TypeWarn =>
18
+ # >> Source2MD::Formatter::TypeAlert =>
19
+ # >> Source2MD::Formatter::TypeMethod =>
20
+ # >> Source2MD::Formatter::TypeTable => false
21
+ # >> Source2MD::Formatter::TypeSourceBlock => false
22
+ # >> Source2MD::Formatter::TypeMdHeader =>
23
+ # >> Source2MD::Formatter::TypeCodeBlock => false
24
+ # >> Source2MD::Formatter::TypeQuote =>
25
+ # >> Source2MD::Formatter::TypeList => true
26
+ # >> > -------------------------------------------------------------------------------- Source2MD::Formatter::TypeList
27
+ # >> > {}
28
+ # >> > ------------------------------------------------------------ in
29
+ # >> > # - a
30
+ # >> > # - b
31
+ # >> >
32
+ # >> >
33
+ # >> > ------------------------------------------------------------ out
34
+ # >> > - a
35
+ # >> > - b
36
+ # >> >
37
+ # >> > ------------------------------------------------------------
38
+ # >> - a
39
+ # >> - b
@@ -0,0 +1,41 @@
1
+ #+hidden: true
2
+ require "./setup"
3
+ Source2MD.oneline = true
4
+
5
+ puts Source2MD::Element.new(<<~EOS).to_md
6
+ # http://
7
+ # http://
8
+ EOS
9
+
10
+ # >> head: {}
11
+ # >> body: "# http://\n# http://\n"
12
+ # >> Source2MD::Formatter::TypeHidden => false
13
+ # >> Source2MD::Formatter::TypeEval =>
14
+ # >> Source2MD::Formatter::TypeCodeInclude =>
15
+ # >> Source2MD::Formatter::TypeRawInclude =>
16
+ # >> Source2MD::Formatter::TypeParseInclude =>
17
+ # >> Source2MD::Formatter::TypeTitle => false
18
+ # >> Source2MD::Formatter::TypeWarn =>
19
+ # >> Source2MD::Formatter::TypeAlert =>
20
+ # >> Source2MD::Formatter::TypeMethod =>
21
+ # >> Source2MD::Formatter::TypeTable => false
22
+ # >> Source2MD::Formatter::TypeSourceBlock => false
23
+ # >> Source2MD::Formatter::TypeMdHeader =>
24
+ # >> Source2MD::Formatter::TypeCodeBlock => false
25
+ # >> Source2MD::Formatter::TypeQuote =>
26
+ # >> Source2MD::Formatter::TypeList => false
27
+ # >> Source2MD::Formatter::TypeUrlList => true
28
+ # >> > -------------------------------------------------------------------------------- Source2MD::Formatter::TypeUrlList
29
+ # >> > {}
30
+ # >> > ------------------------------------------------------------ in
31
+ # >> > # http://
32
+ # >> > # http://
33
+ # >> >
34
+ # >> >
35
+ # >> > ------------------------------------------------------------ out
36
+ # >> > http://
37
+ # >> > http://
38
+ # >> >
39
+ # >> > ------------------------------------------------------------
40
+ # >> http://
41
+ # >> http://
data/lib/source2md/cli.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  module Source2MD
2
2
  class Cli < Thor
3
3
  class_option :debug, type: :boolean, aliases: "-d", default: false
4
- class_option :xmp_out_exclude, type: :boolean, aliases: "-x", default: false
5
- class_option :data_block_exclude, type: :boolean, default: false
4
+ class_option :xmp_out_exclude, type: :boolean, aliases: "-x", default: true
5
+ class_option :data_block_exclude, type: :boolean, default: true
6
6
  class_option :readonly, type: :boolean, aliases: "-r", default: true
7
- class_option :oneline, type: :boolean, aliases: "-1", default: false
7
+ class_option :oneline, type: :boolean, aliases: "-1", default: true
8
8
  class_option :lang_default, type: :string, aliases: "-l", default: "ruby"
9
9
  class_option :prefix_re, type: :string
10
10
  class_option :comment_re, type: :string
@@ -18,6 +18,7 @@ module Source2MD
18
18
  Formatter::TypeCodeBlock, # # ```
19
19
  Formatter::TypeQuote, # # > xxx
20
20
  Formatter::TypeList, # # - xxx or 1. xxx
21
+ Formatter::TypeUrlList, # # http.*
21
22
  Formatter::TypeInlineImage, # # ![]
22
23
 
23
24
  # Sentence (automatic wrap)
@@ -47,7 +47,18 @@ module Source2MD
47
47
  end
48
48
 
49
49
  def clean_descs
50
- option_list - OPTION_KEYS
50
+ lang_default_add(option_list - OPTION_KEYS)
51
+ end
52
+
53
+ # :yyy -> xxx:yyy
54
+ def lang_default_add(list)
55
+ list.collect do |e|
56
+ if e.start_with?(":")
57
+ Source2MD.lang_default + e
58
+ else
59
+ e
60
+ end
61
+ end
51
62
  end
52
63
  end
53
64
  end
@@ -0,0 +1,21 @@
1
+ module Source2MD
2
+ module Formatter
3
+ class TypeUrlList < Base
4
+
5
+ # "# http.*"
6
+ def self.regexp
7
+ %r{#{RE.meta_re}\s+(?:http)}
8
+ end
9
+
10
+ def self.accept?(element)
11
+ if element.body.present?
12
+ element.body.lines.all? { |e| e.match?(regexp) }
13
+ end
14
+ end
15
+
16
+ def to_md
17
+ element.body.remove(TypeText.regexp)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module Source2MD
2
- VERSION = "0.0.18"
2
+ VERSION = "0.0.19"
3
3
  end
data/lib/source2md.rb CHANGED
@@ -17,7 +17,7 @@ module Source2MD
17
17
  config_accessor(:readonly) { true }
18
18
  config_accessor(:lang_default) { "ruby" }
19
19
  config_accessor(:data_block_exclude) { false }
20
- config_accessor(:oneline) { false }
20
+ config_accessor(:oneline) { true }
21
21
  end
22
22
 
23
23
  require "zeitwerk"
@@ -5,11 +5,11 @@ module Source2MD
5
5
  it "works" do
6
6
  actual = Element.new(<<~EOS).to_md
7
7
  # ![](https://example.com/image.png)
8
- # **(alt)**
8
+ # *(alt)*
9
9
  EOS
10
10
  actual.should == <<~EOS
11
11
  ![](https://example.com/image.png)
12
- **(alt)**
12
+ *(alt)*
13
13
  EOS
14
14
  end
15
15
  end
@@ -0,0 +1,21 @@
1
+ require "spec_helper"
2
+
3
+ module Source2MD
4
+ describe do
5
+ it "works" do
6
+ actual = Element.new(<<~EOS).to_md
7
+ # - a
8
+ # - b
9
+ EOS
10
+ actual.should == <<~EOS
11
+ - a
12
+ - b
13
+ EOS
14
+ end
15
+ end
16
+ end
17
+ # >> .
18
+ # >>
19
+ # >> Finished in 0.00671 seconds (files took 0.42211 seconds to load)
20
+ # >> 1 example, 0 failures
21
+ # >>
@@ -28,6 +28,19 @@ module Source2MD
28
28
  EOS
29
29
  end
30
30
 
31
+ it "works" do
32
+ actual = Element.new(<<~EOS).to_md
33
+ #+BEGIN_SRC :yyy
34
+ (foo)
35
+ #+END_SRC
36
+ EOS
37
+ actual.should == <<~EOS
38
+ ```ruby:yyy
39
+ (foo)
40
+ ```
41
+ EOS
42
+ end
43
+
31
44
  it "works" do
32
45
  actual = Element.new(<<~EOS).to_md
33
46
  #+BEGIN_SRC diff xxx:yyy hidden!
@@ -54,12 +67,12 @@ module Source2MD
54
67
  end
55
68
  end
56
69
  # >> ...F
57
- # >>
70
+ # >>
58
71
  # >> Failures:
59
- # >>
72
+ # >>
60
73
  # >> 1) works
61
74
  # >> Failure/Error: Unable to find - to read failed line
62
- # >>
75
+ # >>
63
76
  # >> expected: ""
64
77
  # >> got: "```xxx:yyy data_block_exclude\n```\n" (using ==)
65
78
  # >> Diff:
@@ -67,11 +80,11 @@ end
67
80
  # >> +```xxx:yyy data_block_exclude
68
81
  # >> +```
69
82
  # >> # -:47:in `block (2 levels) in <module:Source2MD>'
70
- # >>
83
+ # >>
71
84
  # >> Finished in 0.01747 seconds (files took 0.33507 seconds to load)
72
85
  # >> 4 examples, 1 failure
73
- # >>
86
+ # >>
74
87
  # >> Failed examples:
75
- # >>
88
+ # >>
76
89
  # >> rspec -:40 # works
77
- # >>
90
+ # >>
@@ -49,5 +49,21 @@ EOS
49
49
  EOS
50
50
  actual.should == "アア\n"
51
51
  end
52
+
53
+ it "http" do
54
+ actual = Element.new(<<~EOS).to_md
55
+ # http://
56
+ # http://
57
+ EOS
58
+ actual.should == <<~EOS
59
+ http://
60
+ http://
61
+ EOS
62
+ end
52
63
  end
53
64
  end
65
+ # >> .....
66
+ # >>
67
+ # >> Finished in 0.00713 seconds (files took 0.33822 seconds to load)
68
+ # >> 5 examples, 0 failures
69
+ # >>
@@ -0,0 +1,21 @@
1
+ require "spec_helper"
2
+
3
+ module Source2MD
4
+ describe do
5
+ it "works" do
6
+ actual = Element.new(<<~EOS).to_md
7
+ # http://
8
+ # http://
9
+ EOS
10
+ actual.should == <<~EOS
11
+ http://
12
+ http://
13
+ EOS
14
+ end
15
+ end
16
+ end
17
+ # >> .
18
+ # >>
19
+ # >> Finished in 0.0059 seconds (files took 0.34597 seconds to load)
20
+ # >> 1 example, 0 failures
21
+ # >>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: source2md
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.18
4
+ version: 0.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akira Ikeda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-03 00:00:00.000000000 Z
11
+ date: 2024-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -180,6 +180,7 @@ files:
180
180
  - examples/type_eval.rb
181
181
  - examples/type_hidden.rb
182
182
  - examples/type_inline_image.rb
183
+ - examples/type_list.rb
183
184
  - examples/type_md_header.rb
184
185
  - examples/type_method.rb
185
186
  - examples/type_partial_code.rb
@@ -188,6 +189,7 @@ files:
188
189
  - examples/type_table.rb
189
190
  - examples/type_text.rb
190
191
  - examples/type_title.rb
192
+ - examples/type_url_list.rb
191
193
  - examples/type_warn.rb
192
194
  - lib/source2md.rb
193
195
  - lib/source2md/cli.rb
@@ -213,6 +215,7 @@ files:
213
215
  - lib/source2md/formatter/type_table.rb
214
216
  - lib/source2md/formatter/type_text.rb
215
217
  - lib/source2md/formatter/type_title.rb
218
+ - lib/source2md/formatter/type_url_list.rb
216
219
  - lib/source2md/formatter/type_warn.rb
217
220
  - lib/source2md/generator.rb
218
221
  - lib/source2md/logger.rb
@@ -233,6 +236,7 @@ files:
233
236
  - spec/formatter/type_eval_spec.rb
234
237
  - spec/formatter/type_hidden_spec.rb
235
238
  - spec/formatter/type_inline_image_spec.rb
239
+ - spec/formatter/type_list_spec.rb
236
240
  - spec/formatter/type_md_header_spec.rb
237
241
  - spec/formatter/type_method_spec.rb
238
242
  - spec/formatter/type_parse_include_spec.rb
@@ -243,6 +247,7 @@ files:
243
247
  - spec/formatter/type_table_spec.rb
244
248
  - spec/formatter/type_text_spec.rb
245
249
  - spec/formatter/type_title_spec.rb
250
+ - spec/formatter/type_url_list_spec.rb
246
251
  - spec/formatter/type_warn_spec.rb
247
252
  - spec/generator_spec.rb
248
253
  - spec/scanner_spec.rb
@@ -267,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
267
272
  - !ruby/object:Gem::Version
268
273
  version: '0'
269
274
  requirements: []
270
- rubygems_version: 3.5.4
275
+ rubygems_version: 3.5.9
271
276
  signing_key:
272
277
  specification_version: 4
273
278
  summary: Markdown generator from source code
@@ -280,6 +285,7 @@ test_files:
280
285
  - spec/formatter/type_eval_spec.rb
281
286
  - spec/formatter/type_hidden_spec.rb
282
287
  - spec/formatter/type_inline_image_spec.rb
288
+ - spec/formatter/type_list_spec.rb
283
289
  - spec/formatter/type_md_header_spec.rb
284
290
  - spec/formatter/type_method_spec.rb
285
291
  - spec/formatter/type_parse_include_spec.rb
@@ -290,6 +296,7 @@ test_files:
290
296
  - spec/formatter/type_table_spec.rb
291
297
  - spec/formatter/type_text_spec.rb
292
298
  - spec/formatter/type_title_spec.rb
299
+ - spec/formatter/type_url_list_spec.rb
293
300
  - spec/formatter/type_warn_spec.rb
294
301
  - spec/generator_spec.rb
295
302
  - spec/scanner_spec.rb