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

Code block should avoid auto-wrap #58

Closed
calfzhou opened this issue Nov 8, 2013 · 11 comments
Closed

Code block should avoid auto-wrap #58

calfzhou opened this issue Nov 8, 2013 · 11 comments
Labels
bug Well, it shouldn’t be doing that. Let’s fix it!
Milestone

Comments

@calfzhou
Copy link
Contributor

calfzhou commented Nov 8, 2013

Shown as the following screenshot, the long-code-line wrapped, and won't align correctly with line numbers.

And if the line number is bigger than 9 (has more than one digits), it will wrap too! Which makes the code-block looks ugly.

image

@calfzhou
Copy link
Contributor Author

calfzhou commented Nov 8, 2013

Add style white-space:pre; to code-block <pre> tag could fix this. But how to add a proper horizontal scroll bar?

image

@talha131
Copy link
Member

talha131 commented Nov 8, 2013

@calfzhou thanks a lot for reporting this issue. I have fixed the issue to the best of my knowledge. Can you please confirm the fix?

I have also made a change that hides line numbers on tablets and phones to save space for actual content. What do you think of it? You can see it by changing your browser window size.

@tshepang you too please share your opinion on this "hiding" feature.

@calfzhou
Copy link
Contributor Author

calfzhou commented Nov 9, 2013

Thanks @talha131 for this fix! It works well on my blog :) And i like this "auto hiding" feature very much.

One more opinion is that, "line numbers" should expand its column width instead of show a scroll bar. A scroll bar on this thin column makes user hard to read the numbers.

image

Style vertical-align: top could be added to each td to get better alignment when only one scroll bar is visible.

image

@tshepang
Copy link

tshepang commented Nov 9, 2013

damn, that was a horrible bug

@tshepang
Copy link

tshepang commented Nov 9, 2013

is good @talha131

@talha131
Copy link
Member

talha131 commented Nov 9, 2013

@tshepang thank you for your feedback.

@calfzhou

"line numbers" should expand its column width instead of show a scroll bar.

I agree. I have fixed it. But there is a bug in my implementation which I could not fix with all my efforts. If your code snippet has more 100 lines then your line numbers will be cut from the right. But for 1-99 it works fine.

You are quite knowledgeable about CSS. Can you please suggest a fix?

Style vertical-align: top could be added to each td to get better alignment when only one scroll bar is visible.

I have added it though I cannot see this issue on my system. I couldn't notice it earlier because my scroll bars are set to auto hide.

Keep coming up with feedback, patches and suggestions.

@calfzhou
Copy link
Contributor Author

@talha131 , the problem is really hard to solve. I tried several times but cannot find a better solution. I remembered that my previous Wordpress code block plugin wraps the table in a div, it gives the div a width: 100%; overflow: auto; style. You could see a demo at http://kpumuk.info/projects/wordpress-plugins/codecolorer/ .

Pygments generate a naked table. Without the wrapper div, styling becomes much harder. In Pygments document (http://pygments.org/docs/formatters/#htmlformatter), I found that there is a div wrapping the code table in the example, but maybe they changed the behavior.

@talha131
Copy link
Member

@calfzhou Thanks for investigating this issue. I think current solution is a good middle ground. I don't think users usually post 100+ lines of code in a post.

@calfzhou
Copy link
Contributor Author

@talha131,

I couldn't notice it earlier because my scroll bars are set to auto hide.

You are using Mac, am I right? I tried my Mac system today, and found the cool scroll bar, it is auto-hide. Is it possible to make it work on every system using CSS?

image

@talha131
Copy link
Member

Is it possible to make it work on every system using CSS?

Scroll bar look and behavior is a function of OS. Some apps create their custom scroll bars using third party widgets. In any case, its behavior and look is a function of OS or app. That's why it can't be controlled with CSS.

@rednafi
Copy link

rednafi commented Jan 21, 2022

Code blocks are still getting auto-wrapped like this:
Screenshot from 2022-01-22 03-41-40

How can I get a scrollbar if the line is longer than a cutoff?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Well, it shouldn’t be doing that. Let’s fix it!
Development

No branches or pull requests

4 participants