Enable inline PHP syntax highlighting

Pygments has a "startinline" option which is only relevant for the PhpLexer. It allows syntax highlighting without the opening <?php tag. I believe this option is ignored for every other lexer.

Could you either set this to true by default using the proposed change? Or could this be exposed as a setting somewhere in _config.yml? I can't think of a reason someone would not want this enabled.
This commit is contained in:
Joel Clermont 2013-03-22 22:57:55 -03:00
parent 75cc24c8d6
commit 1a1c8681a4
1 changed files with 2 additions and 2 deletions

View File

@ -22,14 +22,14 @@ module HighlightCode
highlighted_code = File.read(path)
else
begin
highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html', :options => {:encoding => 'utf-8'})
highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html', :options => {:encoding => 'utf-8', :startinline => true})
rescue MentosError
raise "Pygments can't parse unknown language: #{lang}."
end
File.open(path, 'w') {|f| f.print(highlighted_code) }
end
else
highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html', :options => {:encoding => 'utf-8'})
highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html', :options => {:encoding => 'utf-8', :startinline => true})
end
highlighted_code
end