jupyter_to_scrapbox 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cli.rb +3 -0
- data/lib/jupyter_to_scrapbox.rb +14 -1
- data/lib/jupyter_to_scrapbox/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e086e825fec2562365d5e5b7eb3ea45015c9fa8d
|
4
|
+
data.tar.gz: e381f3422ec7f4d5cb674a68c33f8ca6f383d5a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)
|
data/lib/jupyter_to_scrapbox.rb
CHANGED
@@ -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
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2017-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|