code2pdf 0.4.2 → 0.4.3
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 +4 -4
- data/Gemfile.lock +4 -4
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/bin/code2pdf +1 -1
- data/lib/code2pdf/convert_to_pdf.rb +8 -4
- data/lib/code2pdf/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 578c0a73b26a2556547e1067a953e17e7749862ed484fff98a3e39682baab574
|
4
|
+
data.tar.gz: ff876deb0d621c9dea99aa94e65a8ff1875401a9163b3884731d8515933dbc8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27773342081e8622445535edeb161fca71f12f2ae88f10d11303a725c1a050186acc603ae06d5a403bad894603afa83ee2e23f0f0a7057bfd11d43b769d6fbe0
|
7
|
+
data.tar.gz: e15c871714be8a33f41675e273da1ec39c85a6437164479a3acfcceede45e049c68769cf9d1c95663aa58201c541a21302f34cc6a0c37d2b61ae7ca34469a35e
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
code2pdf (0.4.
|
4
|
+
code2pdf (0.4.3)
|
5
5
|
pdfkit
|
6
6
|
rouge
|
7
7
|
wkhtmltopdf-binary
|
@@ -28,7 +28,7 @@ GEM
|
|
28
28
|
coderay (~> 1.1.0)
|
29
29
|
method_source (~> 0.9.0)
|
30
30
|
rake (12.3.0)
|
31
|
-
rouge (3.
|
31
|
+
rouge (3.3.0)
|
32
32
|
rspec (3.7.0)
|
33
33
|
rspec-core (~> 3.7.0)
|
34
34
|
rspec-expectations (~> 3.7.0)
|
@@ -44,7 +44,7 @@ GEM
|
|
44
44
|
rspec-support (3.7.0)
|
45
45
|
ruby-rc4 (0.1.5)
|
46
46
|
ttfunk (1.5.1)
|
47
|
-
wkhtmltopdf-binary (0.12.
|
47
|
+
wkhtmltopdf-binary (0.12.4)
|
48
48
|
|
49
49
|
PLATFORMS
|
50
50
|
ruby
|
@@ -58,4 +58,4 @@ DEPENDENCIES
|
|
58
58
|
rspec
|
59
59
|
|
60
60
|
BUNDLED WITH
|
61
|
-
1.
|
61
|
+
1.17.1
|
data/LICENSE
CHANGED
data/README.md
CHANGED
data/bin/code2pdf
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
require 'shellwords'
|
3
|
+
|
1
4
|
class ConvertToPDF
|
2
5
|
PDF_OPTIONS = {
|
3
6
|
page_size: 'A4'
|
@@ -45,12 +48,13 @@ class ConvertToPDF
|
|
45
48
|
def syntax_highlight(file)
|
46
49
|
file_type = File.extname(file.first)[1..-1]
|
47
50
|
file_lexer = Rouge::Lexer.find(file_type)
|
48
|
-
return file.last unless file_lexer
|
51
|
+
return CGI.escapeHTML(file.last) unless file_lexer
|
49
52
|
|
50
53
|
theme = Rouge::Themes::Base16.mode(:light)
|
51
54
|
formatter = Rouge::Formatters::HTMLInline.new(theme)
|
52
55
|
formatter = Rouge::Formatters::HTMLTable.new(formatter, start_line: 1)
|
53
|
-
|
56
|
+
code_data = file.last.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
|
57
|
+
formatter.format(file_lexer.lex(code_data))
|
54
58
|
end
|
55
59
|
|
56
60
|
def invalid_blacklist?
|
@@ -101,8 +105,8 @@ class ConvertToPDF
|
|
101
105
|
|
102
106
|
content = ''
|
103
107
|
File.open(file, 'r') do |f|
|
104
|
-
if `file #{file}` !~ /text/
|
105
|
-
content <<
|
108
|
+
if `file #{file.shellescape}` !~ /text/
|
109
|
+
content << '[binary]'
|
106
110
|
else
|
107
111
|
f.each_line { |line_content| content << line_content }
|
108
112
|
end
|
data/lib/code2pdf/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code2pdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Caton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pdfkit
|
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
182
|
version: '0'
|
183
183
|
requirements: []
|
184
184
|
rubyforge_project:
|
185
|
-
rubygems_version: 2.7.
|
185
|
+
rubygems_version: 2.7.7
|
186
186
|
signing_key:
|
187
187
|
specification_version: 4
|
188
188
|
summary: Convert your source code to PDF
|