Skip to content

Commit 150d493

Browse files
committed
[SPARK-28752][BUILD][DOCS][FOLLOW-UP] Render examples imported from Jekyll properly via Rouge
### What changes were proposed in this pull request? This PR proposes to use Pygment compatible format by Rouge. As of #26521, we use Rouge instead of Pygment wrapper in Ruby. Rouge claims Pygment compatibility; and we should output as Pygment does. ```ruby Rouge::Formatters::HTMLPygments.new(formatter) ``` wraps codes with `<div class="highlight"><pre>...` properly. ### Why are the changes needed? To keep the documentation pretty and not broken. ### Does this PR introduce any user-facing change? Theoretically, no. This is rather a regression fix in documentation (that happens only by #26521 in master). See the malformed doc in preview - https://spark.apache.org/docs/3.0.0-preview2/sql-pyspark-pandas-with-arrow.html ### How was this patch tested? Manually built the doc. **Before:** ![Screen Shot 2020-01-13 at 10 21 28 AM](https://user-images.githubusercontent.com/6477701/72229159-ba766a80-35ef-11ea-9a5d-9583448e7c1c.png) **After:** ![Screen Shot 2020-01-13 at 10 26 33 AM](https://user-images.githubusercontent.com/6477701/72229157-b34f5c80-35ef-11ea-8b3a-492e8aa0f82a.png) Closes #27182 from HyukjinKwon/SPARK-28752-followup. Authored-by: HyukjinKwon <[email protected]> Signed-off-by: HyukjinKwon <[email protected]>
1 parent 361583d commit 150d493

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/_plugins/include_example.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ def render(context)
5454
puts(e.backtrace)
5555
exit 1
5656
end
57-
code = select_lines(code)
57+
code = select_lines(code).strip
5858

59-
formatter = Rouge::Formatters::HTML.new
59+
formatter = Rouge::Formatters::HTMLPygments.new(Rouge::Formatters::HTML.new)
6060
lexer = Rouge::Lexer.find(@lang)
6161
rendered_code = formatter.format(lexer.lex(code))
6262

0 commit comments

Comments
 (0)