jupyter_to_scrapbox 0.2.0 → 0.2.1

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: 7d2a15c678c3e7c12eac4b63d04528700b674bb7
4
- data.tar.gz: c33c25e8f02515aa8f57f23366aa9e59a0d15be4
3
+ metadata.gz: 6440292ab6d8a4baef46db1db99a9c1929f505aa
4
+ data.tar.gz: 700b0fe22a7b4ee0025f6d4846310e4b4acab625
5
5
  SHA512:
6
- metadata.gz: fa05b8410ece640bcfb1c3dc00144c0f2b392dc8d29f1d6fe8e5e5143b23b81da7ff7197a4021d434602281f9243a086fad63b2a4d641794864a19ade331f719
7
- data.tar.gz: c8fb5f0a9878dc104c346a3df6e7fd64584bacf5326c36c037144af4ce5d0045d31e37c78ca74d834a2625db5e2d2e6dddcd40a2f55e33a2fb3d0f17e7c2502e
6
+ metadata.gz: 3b0a86f60698038fcce4632445ad5ed77b5b41dcee5aae8be77359b4ce204fca90a2a08616167a6f2561cb3dc20063c864597a72989b5ff2a46baaea01b2deb9
7
+ data.tar.gz: 8431644eaff652863c7e6bc3cc0ff413a1aa6105894e10e56212d4f3adf7f00e9b9f2f2aa8a9da190977e5b5e0fec7abefd58ccfd6b8da07a64d08a61b287a87
@@ -11,10 +11,12 @@ module JupyterToScrapbox
11
11
  default_task :help
12
12
 
13
13
  method_option :verbose, type: :boolean, aliases: '-v', desc: 'verbose message'
14
+ method_option :moderate, type: :boolean, aliases: '-m', desc: 'moderate mode: do not convert markdown notations'
14
15
  desc 'converts FILES [options]', 'Convert jupyter-notebook files to scrapbox-json'
15
16
 
16
17
  def convert(*paths)
17
18
  JupyterToScrapbox::Converter.set_verbose() if options[:verbose]
19
+ JupyterToScrapbox::Converter.set_moderate() if options[:moderate]
18
20
  paths.each do |path|
19
21
  JupyterToScrapbox::Converter.add(path)
20
22
  end
@@ -1,3 +1,3 @@
1
1
  module JupyterToScrapbox
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -7,11 +7,16 @@ module JupyterToScrapbox
7
7
  class Converter
8
8
  @@verbose=false
9
9
  @@converters=[]
10
+ @@parse_markdown_notations=true
10
11
 
11
12
  def Converter.set_verbose()
12
13
  @@verbose=true
13
14
  end
14
15
 
16
+ def Converter.set_moderate()
17
+ @@parse_markdown_notations=false
18
+ end
19
+
15
20
  def Converter.add(path)
16
21
  @@converters.push Converter.new(path)
17
22
  end
@@ -48,19 +53,13 @@ module JupyterToScrapbox
48
53
  puts(s) if @@verbose
49
54
  end
50
55
 
51
- def push_text(s)
52
- s.split("\n").each do |s1|
53
- @sb_json << s1
54
- end
55
- end
56
-
57
56
  def push_empty_text()
58
57
  @sb_json << ""
59
58
  end
60
59
 
61
- def push_code(s)
60
+ def push_text(s)
62
61
  s.split("\n").each do |s1|
63
- @sb_json << "\t"+s1
62
+ @sb_json << s1
64
63
  end
65
64
  end
66
65
 
@@ -70,16 +69,37 @@ module JupyterToScrapbox
70
69
  end
71
70
  end
72
71
 
73
- def push_codes(ww)
72
+ def push_markdown_text(s)
73
+ s.split("\n").each do |s1|
74
+ if @@parse_markdown_notations
75
+ s1.sub!(%r!^\$\$(.+)\$\$!, '[$\1 ]' ) || s1.gsub!(%r!\$(.+)\$!, '[$\1 ]' )
76
+ end
77
+ @sb_json << s1
78
+ end
79
+ end
80
+
81
+ def push_markdown_texts(ww)
74
82
  ww.each do |s|
75
- push_code(s)
83
+ push_markdown_text(s)
76
84
  end
77
85
  end
78
86
 
79
87
  def parse_cell_markdown(md)
80
88
  vputs "-- source"
81
89
  vputs md["source"]
82
- push_texts(md["source"])
90
+ push_markdown_texts(md["source"])
91
+ end
92
+
93
+ def push_code(s)
94
+ s.split("\n").each do |s1|
95
+ @sb_json << "\t"+s1
96
+ end
97
+ end
98
+
99
+ def push_codes(ww)
100
+ ww.each do |s|
101
+ push_code(s)
102
+ end
83
103
  end
84
104
 
85
105
  def parse_cell_code(code)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jupyter_to_scrapbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroharu Sugawara