pptx_markdown 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +37 -0
- data/bin/pptx_markdown +40 -0
- data/lib/pptx_markdown.rb +28 -0
- data/lib/pptx_markdown/builders/markdown.rb +9 -0
- data/lib/pptx_markdown/builders/pptx.rb +66 -0
- data/lib/pptx_markdown/parsers/markdown.rb +37 -0
- data/lib/pptx_markdown/parsers/pptx.rb +52 -0
- data/lib/pptx_markdown/presentation.rb +68 -0
- data/lib/pptx_markdown/shape.rb +72 -0
- data/lib/pptx_markdown/shape_mapper.rb +36 -0
- data/lib/pptx_markdown/slide.rb +40 -0
- data/lib/pptx_markdown/template/[Content_Types].xml +1 -0
- data/lib/pptx_markdown/template/ppt/notesMasters/_rels/notesMaster1.xml.rels +1 -0
- data/lib/pptx_markdown/template/ppt/notesMasters/notesMaster1.xml +1 -0
- data/lib/pptx_markdown/template/ppt/presProps.xml +1 -0
- data/lib/pptx_markdown/template/ppt/slideLayouts/_rels/slideLayout1.xml.rels +1 -0
- data/lib/pptx_markdown/template/ppt/slideLayouts/_rels/slideLayout10.xml.rels +1 -0
- data/lib/pptx_markdown/template/ppt/slideLayouts/_rels/slideLayout11.xml.rels +1 -0
- data/lib/pptx_markdown/template/ppt/slideLayouts/_rels/slideLayout2.xml.rels +1 -0
- data/lib/pptx_markdown/template/ppt/slideLayouts/_rels/slideLayout3.xml.rels +1 -0
- data/lib/pptx_markdown/template/ppt/slideLayouts/_rels/slideLayout4.xml.rels +1 -0
- data/lib/pptx_markdown/template/ppt/slideLayouts/_rels/slideLayout5.xml.rels +1 -0
- data/lib/pptx_markdown/template/ppt/slideLayouts/_rels/slideLayout6.xml.rels +1 -0
- data/lib/pptx_markdown/template/ppt/slideLayouts/_rels/slideLayout7.xml.rels +1 -0
- data/lib/pptx_markdown/template/ppt/slideLayouts/_rels/slideLayout8.xml.rels +1 -0
- data/lib/pptx_markdown/template/ppt/slideLayouts/_rels/slideLayout9.xml.rels +1 -0
- data/lib/pptx_markdown/template/ppt/slideLayouts/slideLayout1.xml +1 -0
- data/lib/pptx_markdown/template/ppt/slideLayouts/slideLayout10.xml +1 -0
- data/lib/pptx_markdown/template/ppt/slideLayouts/slideLayout11.xml +1 -0
- data/lib/pptx_markdown/template/ppt/slideLayouts/slideLayout2.xml +1 -0
- data/lib/pptx_markdown/template/ppt/slideLayouts/slideLayout3.xml +1 -0
- data/lib/pptx_markdown/template/ppt/slideLayouts/slideLayout4.xml +1 -0
- data/lib/pptx_markdown/template/ppt/slideLayouts/slideLayout5.xml +1 -0
- data/lib/pptx_markdown/template/ppt/slideLayouts/slideLayout6.xml +1 -0
- data/lib/pptx_markdown/template/ppt/slideLayouts/slideLayout7.xml +1 -0
- data/lib/pptx_markdown/template/ppt/slideLayouts/slideLayout8.xml +1 -0
- data/lib/pptx_markdown/template/ppt/slideLayouts/slideLayout9.xml +1 -0
- data/lib/pptx_markdown/template/ppt/slideMasters/_rels/slideMaster1.xml.rels +1 -0
- data/lib/pptx_markdown/template/ppt/slideMasters/slideMaster1.xml +1 -0
- data/lib/pptx_markdown/template/ppt/theme/theme1.xml +1 -0
- data/lib/pptx_markdown/template/ppt/theme/theme2.xml +1 -0
- data/lib/pptx_markdown/version.rb +3 -0
- metadata +186 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6dec89e0ab73f1f5b32935285f21f684543ddeaf
|
4
|
+
data.tar.gz: 30ab817dd3ec3e7ac9be19c6b72059260809cddc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5c8d935369edc0582e132d12a39fe9efda163f7447bee0f7c5d2ef77b81450b66c655c69efee7c808827484e3e7a59465747fc46a350472f448fa3d94a6cb025
|
7
|
+
data.tar.gz: ded0aa71db5c1e4c22144a49915f0e488c12e24938a7760461d4fa1a867730867243b709e83432a367e4ec1a4670cbacecb1381882072c36e79d28d7ebb16ef8
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# PPTXMarkdown
|
2
|
+
|
3
|
+
## Getting Started
|
4
|
+
|
5
|
+
### to_markdown
|
6
|
+
|
7
|
+
Converts .pptx presentation to markdown.
|
8
|
+
|
9
|
+
Example:
|
10
|
+
|
11
|
+
```shell
|
12
|
+
pptx_markdown to_markdown path/to/markdown.md path/to/presentation.pptx
|
13
|
+
```
|
14
|
+
|
15
|
+
### to_pptx
|
16
|
+
|
17
|
+
Converts markdown document to .pptx presentation.
|
18
|
+
|
19
|
+
Example:
|
20
|
+
|
21
|
+
```shell
|
22
|
+
pptx_markdown to_pptx path/to/presentation.pptx path/to/markdown.md
|
23
|
+
```
|
24
|
+
|
25
|
+
### clean
|
26
|
+
|
27
|
+
Removes everything but text shapes from presentation.
|
28
|
+
|
29
|
+
Example:
|
30
|
+
|
31
|
+
```shell
|
32
|
+
pptx_markdown clean path/to/presentation.pptx path/to/clean_presentation.pptx
|
33
|
+
```
|
34
|
+
|
35
|
+
## License
|
36
|
+
|
37
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/bin/pptx_markdown
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require_relative '../lib/pptx_markdown.rb'
|
5
|
+
|
6
|
+
module PPTXMarkdown
|
7
|
+
class Executable < Thor
|
8
|
+
desc 'to_markdown', 'Convert .pptx to markdown'
|
9
|
+
def to_markdown(input_path, output_path)
|
10
|
+
presentation = PPTXMarkdown::Parsers::PPTX.new(input_path).call
|
11
|
+
PPTXMarkdown::Builders::Markdown.new(presentation, output_path).call
|
12
|
+
|
13
|
+
finish
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'to_pptx', 'Convert markdown to .pptx'
|
17
|
+
def to_pptx(input_path, output_path)
|
18
|
+
presentation = PPTXMarkdown::Parsers::Markdown.new(input_path).call
|
19
|
+
PPTXMarkdown::Builders::PPTX.new(presentation, output_path).call
|
20
|
+
|
21
|
+
finish
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'clean', 'Remove everything but text from .pptx'
|
25
|
+
def clean(input_path, output_path)
|
26
|
+
presentation = PPTXMarkdown::Parsers::PPTX.new(input_path).call
|
27
|
+
PPTXMarkdown::Builders::PPTX.new(presentation, output_path).call
|
28
|
+
|
29
|
+
finish
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def finish
|
35
|
+
puts 'Finished.'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
PPTXMarkdown::Executable.start
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'zip/filesystem'
|
3
|
+
|
4
|
+
require_relative 'pptx_markdown/builders/markdown'
|
5
|
+
require_relative 'pptx_markdown/builders/pptx'
|
6
|
+
require_relative 'pptx_markdown/parsers/pptx'
|
7
|
+
require_relative 'pptx_markdown/parsers/markdown'
|
8
|
+
require_relative 'pptx_markdown/presentation'
|
9
|
+
require_relative 'pptx_markdown/slide'
|
10
|
+
require_relative 'pptx_markdown/shape'
|
11
|
+
require_relative 'pptx_markdown/shape_mapper'
|
12
|
+
|
13
|
+
module PPTXMarkdown
|
14
|
+
XML_NAMESPACES = {
|
15
|
+
'xmlns:a' => 'http://schemas.openxmlformats.org/drawingml/2006/main',
|
16
|
+
'xmlns:r' => 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
|
17
|
+
'xmlns:mc' => 'http://schemas.openxmlformats.org/markup-compatibility/2006',
|
18
|
+
'xmlns:mv' => 'urn:schemas-microsoft-com:mac:vml',
|
19
|
+
'xmlns:p' => 'http://schemas.openxmlformats.org/presentationml/2006/main',
|
20
|
+
'xmlns:c' => 'http://schemas.openxmlformats.org/drawingml/2006/chart',
|
21
|
+
'xmlns:dgm' => 'http://schemas.openxmlformats.org/drawingml/2006/diagram',
|
22
|
+
'xmlns:o' => 'urn:schemas-microsoft-com:office:office',
|
23
|
+
'xmlns:v' => 'urn:schemas-microsoft-com:vml',
|
24
|
+
'xmlns:pvml' => 'urn:schemas-microsoft-com:office:powerpoint',
|
25
|
+
'xmlns:com' => 'http://schemas.openxmlformats.org/drawingml/2006/compatibility',
|
26
|
+
'xmlns:p14' => 'http://schemas.microsoft.com/office/powerpoint/2010/main'
|
27
|
+
}.freeze
|
28
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'tmpdir'
|
2
|
+
|
3
|
+
module PPTXMarkdown
|
4
|
+
module Builders
|
5
|
+
PPTX = Struct.new(:presentation, :output_path) do
|
6
|
+
def call
|
7
|
+
Dir.mktmpdir do |tmp_path|
|
8
|
+
FileUtils.copy_entry template_path, tmp_path
|
9
|
+
|
10
|
+
generate_slides(tmp_path)
|
11
|
+
generate_presentation(tmp_path)
|
12
|
+
generate_presentation_rels(tmp_path)
|
13
|
+
|
14
|
+
create_pptx(tmp_path)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def create_pptx(dir)
|
21
|
+
Zip::File.open(output_path, Zip::File::CREATE) do |pptx_file|
|
22
|
+
Dir.glob("#{dir}/**/*", ::File::FNM_DOTMATCH).each do |path|
|
23
|
+
pptx_path = path.gsub("#{dir}/", '')
|
24
|
+
|
25
|
+
next if pptx_path == '.' || pptx_path == '..'
|
26
|
+
|
27
|
+
begin
|
28
|
+
pptx_file.add(pptx_path, path)
|
29
|
+
rescue Zip::EntryExistsError
|
30
|
+
puts 'File already exists.'
|
31
|
+
break
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def generate_slides(tmp_path)
|
38
|
+
presentation.slides.each_with_index do |slide, index|
|
39
|
+
File.open(slide_path(tmp_path, index), 'w') do |f|
|
40
|
+
f.write(slide.to_xml(index))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def generate_presentation(tmp_path)
|
46
|
+
File.open(File.join(tmp_path, 'ppt/presentation.xml'), 'w') do |f|
|
47
|
+
f.write(presentation.to_xml)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def generate_presentation_rels(tmp_path)
|
52
|
+
File.open(File.join(tmp_path, 'ppt/_rels/presentation.xml.rels'), 'w') do |f|
|
53
|
+
f.write(presentation.to_xml_rels)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def slide_path(tmp_path, index)
|
58
|
+
File.join(tmp_path, 'ppt/slides', "slide#{index + 1}.xml")
|
59
|
+
end
|
60
|
+
|
61
|
+
def template_path
|
62
|
+
File.join(File.expand_path(File.dirname(__FILE__)), '../template')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module PPTXMarkdown
|
2
|
+
module Parsers
|
3
|
+
Markdown = Struct.new(:path) do
|
4
|
+
def call
|
5
|
+
presentation = PPTXMarkdown::Presentation.new
|
6
|
+
|
7
|
+
content.each_line do |line|
|
8
|
+
if !line.start_with?("\t")
|
9
|
+
presentation.slides.push(
|
10
|
+
PPTXMarkdown::Slide.new([
|
11
|
+
PPTXMarkdown::Shape.new(parse_content(line), 'title')
|
12
|
+
])
|
13
|
+
)
|
14
|
+
|
15
|
+
next
|
16
|
+
end
|
17
|
+
|
18
|
+
presentation.slides.last.shapes.push(
|
19
|
+
PPTXMarkdown::Shape.new(parse_content(line), 'body')
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
presentation
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def parse_content(line)
|
29
|
+
line.scan(/[\t]*\*\s(.+)/)&.first&.first
|
30
|
+
end
|
31
|
+
|
32
|
+
def content
|
33
|
+
File.open(path).read
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module PPTXMarkdown
|
2
|
+
module Parsers
|
3
|
+
PPTX = Struct.new(:path) do
|
4
|
+
CONTENT_PATH = 'p:txBody/a:p/a:r/a:t'.freeze
|
5
|
+
TYPE_PATH = 'p:nvSpPr/p:nvPr/p:ph'.freeze
|
6
|
+
|
7
|
+
def document
|
8
|
+
@document ||= Zip::File.open(path)
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
PPTXMarkdown::Presentation.new(slides)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def slides
|
18
|
+
document.select { |f| f.name =~ %r{^ppt/slides/.+.xml$} }
|
19
|
+
.map do |f|
|
20
|
+
PPTXMarkdown::Slide.new(
|
21
|
+
fetch_shapes(document.file.open(f.name))
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def fetch_shapes(slide)
|
27
|
+
xml = Nokogiri::XML::Document.parse(slide)
|
28
|
+
|
29
|
+
xml.xpath('//p:sp').map do |shape|
|
30
|
+
begin
|
31
|
+
PPTXMarkdown::Shape.new(
|
32
|
+
fetch_content(shape),
|
33
|
+
fetch_type(shape)
|
34
|
+
)
|
35
|
+
rescue PPTXMarkdown::TypeError
|
36
|
+
next
|
37
|
+
end
|
38
|
+
end.compact
|
39
|
+
end
|
40
|
+
|
41
|
+
def fetch_content(shape)
|
42
|
+
shape.xpath(CONTENT_PATH).text
|
43
|
+
end
|
44
|
+
|
45
|
+
def fetch_type(shape)
|
46
|
+
return if shape.xpath(TYPE_PATH)[0].nil?
|
47
|
+
|
48
|
+
shape.xpath(TYPE_PATH)[0]['type']
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module PPTXMarkdown
|
2
|
+
Presentation = Struct.new(:slides) do
|
3
|
+
def initialize(*)
|
4
|
+
super
|
5
|
+
self.slides ||= []
|
6
|
+
end
|
7
|
+
|
8
|
+
def to_markdown
|
9
|
+
slides.map(&:to_markdown).join
|
10
|
+
end
|
11
|
+
|
12
|
+
# @return [String] XML for ppt/presentation.xml
|
13
|
+
def to_xml
|
14
|
+
Nokogiri::XML::Builder.new do |xml|
|
15
|
+
xml['p'].presentation(XML_NAMESPACES) do
|
16
|
+
xml.sldMasterIdLst do
|
17
|
+
xml.sldMasterId(id: 2_147_483_648, 'r:id' => 'rId1')
|
18
|
+
end
|
19
|
+
xml.sldIdLst do
|
20
|
+
slides.each_with_index do |_, index|
|
21
|
+
xml.sldId(
|
22
|
+
id: 255 + (index + 1),
|
23
|
+
'r:id' => "rId#{(index + 1) + 5}"
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
xml.sldSz(cx: 9_144_000, cy: 6_858_000, type: 'screen4x3')
|
28
|
+
xml.notesSz(cx: 6_858_000, cy: 9_144_000)
|
29
|
+
end
|
30
|
+
end.to_xml
|
31
|
+
end
|
32
|
+
|
33
|
+
# @return [String] XML for ppt/_rels/presentation.xml.rels
|
34
|
+
def to_xml_rels
|
35
|
+
Nokogiri::XML::Builder.new do |xml|
|
36
|
+
xml.Relationships(xmlns: 'http://schemas.openxmlformats.org/package/2006/relationships') do
|
37
|
+
xml.Relationship(
|
38
|
+
'Id' => 'rId1',
|
39
|
+
'Type' => 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme',
|
40
|
+
'Target' => 'theme/theme1.xml'
|
41
|
+
)
|
42
|
+
xml.Relationship(
|
43
|
+
'Id' => 'rId2',
|
44
|
+
'Type' => 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/presProps',
|
45
|
+
'Target' => 'presProps.xml'
|
46
|
+
)
|
47
|
+
xml.Relationship(
|
48
|
+
'Id' => 'rId3',
|
49
|
+
'Type' => 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster',
|
50
|
+
'Target' => 'slideMasters/slideMaster1.xml'
|
51
|
+
)
|
52
|
+
xml.Relationship(
|
53
|
+
'Id' => 'rId4',
|
54
|
+
'Type' => 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster',
|
55
|
+
'Target' => 'notesMasters/notesMaster1.xml'
|
56
|
+
)
|
57
|
+
slides.each_with_index do |_, index|
|
58
|
+
xml.Relationship(
|
59
|
+
'Id' => "rId#{5 + index + 1}",
|
60
|
+
'Type' => 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide',
|
61
|
+
'Target' => "slides/slide#{index + 1}.xml"
|
62
|
+
)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end.to_xml
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module PPTXMarkdown
|
2
|
+
class TypeError < StandardError
|
3
|
+
end
|
4
|
+
|
5
|
+
Shape = Struct.new(:content, :type) do
|
6
|
+
TITLE_IDS = %w(ctrTitle title).freeze
|
7
|
+
BODY_IDS = %w(subTitle body).freeze
|
8
|
+
|
9
|
+
def initialize(*)
|
10
|
+
super
|
11
|
+
|
12
|
+
raise PPTXMarkdown::TypeError unless (TITLE_IDS + BODY_IDS).include?(type)
|
13
|
+
end
|
14
|
+
|
15
|
+
# @return [Boolean]
|
16
|
+
def title?
|
17
|
+
TITLE_IDS.include?(type)
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [Boolean]
|
21
|
+
def body?
|
22
|
+
BODY_IDS.include?(type)
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_markdown
|
26
|
+
tag = title? ? '* ' : "\t* "
|
27
|
+
format("%s%s\n", tag, content)
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [String] XML for text shape for ppt/slides/slide0.xml
|
31
|
+
def to_xml(node)
|
32
|
+
Nokogiri::XML::Builder.new do |xml|
|
33
|
+
xml.sp(XML_NAMESPACES) do
|
34
|
+
xml.nvSpPr do
|
35
|
+
xml.cNvPr(id: '', name: '')
|
36
|
+
xml.cNvSpPr(txBox: 1)
|
37
|
+
xml.nvPr do
|
38
|
+
xml.ph(idx: nil, type: type)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
xml.spPr do
|
42
|
+
xml['a'].xfrm do
|
43
|
+
xml.off(x: node.x, y: node.y)
|
44
|
+
xml.ext(cx: node.cx, cy: node.cy)
|
45
|
+
end
|
46
|
+
xml['a'].prstGeom(prst: 'rect') do
|
47
|
+
xml.avLst
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
xml.txBody do
|
52
|
+
xml['a'].bodyPr(anchorCtr: 0, anchor: 't', bIns: 0, lIns: 0, rIns: 0, tIns: 0) do
|
53
|
+
xml.noAutofit
|
54
|
+
end
|
55
|
+
xml['a'].lstStyle
|
56
|
+
xml['a'].p do
|
57
|
+
xml.pPr(lvl: 0) do
|
58
|
+
xml.spcBef do
|
59
|
+
xml.spcPts(val: 0)
|
60
|
+
end
|
61
|
+
xml.buNone
|
62
|
+
end
|
63
|
+
xml.r do
|
64
|
+
xml.t(content)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end.doc.root.to_xml
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module PPTXMarkdown
|
4
|
+
class ShapeMapper
|
5
|
+
# 1pt to English Metric Units
|
6
|
+
EMU = 12_700
|
7
|
+
|
8
|
+
# Space between shapes
|
9
|
+
MARGIN = 25
|
10
|
+
|
11
|
+
# Shape height
|
12
|
+
Y_SIZE = 30
|
13
|
+
|
14
|
+
# Shape width
|
15
|
+
X_SIZE = 670
|
16
|
+
|
17
|
+
def next
|
18
|
+
factor = collection.next
|
19
|
+
|
20
|
+
OpenStruct.new(
|
21
|
+
{
|
22
|
+
x: MARGIN,
|
23
|
+
y: (MARGIN + Y_SIZE) * factor + MARGIN,
|
24
|
+
cx: X_SIZE,
|
25
|
+
cy: (MARGIN * 2) + (Y_SIZE * 2)
|
26
|
+
}.map { |k, v| [k, v * EMU] }.to_h
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def collection
|
33
|
+
@collection ||= (1..Float::INFINITY).to_enum
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module PPTXMarkdown
|
2
|
+
Slide = Struct.new(:shapes) do
|
3
|
+
def to_markdown
|
4
|
+
shapes.map(&:to_markdown).join
|
5
|
+
end
|
6
|
+
|
7
|
+
# @return [String] XML ppt/slides/slide0.xml with nested shapes
|
8
|
+
def to_xml(index)
|
9
|
+
node_collection = PPTXMarkdown::ShapeMapper.new
|
10
|
+
|
11
|
+
Nokogiri::XML::Builder.new do |xml|
|
12
|
+
xml['p'].sld(XML_NAMESPACES) do
|
13
|
+
xml.cSld do
|
14
|
+
xml.spTree do
|
15
|
+
xml.nvGrpSpPr do
|
16
|
+
xml.cNvPr(id: 255 + index + 1, name: nil)
|
17
|
+
xml.cNvGrpSpPr
|
18
|
+
xml.nvPr
|
19
|
+
end
|
20
|
+
xml.grpSpPr do
|
21
|
+
xml['a'].xfrm do
|
22
|
+
xml.off(x: 0, y: 0)
|
23
|
+
xml.ext(cx: 0, cy: 0)
|
24
|
+
xml.chOff(x: 0, y: 0)
|
25
|
+
xml.chExt(cx: 0, cy: 0)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
shapes.each do |shape|
|
29
|
+
xml << shape.to_xml(node_collection.next)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
xml.clrMapOvr do
|
34
|
+
xml['a'].masterClrMapping
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end.to_xml
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
metadata
ADDED
@@ -0,0 +1,186 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pptx_markdown
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sergey Novikov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.6.8
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.6.8
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubyzip
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.2.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.2.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.19.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.19.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: yard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: awesome_print
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- novikov359@gmail.com
|
114
|
+
executables:
|
115
|
+
- pptx_markdown
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- README.md
|
120
|
+
- bin/pptx_markdown
|
121
|
+
- lib/pptx_markdown.rb
|
122
|
+
- lib/pptx_markdown/builders/markdown.rb
|
123
|
+
- lib/pptx_markdown/builders/pptx.rb
|
124
|
+
- lib/pptx_markdown/parsers/markdown.rb
|
125
|
+
- lib/pptx_markdown/parsers/pptx.rb
|
126
|
+
- lib/pptx_markdown/presentation.rb
|
127
|
+
- lib/pptx_markdown/shape.rb
|
128
|
+
- lib/pptx_markdown/shape_mapper.rb
|
129
|
+
- lib/pptx_markdown/slide.rb
|
130
|
+
- lib/pptx_markdown/template/[Content_Types].xml
|
131
|
+
- lib/pptx_markdown/template/ppt/notesMasters/_rels/notesMaster1.xml.rels
|
132
|
+
- lib/pptx_markdown/template/ppt/notesMasters/notesMaster1.xml
|
133
|
+
- lib/pptx_markdown/template/ppt/presProps.xml
|
134
|
+
- lib/pptx_markdown/template/ppt/slideLayouts/_rels/slideLayout1.xml.rels
|
135
|
+
- lib/pptx_markdown/template/ppt/slideLayouts/_rels/slideLayout10.xml.rels
|
136
|
+
- lib/pptx_markdown/template/ppt/slideLayouts/_rels/slideLayout11.xml.rels
|
137
|
+
- lib/pptx_markdown/template/ppt/slideLayouts/_rels/slideLayout2.xml.rels
|
138
|
+
- lib/pptx_markdown/template/ppt/slideLayouts/_rels/slideLayout3.xml.rels
|
139
|
+
- lib/pptx_markdown/template/ppt/slideLayouts/_rels/slideLayout4.xml.rels
|
140
|
+
- lib/pptx_markdown/template/ppt/slideLayouts/_rels/slideLayout5.xml.rels
|
141
|
+
- lib/pptx_markdown/template/ppt/slideLayouts/_rels/slideLayout6.xml.rels
|
142
|
+
- lib/pptx_markdown/template/ppt/slideLayouts/_rels/slideLayout7.xml.rels
|
143
|
+
- lib/pptx_markdown/template/ppt/slideLayouts/_rels/slideLayout8.xml.rels
|
144
|
+
- lib/pptx_markdown/template/ppt/slideLayouts/_rels/slideLayout9.xml.rels
|
145
|
+
- lib/pptx_markdown/template/ppt/slideLayouts/slideLayout1.xml
|
146
|
+
- lib/pptx_markdown/template/ppt/slideLayouts/slideLayout10.xml
|
147
|
+
- lib/pptx_markdown/template/ppt/slideLayouts/slideLayout11.xml
|
148
|
+
- lib/pptx_markdown/template/ppt/slideLayouts/slideLayout2.xml
|
149
|
+
- lib/pptx_markdown/template/ppt/slideLayouts/slideLayout3.xml
|
150
|
+
- lib/pptx_markdown/template/ppt/slideLayouts/slideLayout4.xml
|
151
|
+
- lib/pptx_markdown/template/ppt/slideLayouts/slideLayout5.xml
|
152
|
+
- lib/pptx_markdown/template/ppt/slideLayouts/slideLayout6.xml
|
153
|
+
- lib/pptx_markdown/template/ppt/slideLayouts/slideLayout7.xml
|
154
|
+
- lib/pptx_markdown/template/ppt/slideLayouts/slideLayout8.xml
|
155
|
+
- lib/pptx_markdown/template/ppt/slideLayouts/slideLayout9.xml
|
156
|
+
- lib/pptx_markdown/template/ppt/slideMasters/_rels/slideMaster1.xml.rels
|
157
|
+
- lib/pptx_markdown/template/ppt/slideMasters/slideMaster1.xml
|
158
|
+
- lib/pptx_markdown/template/ppt/theme/theme1.xml
|
159
|
+
- lib/pptx_markdown/template/ppt/theme/theme2.xml
|
160
|
+
- lib/pptx_markdown/version.rb
|
161
|
+
homepage: https://github.com/droptheplot/pptx_markdown
|
162
|
+
licenses:
|
163
|
+
- MIT
|
164
|
+
metadata: {}
|
165
|
+
post_install_message:
|
166
|
+
rdoc_options: []
|
167
|
+
require_paths:
|
168
|
+
- lib
|
169
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - ">="
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
requirements: []
|
180
|
+
rubyforge_project:
|
181
|
+
rubygems_version: 2.6.4
|
182
|
+
signing_key:
|
183
|
+
specification_version: 4
|
184
|
+
summary: PPTX <-> Markdown
|
185
|
+
test_files: []
|
186
|
+
has_rdoc:
|