code_slide 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/code_slide/snippet.rb +27 -4
- data/lib/code_slide/themes/dark.yml +6 -0
- data/lib/code_slide/themes/light.yml +6 -0
- data/lib/code_slide/version.rb +1 -1
- metadata +10 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e099d9e095ef6fa4d522b8257e44830208e5d7a3301c7de528d2e096d3694cde
|
4
|
+
data.tar.gz: 4e301e8e48f951ae28052684dd1536d77251b4ccc3a1007ea75dbe1d0b8567e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2fb5727fc5b39321cdcef5d73361a32624fb1f6c7f95c9bcc7fafc8366980c7e15d46c8155f3518a59979da02f27f91b8960bbeb24d83a8f55498c12665bb35
|
7
|
+
data.tar.gz: b32f8c6a86d58987673aeaa2633cd9b55386fada8510a36c4b28c251a6b5fed4a7cfe7549ace727b9920e8098737fdc4a1ed570cd29514c344c155295db455a9
|
data/lib/code_slide/snippet.rb
CHANGED
@@ -4,19 +4,42 @@ require 'code_slide/png_formatter'
|
|
4
4
|
|
5
5
|
module CodeSlide
|
6
6
|
class Snippet
|
7
|
+
MARK_PREFIX = %r{^\s*(#|//)\s*}
|
8
|
+
START_MARK = /#{MARK_PREFIX}START:\s*/
|
9
|
+
END_MARK = /#{MARK_PREFIX}END:\s*/
|
10
|
+
|
7
11
|
def self.from_file(filename, options = {})
|
8
12
|
options = options.dup
|
9
13
|
|
10
|
-
|
11
|
-
|
14
|
+
lines = File.readlines(filename)
|
15
|
+
mark = options.delete(:mark)
|
16
|
+
|
17
|
+
if mark
|
18
|
+
start = lines.index { |line| line =~ /#{START_MARK}#{mark}\s*$/i }
|
19
|
+
finish = lines.index { |line| line =~ /#{END_MARK}#{mark}\s*$/i }
|
20
|
+
|
21
|
+
# if start is defined, don't include the comment itself
|
22
|
+
start += 2 if start
|
23
|
+
else
|
24
|
+
start = options.delete(:start)
|
25
|
+
finish = options.delete(:finish)
|
26
|
+
end
|
12
27
|
|
28
|
+
start ||= 1
|
29
|
+
finish ||= -1
|
13
30
|
line_start = options[:line_number_start] || start
|
14
31
|
|
15
32
|
# assume people number their file lines starting at 1
|
16
33
|
start -= 1 if start > 0
|
17
34
|
finish -= 1 if finish > 0
|
18
35
|
|
19
|
-
text =
|
36
|
+
text = lines[start..finish].join
|
37
|
+
|
38
|
+
if options.delete(:strip_indent)
|
39
|
+
indent = text[/^\s*/]
|
40
|
+
text.gsub!(/^#{indent}/m, "")
|
41
|
+
end
|
42
|
+
|
20
43
|
new(text,
|
21
44
|
options.merge(lang: options[:lang] || detect_language_type(filename),
|
22
45
|
line_number_start: line_start))
|
@@ -52,7 +75,7 @@ module CodeSlide
|
|
52
75
|
use_font(@font, bold: @bold,
|
53
76
|
italic: @italic,
|
54
77
|
bold_italic: @bold_italic).
|
55
|
-
build_pdf(options).
|
78
|
+
build_pdf(**options).
|
56
79
|
render_file(filename)
|
57
80
|
end
|
58
81
|
|
data/lib/code_slide/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code_slide
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamis Buck
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: prawn
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
19
|
+
version: '2.5'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2.
|
26
|
+
version: '2.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: coderay
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1.
|
47
|
+
version: '1.16'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1.
|
54
|
+
version: '1.16'
|
55
55
|
description: |2
|
56
56
|
A library for turning code snippets into slides. Automatically turn your
|
57
57
|
source code into syntax-highlighted PDFs and PNGs. Take the tedium out
|
@@ -77,7 +77,7 @@ homepage: https://github.com/jamis/code_slide
|
|
77
77
|
licenses:
|
78
78
|
- MIT
|
79
79
|
metadata: {}
|
80
|
-
post_install_message:
|
80
|
+
post_install_message:
|
81
81
|
rdoc_options: []
|
82
82
|
require_paths:
|
83
83
|
- lib
|
@@ -92,9 +92,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
|
-
|
96
|
-
|
97
|
-
signing_key:
|
95
|
+
rubygems_version: 3.4.19
|
96
|
+
signing_key:
|
98
97
|
specification_version: 4
|
99
98
|
summary: Generate PDF/PNG slides from source code
|
100
99
|
test_files: []
|