jupyter_to_scrapbox 0.4.2 → 0.4.3

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
  SHA1:
3
- metadata.gz: 9a348d21b2862a5fbc1e57fc3464f8d4d09c8e4b
4
- data.tar.gz: 28b280bac91c3d3eeea06d0b26578d11a061ae49
3
+ metadata.gz: e086e825fec2562365d5e5b7eb3ea45015c9fa8d
4
+ data.tar.gz: e381f3422ec7f4d5cb674a68c33f8ca6f383d5a6
5
5
  SHA512:
6
- metadata.gz: f386387964a95167a162d1c9b81d5bdf567af673a6928e783f252ee01edff8fe21a0c19d3ea5eaf69c41af65a44ee5ff35e75762c271ce11f9e62ebbb01cfd5c
7
- data.tar.gz: 35a4c3818b3d4524bf721087485b818d508b8c54e26a35121c1a886cc96c405693b7395e91ced3bf8d04a1e2d988f7507bf59225817529be5b41dd29f313c592
6
+ metadata.gz: cf2b5e57e37e4250c2b97f194c389ab86e7678c48f75461541a52792a338f9554e87290212bc2eba1a7f60a5b3bbebae0ddbeec6312fc8bb5577057cce17bc80
7
+ data.tar.gz: ad8b5e90a239302c3d72adf976e5917d9ee48677ac61c3af7f59984d629034fdfaaefb70d241243d5abf09bbf190a6d4989b65f366d268b4edf57535f4a507f9
data/lib/cli.rb CHANGED
@@ -13,12 +13,15 @@ module JupyterToScrapbox
13
13
  method_option :verbose, type: :boolean, aliases: '-v', desc: 'verbose message', :default => false
14
14
  method_option :image, type: :boolean, aliases: '-i', desc: 'register images', :default => false
15
15
  method_option :markdown, type: :boolean, aliases: '-m', desc: 'process markdown', :default => true
16
+ method_option :asterisks, type: :numeric, aliases: '-a', desc: 'number of asterisks for h1', :default => 3
16
17
  desc 'converts FILES [options]', 'Convert jupyter-notebook files to scrapbox-json'
17
18
 
18
19
  def convert(*paths)
19
20
  JupyterToScrapbox::Converter.set_verbose(options[:verbose])
20
21
  JupyterToScrapbox::Converter.set_register_images(options[:image])
21
22
  JupyterToScrapbox::Converter.set_parse_markdown(options[:markdown])
23
+ JupyterToScrapbox::Converter.set_num_asterisks(options[:asterisks])
24
+
22
25
  if paths.length > 0
23
26
  paths.each do |path|
24
27
  JupyterToScrapbox::Converter.add(path)
@@ -41,6 +41,7 @@ module JupyterToScrapbox
41
41
  @@register_images=false
42
42
  @@parse_markdown_notations=true
43
43
  @@converters=[]
44
+ @@num_asterisk_for_h1=3
44
45
 
45
46
  def Converter.prepareGyazoclient()
46
47
  end
@@ -57,6 +58,10 @@ module JupyterToScrapbox
57
58
  @@parse_markdown_notations=v
58
59
  end
59
60
 
61
+ def Converter.set_num_asterisks(v)
62
+ @@num_asterisk_for_h1=v
63
+ end
64
+
60
65
  def Converter.add(path)
61
66
  @@converters.push Converter.new(path)
62
67
  end
@@ -123,7 +128,15 @@ module JupyterToScrapbox
123
128
  def push_markdown_text(s)
124
129
  s.split("\n").each do |s1|
125
130
  if @@parse_markdown_notations
126
- s1.sub!(%r!^\$\$(.+)\$\$!, '[$\1 ]' ) || s1.gsub!(%r!\$(.+)\$!, '[$\1 ]' )
131
+
132
+ # Atx style header
133
+ if s1.sub!(%r!^(#+)(.*)$!) { "["+"*"*([@@num_asterisk_for_h1+1-($1.length),1].max) + $2 + "]" }
134
+
135
+ # inline math
136
+ elsif s1.sub!(%r!^\$\$(.+)\$\$!, '[$\1 ]' )
137
+ else
138
+ s1.gsub!(%r!\$(.+)\$!, '[$\1 ]' )
139
+ end
127
140
  end
128
141
  @sb_json << s1
129
142
  end
@@ -1,3 +1,3 @@
1
1
  module JupyterToScrapbox
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jupyter_to_scrapbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroharu Sugawara
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-14 00:00:00.000000000 Z
11
+ date: 2017-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler