Skip to content

Line number blank with single line code #41

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

Closed
ariejan opened this issue Oct 22, 2012 · 5 comments
Closed

Line number blank with single line code #41

ariejan opened this issue Oct 22, 2012 · 5 comments
Assignees
Milestone

Comments

@ariejan
Copy link

ariejan commented Oct 22, 2012

I use the :table styling for line numbers. But when there's only a single line of code the line number column only contains a blank <pre></pre>, where I'd expect to be a 1.

@korny
Copy link
Member

korny commented Oct 26, 2012

Actually, I thought a single line number of "1" would be obsolete, so I made a special case for that.

Is the behavior problematic for you, or just unexpeced?

How about an option for this, like :line_numbers_hide_single with a default setting of true?

@nathany
Copy link
Contributor

nathany commented Oct 28, 2012

How about an option to hide line numbers if there are less than x lines? (default 0, don't hide them). This would be more flexible. Reference:

Well, for line numbering my blog is a real use case :) In my blog most of the code blocks are about 10/15 lines, so line numbering is unnecessary, but in the post Extending RedCloth with CodeRay, there's a code snippet of 60 lines, and line numbering is useful only in that case. (Issue #65) - @nicolaracco

I think hiding line numbers should be off by default, but if we do that, this should probably be for 1.1? (a "breaking" change)

@ghost ghost assigned korny Oct 28, 2012
@korny
Copy link
Member

korny commented Nov 11, 2012

How about an option to hide line numbers if there are less than x lines?

The case seems to odd to me to make it an option. It's really easy to do yourself, and more readable:

CodeRay.highlight code, :ruby, :line_numbers => code.lines.count > 15 && :table

@korny korny closed this as completed Nov 11, 2012
@nathany
Copy link
Contributor

nathany commented Nov 11, 2012

Nice. But then why not:

CodeRay.highlight code, :ruby, :line_numbers => code.lines.count > 1 && :table

Instead of having a special case built-in for hiding line numbers when there is only 1 line?

@korny
Copy link
Member

korny commented Nov 13, 2012

Good point. We will do that, but in 1.1. Also fixes OP's bug :-)

@korny korny reopened this Nov 13, 2012
@korny korny closed this as completed in 3d7f345 Mar 10, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants