Skip to content

Commit

Permalink
Transform rouge options keys into symbols.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnando committed Feb 20, 2022
1 parent eafbabb commit bfa68f0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- Fix Rouge options keys; symbols are required.

## v3.0.2

- Fix `styles` directory copying.
Expand Down
2 changes: 2 additions & 0 deletions lib/kitabu/extensions/rouge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ module Plugins
module Redcarpet
def rouge_formatter(lexer)
options = lexer.respond_to?(:options) ? lexer.options : {}
options = options.keys.map(&:to_sym).zip(options.values).to_h
options[:start_line] = options.fetch(:start_line, 1).to_i

Formatters::HTMLLegacy.new(
{css_class: "highlight #{lexer.tag}"}.merge(options)
Expand Down
11 changes: 11 additions & 0 deletions spec/kitabu/markdown_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ class User
expect(html).to include('<span class="k">echo</span>')
end

it "enables line numbers" do
html = Kitabu::Markdown.render <<-TEXT.strip_heredoc
```ruby?line_numbers=true
class User
end
```
TEXT

expect(html).to include(%[<table class="rouge-table">])
end

it "does not raise with unknown lexers" do
expect do
Kitabu::Markdown.render <<-TEXT.strip_heredoc
Expand Down

0 comments on commit bfa68f0

Please sign in to comment.