-
-
Notifications
You must be signed in to change notification settings - Fork 382
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
Ensure <pre> nodes are not removed after syntax highlighting #295
Conversation
After upgrading to rouge, I noticed the syntax highlighting in `octodown` has disappeared. It seems that the `pre` tags were being removed, which are neccesary for correct highlighting with rouge. This commit fixes this by replacing the `inner_html` of the preblock with the code highlighted by rouge.
@@ -10,7 +10,7 @@ group :development do | |||
end | |||
|
|||
group :test do | |||
gem 'commonmarker', '~> 0.14', require: false | |||
gem 'commonmarker', '~> 0.16', require: false |
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.
Bumped because :GITHUB_PRE_LANG
was not introduced until 0.16.1
@@ -9,6 +9,7 @@ Rake::TestTask.new do |t| | |||
t.libs << 'test' | |||
t.test_files = FileList['test/**/*_test.rb'] | |||
t.verbose = true | |||
t.warning = false |
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.
Rouge is spitting out a ton of warnings which made the test output a bit annoying, so I added this flag.
klass = node['class'] | ||
klass = [klass, "highlight-#{lang}"].compact.join ' ' | ||
scope = context[:scope] || "highlight-#{lang}" |
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.
I would like to be able to scope my css, so I added this option.
For more info, https://github.com/jneen/rouge#scope-highlight
Looks great! Thanks. |
After upgrading to rouge, I noticed the syntax highlighting in
octodown
hasdisappeared. It seems that the
pre
tags were being removed, which areneccesary for correct highlighting with rouge. This commit fixes this by
replacing the
inner_html
of the preblock with the code highlighted by rouge.