md2key 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/md2key/converter.rb +8 -3
- data/lib/md2key/highlight.rb +3 -10
- data/lib/md2key/keynote.rb +17 -0
- data/lib/md2key/markdown.rb +31 -2
- data/lib/md2key/slide.rb +1 -1
- data/lib/md2key/table.rb +4 -0
- data/lib/md2key/version.rb +1 -1
- data/scripts/create_slide_and_insert_table.scpt +29 -0
- data/scripts/update_table.scpt +22 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c7595398a53c91167545a3c662be59191368ce2
|
4
|
+
data.tar.gz: 3cd48b2fd10db287d216cc66763f42fbea4a6f74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c17ea6fe7f45fc60317e86686aa8045177df35c5ca1010581a8a1afd7dbcacd1d4a390a088da9ac8892bf73258c35229bc72507e2c391406e48eac23ed1814e1
|
7
|
+
data.tar.gz: 07ea02c224a2c633acc4b4c34e9bdc4e256f23bc6fe34d92ace3f9ee846f76babf7951d52dfa92dbfc513b210dc994d515150e66a2e3c7d56a1ee76bcca2e57c
|
data/CHANGELOG.md
CHANGED
data/lib/md2key/converter.rb
CHANGED
@@ -27,9 +27,14 @@ module Md2key
|
|
27
27
|
def generate_contents
|
28
28
|
Keynote.update_cover(@markdown.cover)
|
29
29
|
@markdown.slides.each_with_index do |slide, index|
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
if slide.table
|
31
|
+
Keynote.create_slide_with_table(slide, slide.table.rows, slide.table.columns)
|
32
|
+
Keynote.insert_table(slide.table.data)
|
33
|
+
else
|
34
|
+
Keynote.create_slide(slide)
|
35
|
+
Keynote.insert_image(slide.image) if slide.image
|
36
|
+
Keynote.insert_code(slide.code) if slide.code
|
37
|
+
end
|
33
38
|
end
|
34
39
|
end
|
35
40
|
end
|
data/lib/md2key/highlight.rb
CHANGED
@@ -7,17 +7,10 @@ module Md2key
|
|
7
7
|
|
8
8
|
extension = code.extension || DEFAULT_EXTENSION
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
IO.popen(['highlight', '-O', 'rtf', '-K', '28', '-s', 'rdark', '-k', 'Monaco', file.path], 'r+') do |highlight|
|
15
|
-
IO.popen('pbcopy', 'w+') do |pbcopy|
|
16
|
-
pbcopy.write(highlight.read)
|
17
|
-
end
|
10
|
+
IO.popen("highlight -O rtf -K 28 -s rdark -k Monaco -S #{extension} | pbcopy", 'w+') do |highlight|
|
11
|
+
highlight.write(code.source)
|
12
|
+
highlight.close
|
18
13
|
end
|
19
|
-
ensure
|
20
|
-
file.delete
|
21
14
|
end
|
22
15
|
|
23
16
|
private
|
data/lib/md2key/keynote.rb
CHANGED
@@ -23,6 +23,11 @@ module Md2key
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
# @param [Md2key::Slide] slide
|
27
|
+
def create_slide_with_table(slide, rows, columns)
|
28
|
+
execute_applescript('create_slide_and_insert_table', slide.title, TEMPLATE_SLIDE_INDEX, rows, columns)
|
29
|
+
end
|
30
|
+
|
26
31
|
def ensure_template_slide_availability
|
27
32
|
return if slides_count >= 2
|
28
33
|
execute_applescript('create_empty_slide')
|
@@ -49,6 +54,18 @@ module Md2key
|
|
49
54
|
paste_clipboard
|
50
55
|
end
|
51
56
|
|
57
|
+
def insert_table(data)
|
58
|
+
row_index = 1
|
59
|
+
data.each do |row|
|
60
|
+
param = [slides_count, row_index]
|
61
|
+
row.each do |cell|
|
62
|
+
param << cell
|
63
|
+
end
|
64
|
+
execute_applescript('update_table', *param)
|
65
|
+
row_index += 1
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
52
69
|
private
|
53
70
|
|
54
71
|
def insert_code_background
|
data/lib/md2key/markdown.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'md2key/line'
|
2
2
|
require 'md2key/slide'
|
3
|
+
require 'md2key/table'
|
3
4
|
require 'oga'
|
4
5
|
require 'redcarpet'
|
5
6
|
|
@@ -51,6 +52,34 @@ module Md2key
|
|
51
52
|
slide.title = node.text
|
52
53
|
when 'ul'
|
53
54
|
slide.lines.concat(li_lines(node))
|
55
|
+
when 'ol'
|
56
|
+
slide.lines.concat(li_lines(node))
|
57
|
+
when 'table'
|
58
|
+
row_data = []
|
59
|
+
rows = 0
|
60
|
+
columns = 0
|
61
|
+
row_text = []
|
62
|
+
node.children[0].children.each do |child|
|
63
|
+
next if !child.is_a?(Oga::XML::Element) || child.name != 'tr'
|
64
|
+
rows += 1
|
65
|
+
child.children.each do |td|
|
66
|
+
next if !td.is_a?(Oga::XML::Element) || td.name != 'th'
|
67
|
+
columns += 1
|
68
|
+
row_text << td.text
|
69
|
+
end
|
70
|
+
end
|
71
|
+
row_data << row_text
|
72
|
+
node.children[1].children.each do |child|
|
73
|
+
next if !child.is_a?(Oga::XML::Element) || child.name != 'tr'
|
74
|
+
row_text = []
|
75
|
+
child.children.each do |td|
|
76
|
+
next if !td.is_a?(Oga::XML::Element) || td.name != 'td'
|
77
|
+
row_text << td.text
|
78
|
+
end
|
79
|
+
row_data << row_text
|
80
|
+
rows += 1
|
81
|
+
end
|
82
|
+
slide.table = Table.new(rows, columns, row_data)
|
54
83
|
when 'p'
|
55
84
|
node.children.each do |child|
|
56
85
|
if child.is_a?(Oga::XML::Element) && child.name == 'img'
|
@@ -75,7 +104,7 @@ module Md2key
|
|
75
104
|
# @return [Array<Md2Key::Line>]
|
76
105
|
def li_lines(ul_node, indent: 0)
|
77
106
|
return [] unless ul_node.is_a?(Oga::XML::Element)
|
78
|
-
return [] if ul_node.name != 'ul'
|
107
|
+
return [] if ul_node.name != 'ul' && ul_node.name != 'ol'
|
79
108
|
|
80
109
|
lines = []
|
81
110
|
ul_node.children.each do |li_node|
|
@@ -101,7 +130,7 @@ module Md2key
|
|
101
130
|
Redcarpet::Render::XHTML.new(
|
102
131
|
escape_html: true,
|
103
132
|
),
|
104
|
-
fenced_code_blocks: true,
|
133
|
+
fenced_code_blocks: true, :tables => true
|
105
134
|
)
|
106
135
|
redcarpet.render(markdown)
|
107
136
|
end
|
data/lib/md2key/slide.rb
CHANGED
data/lib/md2key/table.rb
ADDED
data/lib/md2key/version.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
on run argv
|
2
|
+
set slideTitle to item 1 of argv
|
3
|
+
set templateIndex to item 2 of argv as number
|
4
|
+
set rowCount to item 3 of argv as number
|
5
|
+
set columnCount to item 4 of argv as number
|
6
|
+
|
7
|
+
set headerRowCount to 1
|
8
|
+
set headerColumnCount to 0
|
9
|
+
set footerRowCount to 0
|
10
|
+
|
11
|
+
tell application "Keynote"
|
12
|
+
set thisDocument to the front document
|
13
|
+
tell thisDocument
|
14
|
+
-- Workaround to select correct master slide. In spite of master slide can be selected by name,
|
15
|
+
-- name property is not limited to be unique.
|
16
|
+
-- So move the focus to second slide and force "make new slide" to use the exact master slide.
|
17
|
+
move slide templateIndex to before slide templateIndex
|
18
|
+
|
19
|
+
set newSlide to make new slide
|
20
|
+
tell newSlide
|
21
|
+
try
|
22
|
+
set base slide to master slide "Title - Top" of thisDocument
|
23
|
+
end try
|
24
|
+
set object text of default title item to slideTitle
|
25
|
+
set newTable to make new table with properties {column count:columnCount, row count:rowCount, footer row count:footerRowCount,header column count:headerColumnCount,header row count:headerRowCount}
|
26
|
+
end tell
|
27
|
+
end tell
|
28
|
+
end tell
|
29
|
+
end run
|
@@ -0,0 +1,22 @@
|
|
1
|
+
on run argv
|
2
|
+
set slideIndex to item 1 of argv as number
|
3
|
+
set rowIndex to item 2 of argv as number
|
4
|
+
|
5
|
+
tell application "Keynote"
|
6
|
+
tell the front document
|
7
|
+
tell slide slideIndex
|
8
|
+
set thisTable to the first table
|
9
|
+
tell thisTable
|
10
|
+
set idx to 1
|
11
|
+
repeat with i in items 3 thru end of argv
|
12
|
+
tell cell rowIndex of column idx
|
13
|
+
set value to i
|
14
|
+
set the font size to 12
|
15
|
+
end tell
|
16
|
+
set idx to idx + 1
|
17
|
+
end repeat
|
18
|
+
end tell
|
19
|
+
end tell
|
20
|
+
end tell
|
21
|
+
end tell
|
22
|
+
end run
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: md2key
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -119,10 +119,12 @@ files:
|
|
119
119
|
- lib/md2key/markdown.rb
|
120
120
|
- lib/md2key/pbcopy.rb
|
121
121
|
- lib/md2key/slide.rb
|
122
|
+
- lib/md2key/table.rb
|
122
123
|
- lib/md2key/version.rb
|
123
124
|
- md2key.gemspec
|
124
125
|
- scripts/activate_slide.scpt
|
125
126
|
- scripts/create_empty_slide.scpt
|
127
|
+
- scripts/create_slide_and_insert_table.scpt
|
126
128
|
- scripts/create_slide_and_select_body.scpt
|
127
129
|
- scripts/create_slide_and_write_body.scpt
|
128
130
|
- scripts/delete_extra_slides.scpt
|
@@ -133,6 +135,7 @@ files:
|
|
133
135
|
- scripts/paste_clipboard.scpt
|
134
136
|
- scripts/slides_count.scpt
|
135
137
|
- scripts/update_slide.scpt
|
138
|
+
- scripts/update_table.scpt
|
136
139
|
homepage: https://github.com/k0kubun/md2key
|
137
140
|
licenses: []
|
138
141
|
metadata: {}
|
@@ -157,4 +160,3 @@ signing_key:
|
|
157
160
|
specification_version: 4
|
158
161
|
summary: Convert markdown to keynote
|
159
162
|
test_files: []
|
160
|
-
has_rdoc:
|