kpumuk commented on code in PR #14:
URL: https://github.com/apache/thrift-website/pull/14#discussion_r3089515149


##########
_plugins/remote_snippets.rb:
##########
@@ -42,13 +42,14 @@ def render(context)
     end
     snippet_type = "snippet"
     if @type == "direct"
-      content = Kramdown::Document.new(content).to_html
+      content = context.registers[:site]
+        .find_converter_instance(Jekyll::Converters::Markdown)
+        .convert(content.to_s)
       snippet_type = "page"
     else
       content = content.force_encoding("utf-8")
-      formatter = Rouge::Formatters::HTMLLegacy.new
-      lexer = Rouge::Lexer.find_fancy(@type, content)
-      content = formatter.format(lexer.lex(content))
+      formatter = Jekyll::Tags::HighlightBlock.send(:new, "highlight", @type, 
Liquid::ParseContext.new)
+      content = formatter.send(:add_code_tag, formatter.send(:render_rouge, 
content))

Review Comment:
   This is not ideal, as I am reaching for private APIs twice (both `new` and 
`render_rouge` are private). Another option is to simply switch to 
`Rouge::Formatters::HTML.new`, but add the HTML tags around the result 
manually, like:
   
   ```ruby
   formatter = Rouge::Formatters::HTML.new
   lexer = Rouge::Lexer.find_fancy(@type, content)
   content = formatter.format(lexer.lex(content))
   
   content = "<figure class=\"highlight\"><pre><code 
class=\"language-#{@lang.to_s.tr("+", "-")}\" 
data-lang=\"#{@lang}\">#{content}</code></pre></figure>"
   ```
   
   The risk is that HTML layout might fall out of sync between this and 
Jekyll...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to