Skip to content

Commit

Permalink
resolves rouge-ruby#280 use proper precedence when resolving style fo…
Browse files Browse the repository at this point in the history
…r token
  • Loading branch information
mojavelinux committed Jun 28, 2015
1 parent 684d200 commit 96c39e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/rouge/theme.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def style(*tokens)
end

def get_own_style(token)
token.token_chain.each do |anc|
token.token_chain.reverse_each do |anc|
return styles[anc] if styles[anc]
end

Expand Down
12 changes: 6 additions & 6 deletions spec/theme_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ def squish(str)
end

class MyTheme < Rouge::CSSTheme
style Literal::String, :bold => true
style Literal::String::Backtick, :italic => true
style Literal::String, :fg => '#003366', :bold => true
style Literal::String::Backtick, :fg => '#555555', :italic => true
end

let(:theme) { MyTheme.new }
Expand Down Expand Up @@ -35,12 +35,12 @@ class MyTheme < Rouge::CSSTheme
end

it 'fetches a style for a token' do
bold = theme.style_for(Token['Literal.String'])
assert { bold == { :bold => true } }
style = theme.style_for(Rouge::Token['Literal.String'])
assert { style == { :fg => '#003366', :bold => true } }
end

it 'fetches a the closest style for a token' do
bold = theme.style_for(Token['Literal.String.Double'])
assert { bold == { :bold => true } }
style = theme.style_for(Rouge::Token['Literal.String.Backtick'])
assert { style == { :fg => '#555555', :italic => true } }
end
end

0 comments on commit 96c39e3

Please sign in to comment.