diff --git a/Gemfile.lock b/Gemfile.lock index 7639e61..2f6d4af 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,42 +9,42 @@ PATH GEM remote: http://rubygems.org/ specs: - Ascii85 (1.0.2) + Ascii85 (1.1.0) afm (0.2.2) - coderay (1.1.2) - diff-lcs (1.3) + coderay (1.1.3) + diff-lcs (1.5.0) hashery (2.1.2) - method_source (0.9.0) + method_source (1.0.0) pdf-inspector (1.3.0) pdf-reader (>= 1.0, < 3.0.a) - pdf-reader (2.0.0) - Ascii85 (~> 1.0.0) + pdf-reader (2.10.0) + Ascii85 (~> 1.0) afm (~> 0.2.1) hashery (~> 2.0) ruby-rc4 ttfunk - pdfkit (0.8.2) - pry (0.11.3) - coderay (~> 1.1.0) - method_source (~> 0.9.0) - rake (12.3.3) - rouge (3.3.0) - rspec (3.7.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) + pdfkit (0.8.6) + pry (0.14.1) + coderay (~> 1.1) + method_source (~> 1.0) + rake (13.0.6) + rouge (3.29.0) + rspec (3.11.0) + rspec-core (~> 3.11.0) + rspec-expectations (~> 3.11.0) + rspec-mocks (~> 3.11.0) + rspec-core (3.11.0) + rspec-support (~> 3.11.0) + rspec-expectations (3.11.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-mocks (3.7.0) + rspec-support (~> 3.11.0) + rspec-mocks (3.11.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.0) + rspec-support (~> 3.11.0) + rspec-support (3.11.0) ruby-rc4 (0.1.5) - ttfunk (1.5.1) - wkhtmltopdf-binary (0.12.4) + ttfunk (1.7.0) + wkhtmltopdf-binary (0.12.6.5) PLATFORMS ruby @@ -58,4 +58,4 @@ DEPENDENCIES rspec BUNDLED WITH - 1.17.1 + 2.3.16 diff --git a/lib/code2pdf/convert_to_pdf.rb b/lib/code2pdf/convert_to_pdf.rb index 6885bcc..e8d9697 100644 --- a/lib/code2pdf/convert_to_pdf.rb +++ b/lib/code2pdf/convert_to_pdf.rb @@ -46,8 +46,8 @@ def pdf end def syntax_highlight(file) - file_type = File.extname(file.first)[1..-1] - file_lexer = Rouge::Lexer.find(file_type) + file_name = File.basename(file.first) + file_lexer = Rouge::Lexer.guess_by_filename(file_name) return CGI.escapeHTML(file.last) unless file_lexer theme = Rouge::Themes::Base16.mode(:light) diff --git a/spec/fixtures/hello_world/lib/sample.kt b/spec/fixtures/hello_world/lib/sample.kt new file mode 100644 index 0000000..b0a1cbd --- /dev/null +++ b/spec/fixtures/hello_world/lib/sample.kt @@ -0,0 +1,8 @@ +/** + * Some javadoc + */ +class Example { + fun sum(): Int { + return 2 + 2 + } +} diff --git a/spec/fixtures/hello_world_original.pdf b/spec/fixtures/hello_world_original.pdf index 867e913..b8e3db5 100644 Binary files a/spec/fixtures/hello_world_original.pdf and b/spec/fixtures/hello_world_original.pdf differ