File tree Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ kramdown:
2828 hard_wrap : true
2929 syntax_highlighter : rouge
3030 syntax_highlighter_opts :
31- formatter : HTMLPygmentsA11y
31+ formatter : HTMLLegacyA11y
3232
3333sass :
3434 load_paths :
Original file line number Diff line number Diff line change 11require 'rouge'
2+
23# Include tabindex for accessibility reasons
3- class HTMLPygmentsA11y < Rouge ::Formatters ::HTML
4+ class Rouge ::Formatters ::HTMLPygmentsA11y < Rouge ::Formatters ::HTMLPygments
5+ def initialize ( inner , css_class = 'codehilite' )
6+ @inner = inner
7+ @css_class = css_class
8+ end
9+
410 def stream ( tokens , &b )
511 yield %(<div class="highlight"><pre class="#{ @css_class } "><code tabindex="0">)
612 @inner . stream ( tokens , &b )
7- yield "</code></pre></div"
13+ yield "</code></pre></div>"
14+ end
15+ end
16+
17+ class Rouge ::Formatters ::HTMLLegacyA11y < Rouge ::Formatters ::HTMLLegacy
18+ def initialize ( opts = { } )
19+ @formatter = opts [ :inline_theme ] ? HTMLInline . new ( opts [ :inline_theme ] )
20+ : Rouge ::Formatters ::HTML . new
21+
22+
23+ @formatter = Rouge ::Formatters ::HTMLTable . new ( @formatter , opts ) if opts [ :line_numbers ]
24+
25+ if opts . fetch ( :wrap , true )
26+ @formatter = Rouge ::Formatters ::HTMLPygmentsA11y . new ( @formatter , opts . fetch ( :css_class , 'codehilite' ) )
27+ end
28+ end
29+
30+ # @yield the html output.
31+ def stream ( tokens , &b )
32+ @formatter . stream ( tokens , &b )
833 end
934end
You can’t perform that action at this time.
0 commit comments