Skip to content

Commit 1a1c868

Browse files
committed
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.
1 parent 75cc24c commit 1a1c868

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

plugins/pygments_code.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ def pygments(code, lang)
2222
highlighted_code = File.read(path)
2323
else
2424
begin
25-
highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html', :options => {:encoding => 'utf-8'})
25+
highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html', :options => {:encoding => 'utf-8', :startinline => true})
2626
rescue MentosError
2727
raise "Pygments can't parse unknown language: #{lang}."
2828
end
2929
File.open(path, 'w') {|f| f.print(highlighted_code) }
3030
end
3131
else
32-
highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html', :options => {:encoding => 'utf-8'})
32+
highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html', :options => {:encoding => 'utf-8', :startinline => true})
3333
end
3434
highlighted_code
3535
end

0 commit comments

Comments
 (0)