source2md 0.0.5 → 0.0.6

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: f98d5b2f1f4a15eb936a3fa1fabbc4e38316b01f65bf317253cbdf6b3e8d79f5
4
- data.tar.gz: 9383810a16af7443690a4de9e2528f30d916319129f3bde75da1905325924048
3
+ metadata.gz: 45ea284efbf369a44f443d19ad9efef483c50d71b7d0a6a3061e22fd0a844ab4
4
+ data.tar.gz: f5e5ae8ac1275e92d6a09161f6561e3ca3ed39e13b821d69a3b5ceae53d23467
5
5
  SHA512:
6
- metadata.gz: db0be63ef5b74fc60841e4f3db52c928ece933c170580f28d5e8892c41f1bad662e68519d80ddf20fe325d840a7f93ffc59bb2a522532485afb581b6d1af637b
7
- data.tar.gz: 4c3f17eff3f140510e33061340fbecec8e909c9ac869324446f5c737d1d457f42c59477b278446e482d99f9e320e441ffa00318b3b543afac184f32557845bae
6
+ metadata.gz: 9b801b23ca8be860c0f76bbc6e3184b79ee9872b424108b83598dc23362667e00c21eb857c2995698addee97f85bd2995dc421b4f2d6dadd871e7f3db80eb6d0
7
+ data.tar.gz: 4972b72106e655da9078ce8962eb4bd32fbecccd520c1d7d0bd24b7e1029b6d9fa1aa2775ce9b9a4a980fd7af9d373d35be8c1666d67868eb1a04d5589f036cf
data/README.md CHANGED
@@ -72,15 +72,9 @@ EOS
72
72
  puts Source2MD::Section.new(<<~EOS).to_md
73
73
  #+hidden: true
74
74
  p "This paragraph is not displayed"
75
-
76
- p "This paragraph is displayed"
77
75
  EOS
78
76
  ```
79
77
 
80
- > ```ruby
81
- > p "This paragraph is displayed"
82
- > ```
83
-
84
78
  ### Code include ###
85
79
 
86
80
  ```ruby
data/doc/0130_hidden.rb CHANGED
@@ -7,11 +7,13 @@ require "./setup"
7
7
  puts Source2MD::Section.new(<<~EOS).to_md
8
8
  #+hidden: true
9
9
  p "This paragraph is not displayed"
10
-
11
- p "This paragraph is displayed"
12
10
  EOS
13
11
  #+END_SRC
14
12
 
15
- # > ```ruby
16
- # > p "This paragraph is displayed"
17
- # > ```
13
+ #+BEGIN_SRC
14
+ puts Source2MD::Section.new(<<~EOS).to_md
15
+ #+BEGIN_SRC hidden!
16
+ p "This paragraph is not displayed"
17
+ #+END_SRC
18
+ EOS
19
+ #+END_SRC
@@ -7,15 +7,20 @@ puts Source2MD::Element.new(<<~EOS).to_md
7
7
  #+name:
8
8
 
9
9
  EOS
10
- # ~> /Users/ikeda/src/source2md/lib/source2md/part/type_include.rb:27:in `read': No such file or directory @ rb_sysopen - /Users/ikeda/src/source2md/examples/input.yml diff xxx:yyy (Errno::ENOENT)
11
- # ~> from /Users/ikeda/src/source2md/lib/source2md/part/type_include.rb:27:in `read'
12
- # ~> from /Users/ikeda/src/source2md/lib/source2md/part/type_include.rb:27:in `body'
13
- # ~> from /Users/ikeda/src/source2md/lib/source2md/part/type_include.rb:17:in `to_md'
14
- # ~> from /Users/ikeda/src/source2md/lib/source2md/part/base.rb:25:in `block in initialize'
15
- # ~> from /opt/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/activesupport-7.0.6/lib/active_support/logger_thread_safe_level.rb:58:in `add'
16
- # ~> from /opt/rbenv/versions/3.2.2/lib/ruby/3.2.0/logger.rb:689:in `debug'
17
- # ~> from /Users/ikeda/src/source2md/lib/source2md/part/base.rb:13:in `initialize'
18
- # ~> from /Users/ikeda/src/source2md/lib/source2md/part/type_include.rb:9:in `initialize'
19
- # ~> from /Users/ikeda/src/source2md/lib/source2md/element.rb:27:in `new'
20
- # ~> from /Users/ikeda/src/source2md/lib/source2md/element.rb:27:in `to_md'
21
- # ~> from -:3:in `<main>'
10
+ # >> > -------------------------------------------------------------------------------- Source2MD::Formatter::TypeCodeInclude
11
+ # >> > {"code_include"=>"input.yml", "name"=>""}
12
+ # >> > ------------------------------------------------------------ in
13
+ # >> >
14
+ # >> >
15
+ # >> > ------------------------------------------------------------ out
16
+ # >> > ```yml:
17
+ # >> > ---
18
+ # >> > one:
19
+ # >> > foo: 1
20
+ # >> > ```
21
+ # >> > ------------------------------------------------------------
22
+ # >> ```yml:
23
+ # >> ---
24
+ # >> one:
25
+ # >> foo: 1
26
+ # >> ```
@@ -2,28 +2,18 @@
2
2
  require "./setup"
3
3
 
4
4
  puts Source2MD::Element.new(<<~EOS).to_md
5
- #+BEGIN_SRC diff xxx:yyy
5
+ #+BEGIN_SRC diff xxx:yyy hidden!
6
6
  (foo)
7
7
  #+END_SRC
8
8
  EOS
9
- # >> --------------------------------------------------------------------------------
10
- # >> Source2MD::Part::TypeSourceBlock
9
+ # >> > -------------------------------------------------------------------------------- Source2MD::Formatter::TypeSourceBlock
10
+ # >> > {}
11
+ # >> > ------------------------------------------------------------ in
12
+ # >> > #+BEGIN_SRC diff xxx:yyy hidden!
13
+ # >> > (foo)
14
+ # >> > #+END_SRC
15
+ # >> >
16
+ # >> > ------------------------------------------------------------ out
17
+ # >> >
18
+ # >> > ------------------------------------------------------------
11
19
  # >>
12
- # >> head:
13
- # >> {}
14
- # >>
15
- # >> in:
16
- # >> #+BEGIN_SRC diff xxx:yyy
17
- # >> (foo)
18
- # >> #+END_SRC
19
- # >>
20
- # >> out:
21
- # >> ```diff xxx:yyy
22
- # >> diff xxx:yyy
23
- # >> (foo)
24
- # >> ```
25
- # >> --------------------------------------------------------------------------------
26
- # >> ```diff xxx:yyy
27
- # >> diff xxx:yyy
28
- # >> (foo)
29
- # >> ```
@@ -6,6 +6,9 @@ module Source2MD
6
6
  end
7
7
 
8
8
  def to_md
9
+ if code_block_desc_keywords.include?("hidden!")
10
+ return ""
11
+ end
9
12
  CodeBlock.new(body, desc: code_block_desc).to_md
10
13
  end
11
14
 
@@ -20,6 +23,10 @@ module Source2MD
20
23
  md.captures.first.strip
21
24
  end
22
25
  end
26
+
27
+ def code_block_desc_keywords
28
+ code_block_desc.to_s.split(/\s+/).to_set
29
+ end
23
30
  end
24
31
  end
25
32
  end
@@ -1,19 +1,19 @@
1
1
  module Source2MD
2
2
  class Scanner
3
- SEPARATOR = "\\R{2,}"
3
+ SEPARATOR = "\\R{2,}"
4
4
 
5
- # MD_CODE_BLOCK_REGEXP = /^# ```.*?^# ```/m
5
+ # MD_CODE_BLOCK_RE = /^# ```.*?^# ```/m
6
6
 
7
- BEGIN_KEY = "BEGIN_SRC"
8
- END_KEY = "END_SRC"
9
- SOURCE_BLOCK_REGEXP = /^#\+#{BEGIN_KEY}.*?^#\+#{END_KEY}/m
7
+ SRC_BEGIN_KEY = "BEGIN_SRC"
8
+ SRC_END_KEY = "END_SRC"
9
+ SRC_BLOCK_RE = /^#\+#{SRC_BEGIN_KEY}.*?^#\+#{SRC_END_KEY}/m
10
10
 
11
- NORMAL_BLOCK_REGEXP = /.*?#{SEPARATOR}/m
11
+ NORMAL_BLOCK_RE = /.*?#{SEPARATOR}/m
12
12
 
13
- PARAGRAPH_REGEXP = Regexp.union [
14
- # MD_CODE_BLOCK_REGEXP,
15
- SOURCE_BLOCK_REGEXP,
16
- NORMAL_BLOCK_REGEXP,
13
+ PARAGRAPH_RE = Regexp.union [
14
+ # MD_CODE_BLOCK_RE,
15
+ SRC_BLOCK_RE,
16
+ NORMAL_BLOCK_RE,
17
17
  ]
18
18
 
19
19
  def initialize(content)
@@ -26,7 +26,7 @@ module Source2MD
26
26
  v = v.remove(/^# >>.*$/)
27
27
  end
28
28
  v = v + "\n\n"
29
- v = v.scan(PARAGRAPH_REGEXP)
29
+ v = v.scan(PARAGRAPH_RE)
30
30
  v = v.collect(&:strip)
31
31
  v = v.find_all(&:present?)
32
32
  end
@@ -1,3 +1,3 @@
1
1
  module Source2MD
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -27,5 +27,14 @@ module Source2MD
27
27
  ```
28
28
  EOS
29
29
  end
30
+
31
+ it "works" do
32
+ actual = Element.new(<<~EOS).to_md
33
+ #+BEGIN_SRC diff xxx:yyy hidden!
34
+ (foo)
35
+ #+END_SRC
36
+ EOS
37
+ actual.should == ""
38
+ end
30
39
  end
31
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: source2md
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akira Ikeda