md2key 0.3.0 → 0.3.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: 68f197459ebaa8c0d704124fbabe5848342323a3
4
- data.tar.gz: 73c7143f88078d5e8c755a7657c68d77bcabd5f3
3
+ metadata.gz: 29fd6b603848015b2693b9fcce9711bfa0263f5d
4
+ data.tar.gz: ad03c56d3d802deb901ed64ec3114b36e976a05c
5
5
  SHA512:
6
- metadata.gz: 92103cd03fb7421ba0f5a619257a7e29cfa2dc3589a38a3d9e3ba2cc64603fe0cd81d643a9d0062df5ce9e3025d3c033666b2ed841c87455849d7e7f5e6de882
7
- data.tar.gz: da56aeb04ef8b4abfde8c3c5f0aef41f292bcc65b4c0a53fe515dbaf12da9d237c83ee0bcc4cd5b1bef65f8dc64c0cd4e0d3a55fb74ff9f4c141a895a4ca651e
6
+ metadata.gz: 0f0d5622209334146fd148b4aae44a520066bab4df69f5fbb1ad56a9400bc6db3f091a3437b762ef471dcf641947e10b7e79c9a5346e3d0d92ec2b922f102bb0
7
+ data.tar.gz: c5209f6eca3d337ed1c6f9023711042194fa04aaa1675c94d0f3b713bf41a1fe5f0f7d4f4876bb7c80fbe2872876bdcafe1a7146da1e7b4ccb53bb7e4e9ea666
data/CHANGELOG.md CHANGED
@@ -1,7 +1,11 @@
1
+ # v0.3.1
2
+
3
+ - Support inserting images
4
+
1
5
  # v0.3.0
2
6
 
3
- - Extra slides are deleted automatically
4
- - Md2key is changed not to fail even if a second slide does not exist
7
+ - Old extra slides before execution are deleted automatically
8
+ - Changed not to fail even if a second slide does not exist
5
9
 
6
10
  # v0.2.2
7
11
 
data/README.md CHANGED
@@ -53,6 +53,19 @@ Headers always create a new slide.
53
53
  - I'm fine thank you
54
54
  ```
55
55
 
56
+ ### Image
57
+
58
+ ![](https://i.gyazo.com/c9870e72ddf35a9dbd487fad4e6968bd.png)
59
+
60
+ ```markdown
61
+ # image slide
62
+
63
+ - This is an example
64
+ - You can insert an image
65
+
66
+ ![](/Applications/Keynote.app/Contents/Resources/keynote.help/Contents/Resources/GlobalArt/AppLanding_KeynoteP4.png)
67
+ ```
68
+
56
69
  ## License
57
70
 
58
71
  MIT License
@@ -18,6 +18,7 @@ module Md2key
18
18
  Keynote.show_template_slide # to select a layout of slide
19
19
  @markdown.slides.each_with_index do |slide, index|
20
20
  Keynote.create_slide(slide.title, slide.lines.join('\n'))
21
+ Keynote.insert_image(slide.image) if slide.image
21
22
  end
22
23
 
23
24
  Keynote.delete_template_slide
@@ -31,7 +31,7 @@ module Md2key
31
31
  def show_template_slide
32
32
  create_slide('', '') if slides_count < 2
33
33
  tell_keynote(<<-APPLE.unindent)
34
- show slide #{TEMPLATE_SLIDE_INDEX}
34
+ show slide #{TEMPLATE_SLIDE_INDEX} of document 1
35
35
  APPLE
36
36
  end
37
37
 
@@ -72,6 +72,30 @@ module Md2key
72
72
  APPLE
73
73
  end
74
74
 
75
+ # Insert image to the last slide
76
+ def insert_image(path)
77
+ tell_keynote(<<-APPLE.unindent)
78
+ tell document 1
79
+ set theSlide to slide #{slides_count}
80
+ set theImage to POSIX file "#{path}"
81
+ set docWidth to its width
82
+ set docHeight to its height
83
+
84
+ tell slide #{TEMPLATE_SLIDE_INDEX}
85
+ set imgFile to make new image with properties { file: theImage, width: docWidth / 3 }
86
+ tell imgFile
87
+ set imgWidth to its width
88
+ set imgHeight to its width
89
+ end tell
90
+ end tell
91
+
92
+ tell theSlide
93
+ make new image with properties { file: theImage, width: imgWidth, position: { docWidth - imgWidth - 60, docHeight / 2 - imgHeight / 2} }
94
+ end tell
95
+ end tell
96
+ APPLE
97
+ end
98
+
75
99
  private
76
100
 
77
101
  def slides_count
@@ -49,7 +49,13 @@ module Md2key
49
49
  # FIXME: support nested list
50
50
  slide.lines += li_texts(node).flatten
51
51
  when 'p'
52
- slide.lines << node.text
52
+ node.children.each do |child|
53
+ if child.is_a?(Oga::XML::Element) && child.name == 'img'
54
+ slide.image = child.attribute('src').value
55
+ next
56
+ end
57
+ slide.lines << child.text
58
+ end
53
59
  when 'hr'
54
60
  # noop
55
61
  end
data/lib/md2key/slide.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Md2key
2
- class Slide < Struct.new(:title, :lines)
2
+ class Slide < Struct.new(:title, :lines, :image)
3
3
  def initialize(*)
4
4
  super
5
5
  self.lines ||= []
@@ -1,3 +1,3 @@
1
1
  module Md2key
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: md2key
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun