pptx-visible-slide-text 0.1.0
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 +7 -0
- data/LICENSE +21 -0
- data/README.md +23 -0
- data/lib/pptx_visible_slide_text.rb +51 -0
- metadata +82 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 64ea3c38f17192c8d25ee3cc867b8d1129a14dd381352f91989c73aa3a5ac2c1
|
|
4
|
+
data.tar.gz: 3841bf84b95054461472247ae4a1c96810ce3369d83ea0c428dd411205f35716
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 5bdd7c8af4d0f8690807ddcb698edab1af4007a61aafd52136a526c0051dda0a295a19919dd010dcade3b010296106449a708bbc4b987d64ca363f801e802fc8
|
|
7
|
+
data.tar.gz: 2e27f3631da55f3b86c228ff88d3de912f025f9a85b4e50b375bd563ce237ca912e8f1cb90ca1d4fcc2d66e5087be7716a2ebaedd39d224e87d93d2da2012845
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 js-upup
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# PPTX Visible Slide Text
|
|
2
|
+
|
|
3
|
+
Enumerate slide text in deck order, even when slide filenames are out of order.
|
|
4
|
+
The reader follows presentation relationships and skips slides marked hidden.
|
|
5
|
+
It joins text runs into paragraphs, including text in table cells. Visible
|
|
6
|
+
slides without text are retained with `empty: true`. Positions use the
|
|
7
|
+
one-based slide index in the original deck, including gaps from hidden slides.
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
require "pptx_visible_slide_text"
|
|
11
|
+
PptxVisibleSlideText.each_slide("pitch.pptx") do |slide|
|
|
12
|
+
puts "Slide #{slide[:position]}: #{slide[:empty] ? '[no slide text]' : slide[:text]}"
|
|
13
|
+
end
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Use a local, unencrypted PPTX file. Text in images, speaker notes, embedded
|
|
17
|
+
documents and externally linked parts is outside the reader's scope. XML
|
|
18
|
+
parts are limited to 16 MiB each. Malformed files raise a parsing error.
|
|
19
|
+
|
|
20
|
+
If you are preparing a deck for [PPT to Video](https://imagetovideoai.tools/ppt-to-video),
|
|
21
|
+
this inventory helps you find image-only slides and check the order of the text
|
|
22
|
+
before uploading the deck. The workspace uses slide text to generate new video
|
|
23
|
+
visuals; the Ruby library only reads the local presentation.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require "zip"
|
|
2
|
+
require "nokogiri"
|
|
3
|
+
require "pathname"
|
|
4
|
+
|
|
5
|
+
module PptxVisibleSlideText
|
|
6
|
+
XML_LIMIT = 16 * 1024 * 1024
|
|
7
|
+
PML = %w[http://schemas.openxmlformats.org/presentationml/2006/main http://purl.oclc.org/ooxml/presentationml/main].freeze
|
|
8
|
+
DRAWING = %w[http://schemas.openxmlformats.org/drawingml/2006/main http://purl.oclc.org/ooxml/drawingml/main].freeze
|
|
9
|
+
REL = %w[http://schemas.openxmlformats.org/officeDocument/2006/relationships http://purl.oclc.org/ooxml/officeDocument/relationships].freeze
|
|
10
|
+
|
|
11
|
+
def self.xml(archive, path)
|
|
12
|
+
entry = archive.find_entry(path)
|
|
13
|
+
raise ArgumentError, "Missing presentation part: #{path}" unless entry
|
|
14
|
+
raise ArgumentError, "XML part too large" if entry.size > XML_LIMIT
|
|
15
|
+
content = entry.get_input_stream { |stream| stream.read(XML_LIMIT + 1) } || ""
|
|
16
|
+
raise ArgumentError, "XML part too large" if content.bytesize > XML_LIMIT
|
|
17
|
+
doc = Nokogiri::XML(content) { |cfg| cfg.strict.nonet }
|
|
18
|
+
raise ArgumentError, "Unexpected document type declaration" if doc.internal_subset
|
|
19
|
+
doc
|
|
20
|
+
end
|
|
21
|
+
private_class_method :xml
|
|
22
|
+
|
|
23
|
+
# Yields one hash per visible slide in the presentation's playback order.
|
|
24
|
+
def self.each_slide(path)
|
|
25
|
+
return enum_for(__method__, path) unless block_given?
|
|
26
|
+
Zip::File.open(path) do |archive|
|
|
27
|
+
deck = xml(archive, "ppt/presentation.xml")
|
|
28
|
+
ns = deck.root.namespace&.href
|
|
29
|
+
raise ArgumentError, "Unsupported presentation XML" unless PML.include?(ns)
|
|
30
|
+
rels = xml(archive, "ppt/_rels/presentation.xml.rels")
|
|
31
|
+
slides = {}
|
|
32
|
+
rels.root.element_children.each do |rel|
|
|
33
|
+
next unless rel.name == "Relationship" && REL.any? { |base| rel["Type"] == base + "/slide" }
|
|
34
|
+
next if rel["TargetMode"] == "External"
|
|
35
|
+
part = Pathname.new("/ppt").join(rel["Target"]).cleanpath.to_s.delete_prefix("/")
|
|
36
|
+
slides[rel["Id"]] = part
|
|
37
|
+
end
|
|
38
|
+
deck.xpath("/p:presentation/p:sldIdLst/p:sldId", "p" => ns).each_with_index do |slot, i|
|
|
39
|
+
id = slot.attribute_nodes.find { |a| a.name == "id" && REL.include?(a.namespace&.href) }
|
|
40
|
+
slide = xml(archive, slides.fetch(id&.value))
|
|
41
|
+
next if %w[0 false off].include?(slide.root["show"])
|
|
42
|
+
drawing_ns = DRAWING.fetch(PML.index(ns))
|
|
43
|
+
paragraphs = slide.xpath("/p:sld/p:cSld/p:spTree//a:p", "p" => ns, "a" => drawing_ns).map do |paragraph|
|
|
44
|
+
paragraph.xpath(".//a:t|.//a:br", "a" => drawing_ns).map { |node| node.name == "br" ? "\n" : node.text }.join
|
|
45
|
+
end
|
|
46
|
+
text = paragraphs.join("\n").strip
|
|
47
|
+
yield({position: i + 1, text: text, empty: text.empty?})
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: pptx-visible-slide-text
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- js-upup
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-11-23 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rubyzip
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '2.4'
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '4'
|
|
23
|
+
type: :runtime
|
|
24
|
+
prerelease: false
|
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
+
requirements:
|
|
27
|
+
- - ">="
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '2.4'
|
|
30
|
+
- - "<"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '4'
|
|
33
|
+
- !ruby/object:Gem::Dependency
|
|
34
|
+
name: nokogiri
|
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '1.16'
|
|
40
|
+
type: :runtime
|
|
41
|
+
prerelease: false
|
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '1.16'
|
|
47
|
+
description: Enumerate PPTX slides, omit hidden slides, and flag visible slides without
|
|
48
|
+
text. When preparing a deck for https://imagetovideoai.tools/ppt-to-video the report
|
|
49
|
+
shows which slides supply readable source text.
|
|
50
|
+
email:
|
|
51
|
+
executables: []
|
|
52
|
+
extensions: []
|
|
53
|
+
extra_rdoc_files: []
|
|
54
|
+
files:
|
|
55
|
+
- LICENSE
|
|
56
|
+
- README.md
|
|
57
|
+
- lib/pptx_visible_slide_text.rb
|
|
58
|
+
homepage:
|
|
59
|
+
licenses:
|
|
60
|
+
- MIT
|
|
61
|
+
metadata:
|
|
62
|
+
documentation_uri: https://rubygems.org/gems/pptx-visible-slide-text
|
|
63
|
+
post_install_message:
|
|
64
|
+
rdoc_options: []
|
|
65
|
+
require_paths:
|
|
66
|
+
- lib
|
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
68
|
+
requirements:
|
|
69
|
+
- - ">="
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
71
|
+
version: '3.1'
|
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
|
+
requirements:
|
|
74
|
+
- - ">="
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: '0'
|
|
77
|
+
requirements: []
|
|
78
|
+
rubygems_version: 3.0.3.1
|
|
79
|
+
signing_key:
|
|
80
|
+
specification_version: 4
|
|
81
|
+
summary: Read visible PowerPoint slide text in presentation order.
|
|
82
|
+
test_files: []
|