Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precedence of style lookup is inverted #280

Closed
mojavelinux opened this issue Jun 28, 2015 · 1 comment
Closed

Precedence of style lookup is inverted #280

mojavelinux opened this issue Jun 28, 2015 · 1 comment

Comments

@mojavelinux
Copy link
Contributor

When resolving the style for a token using the style_for method (which eventually delegates to get_own_style), the precedence is backwards. What's expected is a more specific (nested) style to win over a more general (ancestor) style. However, the inverse is true.

I think that the following logic:

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

should in fact be:

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

The test case is as follows:

style Keyword::Type, fg: :gray, bold: true
style Keyword, fg: :green, bold: true

When I invoke:

style_for Token['Keyword.Type']

I expect to get:

{:fg => :gray, :bold => true}

Instead, I get:

{:fg => :green, :bold => true}

As a result, this makes the behavior of Rouge inconsistent with the behavior of Pygments.

@mojavelinux
Copy link
Contributor Author

I think the reason this wasn't detected by the test suite is because the test is ambiguous. It will assert true regardless of order of precedence in the implementation. When I send a pull request, I'll make sure that the test catches this distinction.

mojavelinux added a commit to mojavelinux/rouge that referenced this issue Jun 28, 2015
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Jun 28, 2015
- add integration with Rouge
- organize the code to setup syntax highlighting
- enable line number support when highlighting with Rouge
- add pastie theme for Rouge
- patch Rouge style lookup (see rouge-ruby/rouge#280)
- don't crash if color value is 3-digit hex in span style
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Jun 28, 2015
- add integration with Rouge for highlighting source listings
- organize the code to setup source highlighting
- enable line number support when highlighting with Rouge
- add pastie theme for Rouge
- patch Rouge style lookup (see rouge-ruby/rouge#280)
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Jun 28, 2015
- add integration with Rouge for highlighting source listings
- organize the code to setup source highlighting
- enable line number support when highlighting with Rouge
- add pastie theme for Rouge
- patch Rouge style lookup (see rouge-ruby/rouge#280)
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Jun 28, 2015
- add integration with Rouge for highlighting source listings
- organize the code to setup source highlighting
- enable line number support when highlighting with Rouge
- add pastie theme for Rouge
- patch Rouge style lookup (see rouge-ruby/rouge#280)
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Jun 28, 2015
- add integration with Rouge for highlighting source listings
- organize the code to setup source highlighting
- enable line number support when highlighting with Rouge
- add pastie theme for Rouge
- patch Rouge style lookup (see rouge-ruby/rouge#280)
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Jun 28, 2015
- add integration with Rouge for highlighting source listings
- organize the code to setup source highlighting
- enable line number support when highlighting with Rouge
- add pastie theme for Rouge
- patch Rouge style lookup (see rouge-ruby/rouge#280)
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Jul 6, 2015
- add integration with Rouge for highlighting source listings
- guard indentation within Rouge formatter
- organize the code to setup source highlighting
- enable line number support when highlighting with Rouge
- add pastie theme for Rouge
- patch Rouge style lookup (see rouge-ruby/rouge#280)
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Jul 6, 2015
- add integration with Rouge for highlighting source listings
- use no-break space for indent guard instead of zero-width space
- guard indentation within Rouge formatter
- organize the code to setup source highlighting
- enable line number support when highlighting with Rouge
- add pastie theme for Rouge
- patch Rouge style lookup (see rouge-ruby/rouge#280)
- cast lookup collections to set
- optimize code
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Jul 6, 2015
- add integration with Rouge for highlighting source listings
- use no-break space for indent guard instead of zero-width space
- guard indentation within Rouge formatter
- organize the code to setup source highlighting
- enable line number support when highlighting with Rouge
- add pastie theme for Rouge
- patch Rouge style lookup (see rouge-ruby/rouge#280)
- cast lookup collections to set
- optimize code
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Jul 6, 2015
- add integration with Rouge for highlighting source listings
- use no-break space for indent guard instead of zero-width space
- guard indentation within Rouge formatter
- organize the code to setup source highlighting
- enable line number support when highlighting with Rouge
- add pastie theme for Rouge
- patch Rouge style lookup (see rouge-ruby/rouge#280)
- cast lookup collections to set
- optimize code
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Jul 6, 2015
- add integration with Rouge for highlighting source listings
- use no-break space for indent guard instead of zero-width space
- guard indentation within Rouge formatter
- organize the code to setup source highlighting
- enable line number support when highlighting with Rouge
- add pastie theme for Rouge
- patch Rouge style lookup (see rouge-ruby/rouge#280)
- cast lookup collections to set
- optimize code
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Jul 6, 2015
- add integration with Rouge for highlighting source listings
- use no-break space for indent guard instead of zero-width space
- guard indentation within Rouge formatter
- organize the code to setup source highlighting
- enable line number support when highlighting with Rouge
- add pastie theme for Rouge
- patch Rouge style lookup (see rouge-ruby/rouge#280)
- cast lookup collections to set
- optimize code
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Jul 6, 2015
- add integration with Rouge for highlighting source listings
- use no-break space for indent guard instead of zero-width space
- guard indentation within Rouge formatter
- organize the code to setup source highlighting
- enable line number support when highlighting with Rouge
- add pastie theme for Rouge
- patch Rouge style lookup (see rouge-ruby/rouge#280)
- cast lookup collections to set
- optimize code
@jneen jneen closed this as completed in e100e86 Sep 10, 2015
jneen added a commit that referenced this issue Sep 10, 2015
resolves #280 use proper precedence when resolving style for token
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant