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
Support Minted for LaTeX Code Block Conversion #93
Comments
This could now be implemented as a generic syntax highlighter. And the LaTeX converter still needs to be adjusted to use the generic syntax highlighter implementation. |
I would like to try my hand at this, but I am not sure what would be the best way. Currently all converters in |
That would be great! No, there is currently no such provision. Providing a correct value to the syntax highlighter option is the job of the user. However, I toying around with the idea of introducing mime types for the parsers and converters. If this is done, it should be possible to set a preferred syntax highlighter for a mime type instead of a specific converter. So for the time being, this issue would just need a new syntax highlighter and the adaption of the LaTeX converter. |
I forked the repo and changed the LaTeX converter use the highlight_code function (like the html converter). But this way running The best fix I could come up with would be to add a optional constant Should I open up a pull request with this changes first? add_syntax_highlighter(kn_down) do |converter, text, lang, type, opts|
require "kramdown/converter/syntax_highlighter/#{kn_down}"
klass = ::Kramdown::Utils.deep_const_get("::Kramdown::Converter::SyntaxHighlighter::#{klass_name}")
converter_name = converter.class.name.split('::').last.to_sym # maybe use strings?
# Use || because SUPPORTED_CONVERTERS should be optional
supported = klass::SUPPORTED_CONVERTERS.nil? || klass::SUPPORTED_CONVERTERS.member?(converter_name)
if klass::AVAILABLE && supported
add_syntax_highlighter(kn_down, klass)
else
add_syntax_highlighter(kn_down) {|*args| nil}
end
syntax_highlighter(kn_down).call(converter, text, lang, type, opts)
end |
The problem with using a constant like Until such a facility is ready I think the best option would be to allow the LaTeX converter to optionally use exactly one specific syntax_highlighter, namely the one for minted. I.e. when |
Thanks for your contribution, the changes are now in master. |
[from Rubyforge]
It's excellent that Kramdown already supports a solid, separate package like Listings for formatting code blocks whenconverting to LaTeX. However, I'd like to request that Minted be supported as well.
Minted uses the Pygmentize library for its conversion, and was built in response to some of the shortcomings of Listings.Tools like Emacs' Org mode provide a configuration option when exporting to LaTeX to choose between exporting code blocks as Listing environments or Minted environments.
Thank you for an excellent open source project.
The text was updated successfully, but these errors were encountered: