-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Receiving theme parameter to use the default or github #28
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ def initialize(params = {}) | |
elsif !params.key?(:to) || params[:to].nil? | ||
raise ArgumentError.new 'where should I save the generated pdf file?' | ||
else | ||
@from, @to, @except = params[:from], params[:to], params[:except].to_s | ||
@from, @to, @except, @themeName = params[:from], params[:to], params[:except].to_s, params[:theme] | ||
|
||
if File.exist?(@except) && invalid_blacklist? | ||
raise LoadError.new "#{@except} is not a valid blacklist YAML file" | ||
|
@@ -50,10 +50,16 @@ def syntax_highlight(file) | |
file_lexer = Rouge::Lexer.find(file_type) | ||
return CGI.escapeHTML(file.last) unless file_lexer | ||
|
||
theme = Rouge::Themes::Base16.mode(:light) | ||
if (@themeName == "github") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/ConditionalAssignment: Use the return of the conditional for variable assignment and comparison. |
||
theme = Rouge::Themes::Github.new() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style/MethodCallWithoutArgsParentheses: Do not use parentheses for method calls with no arguments. |
||
else | ||
theme = Rouge::Themes::Base16.mode(:light) | ||
end | ||
|
||
formatter = Rouge::Formatters::HTMLInline.new(theme) | ||
formatter = Rouge::Formatters::HTMLTable.new(formatter, start_line: 1) | ||
code_data = file.last.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '') | ||
puts "Processing file #{file.first}" | ||
formatter.format(file_lexer.lex(code_data)) | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/ParallelAssignment: Do not use parallel assignment.
Naming/VariableName: Use snake_case for variable names.
Metrics/LineLength: Line is too long. [104/80]