Open Goles opened 9 years ago
This is an issue that should be tracked on the Pygments issue tracker
@imathis Are you sure about this? I got pygments installed in my machine and made a test project,
from pygments import highlight
from pygments.lexers import SwiftLexer
from pygments.formatters import HtmlFormatter
code = 'var letterCounter = 0'
print highlight(code, :lexer => 'swift', :formatter => 'html', :options => {:encoding => 'utf-8', :startinline => true})
That outputted perfect HTML, I think that it could be related to the way that pygments is imported in pygments_code.rb, maybe it's outdated?
I even tried to run Pygments.get_lexer_by_name()
from pygments_code.rb
by adding a line like:
print Pygments.get_lexer_by_name("python")
and got the following error when performing a rake generate
/Users/a_user/Dropbox/Private/octopress/plugins/pygments_code.rb:19:in `pygments': undefined method `get_lexer_by_name' for Pygments:Module (NoMethodError)
Isn't this some kind of namespacing issue in the pygments_code
plug-in?
Man, I'm sorry. I somehow misread your comment as "I know Pygments doesn't support Swift". Thanks for your followup. I'll look into this.
@imathis no problem!!
Thanks, and let me know if I can be of further help :+1:
pygments.rb
0.6.0 has Swift support. You'll have to upgrade.
Maybe I have to update octopress... I tried modifying the Gemfile in my blog and changing the pygments line, it previously looked like this:
source "https://rubygems.org"
group :development do
gem 'rake', '~> 0.9'
gem 'jekyll', '~> 0.12'
gem 'rdiscount', '~> 2.0.7'
gem 'pygments.rb', '~> 0.3.4'
gem 'RedCloth', '~> 4.2.9'
gem 'haml', '~> 3.1.7'
gem 'compass', '~> 0.12.2'
gem 'sass', '~> 3.2'
gem 'sass-globbing', '~> 1.0.0'
gem 'rubypants', '~> 0.2.0'
gem 'rb-fsevent', '~> 0.9'
gem 'stringex', '~> 1.4.0'
gem 'liquid', '~> 2.3.0'
end
gem 'sinatra', '~> 1.4.2'
I changed the pygments line to
gem 'pygments.rb', '~> 0.6.0'
but got the following error when performing a bundle update pygments.rb
bundle update pygments.rb
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Bundler could not find compatible versions for gem "pygments.rb":
In Gemfile:
jekyll (~> 0.12) ruby depends on
pygments.rb (~> 0.3.2) ruby
pygments.rb (0.6.0)
Yeah, your octopress is old :( the latest master has a bunch of changes to the Gemfile and plugin fixes.
@parkr Is there a simple way to update Octopress?
Not for Octopress 2.0 :( i'd recommend copying the gemfile and _plugins directory and see where that gets you. Octopress 3 will be much easier to upgrade!
In case anyone runs into this error message but finds themselves on the latest All The Things: Verify your current Python is CPython. I got the "unknown language" error for all languages, and the resolution was to pyenv local system
(rather than my standard default of Pypy).
Hey there, I have a blogpost with a code block that looks like this gist, (because it's in markdown I couldn't embed it to the Issue text).
I know that Pygments does support Swift, and as far as I know, I'm using the most updated Pygments version... however when I try to rake generate my blog I get:
I tried fixing
pygments_code.rb
myself and actually forcing it to colorize Swift, with no luck... could anyone help me out here?