source2md 0.0.12 → 0.0.13

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: 562135200c7492a703d690fe621a77ef6341567ef499a0a868033db4c93f0d72
4
- data.tar.gz: 9bb67852ae6ae568edded0478116ea78e9e24ce58d58ce16df0c6b692f515f59
3
+ metadata.gz: 563959d92fa1520a3e09544319ff3eb9a50ac0136cc68edb290b98dc6d005e4e
4
+ data.tar.gz: 895fe538bd66ae956f5892b8278a4f7936140e78e07231d2cab7e6d926834b78
5
5
  SHA512:
6
- metadata.gz: 619ff51efb9c41fe3cbeea92774fc3e853e5c915fde446f9118f1af9c5dc6262ea510430c7e48bf338f822d3f6f58d9f2d69e095c04c035d02d63c84c6f82a1b
7
- data.tar.gz: cf9e28c97304ba30b623a5d7f66a4c79ba47231f5ce8d3ac1c8452e5beeaba9c1f77f379be37412bc94eddceafd53261f5cf6e99020d4d7a4a230a80daf45cf1
6
+ metadata.gz: 83fc8fd71c70f95f3ccdb05b3119ea21dd6a09df913b58b254783189fefd2a370bdffd4d9becf77285ab2c7594a95b8529271f6b1587e94977ee023e4ebffbfb
7
+ data.tar.gz: 02d4b91d972ce7aeffb30dcd9af76001bbf2d2385e2082cc0db4e0e71d1e6e043930e404651dcff5e63606955b97c28b04d8d2f7b8b34963dd1426ca407528fe
@@ -1,17 +1,38 @@
1
1
  #+hidden: true
2
2
  require "./setup"
3
3
 
4
+ Source2MD.data_block_exclude = true
5
+
4
6
  puts Source2MD::Element.new(<<~EOS).to_md
5
7
  a
6
8
  b
7
9
  c
10
+ __END__
11
+ foo
8
12
  EOS
13
+ # >> head: {}
14
+ # >> body: "a\n b\nc\n__END__\nfoo\n"
15
+ # >> Source2MD::Formatter::TypeHidden => false
16
+ # >> Source2MD::Formatter::TypeCodeInclude =>
17
+ # >> Source2MD::Formatter::TypeRawInclude =>
18
+ # >> Source2MD::Formatter::TypeParseInclude =>
19
+ # >> Source2MD::Formatter::TypeTitle => false
20
+ # >> Source2MD::Formatter::TypeWarn =>
21
+ # >> Source2MD::Formatter::TypeAlert =>
22
+ # >> Source2MD::Formatter::TypeMethod =>
23
+ # >> Source2MD::Formatter::TypeTable => false
24
+ # >> Source2MD::Formatter::TypeSourceBlock => false
25
+ # >> Source2MD::Formatter::TypeText => false
26
+ # >> Source2MD::Formatter::TypePartialCode => true
9
27
  # >> > -------------------------------------------------------------------------------- Source2MD::Formatter::TypePartialCode
10
28
  # >> > {}
11
29
  # >> > ------------------------------------------------------------ in
12
30
  # >> > a
13
31
  # >> > b
14
32
  # >> > c
33
+ # >> > __END__
34
+ # >> > foo
35
+ # >> >
15
36
  # >> >
16
37
  # >> > ------------------------------------------------------------ out
17
38
  # >> > ```ruby
@@ -19,6 +40,7 @@ EOS
19
40
  # >> > b
20
41
  # >> > c
21
42
  # >> > ```
43
+ # >> >
22
44
  # >> > ------------------------------------------------------------
23
45
  # >> ```ruby
24
46
  # >> a
data/lib/source2md/cli.rb CHANGED
@@ -1,11 +1,12 @@
1
1
  module Source2MD
2
2
  class Cli < Thor
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 :readonly, type: :boolean, aliases: "-r", default: true
6
- class_option :default_lang, type: :string, aliases: "-l", default: "ruby"
7
- class_option :prefix_re, type: :string
8
- class_option :comment_re, type: :string
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
6
+ class_option :readonly, type: :boolean, aliases: "-r", default: true
7
+ class_option :default_lang, type: :string, aliases: "-l", default: "ruby"
8
+ class_option :prefix_re, type: :string
9
+ class_option :comment_re, type: :string
9
10
 
10
11
  def initialize(...)
11
12
  super
@@ -15,9 +16,10 @@ module Source2MD
15
16
  Source2MD.debug = true
16
17
  end
17
18
 
18
- Source2MD.xmp_out_exclude = options[:xmp_out_exclude]
19
- Source2MD.readonly = options[:readonly]
20
- Source2MD.default_lang = options[:default_lang]
19
+ Source2MD.xmp_out_exclude = options[:xmp_out_exclude]
20
+ Source2MD.data_block_exclude = options[:data_block_exclude]
21
+ Source2MD.readonly = options[:readonly]
22
+ Source2MD.default_lang = options[:default_lang]
21
23
 
22
24
  Source2MD::RE.update do |e|
23
25
  if v = options[:prefix_re]
@@ -6,7 +6,17 @@ module Source2MD
6
6
  end
7
7
 
8
8
  def to_md
9
- CodeBlock.new(element.body).to_md
9
+ CodeBlock.new(body).to_md
10
+ end
11
+
12
+ private
13
+
14
+ def body
15
+ if Source2MD.data_block_exclude
16
+ element.body.sub(/^__END__\R.*/m, "")
17
+ else
18
+ element.body
19
+ end
10
20
  end
11
21
  end
12
22
  end
@@ -53,7 +53,9 @@ module Source2MD
53
53
  if output_file.exist?
54
54
  FileUtils.chmod("a+w", output_file)
55
55
  end
56
+
56
57
  yield
58
+
57
59
  if Source2MD.readonly
58
60
  FileUtils.chmod("a-w", output_file)
59
61
  end
@@ -1,3 +1,3 @@
1
1
  module Source2MD
2
- VERSION = "0.0.12"
2
+ VERSION = "0.0.13"
3
3
  end
data/lib/source2md.rb CHANGED
@@ -16,6 +16,7 @@ module Source2MD
16
16
  config_accessor(:xmp_out_exclude) { false }
17
17
  config_accessor(:readonly) { true }
18
18
  config_accessor(:default_lang) { "ruby" }
19
+ config_accessor(:data_block_exclude) { false }
19
20
  end
20
21
 
21
22
  require "zeitwerk"
@@ -5,6 +5,9 @@ module Source2MD
5
5
  it "works" do
6
6
  actual = Element.new(<<~EOS).to_md
7
7
  (foo)
8
+ __END__
9
+ 1
10
+ 2
8
11
  EOS
9
12
  actual.should == <<~EOS
10
13
  ```ruby
data/spec/spec_helper.rb CHANGED
@@ -10,6 +10,7 @@ Zeitwerk::Loader.eager_load_all
10
10
 
11
11
  Source2MD.logger.level = :error
12
12
  Source2MD.xmp_out_exclude = true
13
+ Source2MD.data_block_exclude = true
13
14
 
14
15
  RSpec.configure do |config|
15
16
  config.expect_with :rspec do |c|
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.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akira Ikeda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-16 00:00:00.000000000 Z
11
+ date: 2023-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport