Skip to content
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

Merged
merged 1 commit into from
May 4, 2018

Conversation

ianks
Copy link
Contributor

@ianks ianks commented May 4, 2018

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.

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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}"
Copy link
Contributor Author

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

@gjtorikian
Copy link
Owner

Looks great! Thanks.

@gjtorikian gjtorikian merged commit 76c9cfe into gjtorikian:master May 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants