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

Line wrapping of long code lines #253

Closed
silverwind opened this issue Sep 2, 2015 · 27 comments
Closed

Line wrapping of long code lines #253

silverwind opened this issue Sep 2, 2015 · 27 comments

Comments

@silverwind
Copy link
Member

I just pushed a change that enables wrapping of long lines like this one.

So far It seems to work, but there may be side effects and we also need to take care of Gist and other code boxes. We could do an option for it, but I see no downside, so it may be unnecessary.

@silverwind silverwind changed the title Kine wrapping of long code lines Line wrapping of long code lines Sep 2, 2015
@Mottie
Copy link
Member

Mottie commented Sep 2, 2015

I like it... I'm using it now and I'll report back if I run into any issues.

@Mottie
Copy link
Member

Mottie commented Sep 2, 2015

The change does not work on encoded images.

You can include a break-all definition, but I don't know if it's a good idea since it will break up words in the middle:

.blob-code-inner {
  white-space: pre-wrap !important;
  word-break: break-all !important;
}

@silverwind
Copy link
Member Author

Hmm, I guess most editors break like break-all, so breaking in the middle of a word is probably acceptable in code, I'll do it. Also, copy-paste is not affected by this, thankfully.

7b241f3

@silverwind
Copy link
Member Author

Looking good so far. The blob-code-inner class i used pretty much everywhere, even in Gist.

@silverwind
Copy link
Member Author

There's a bit of horizontal overflow on diffs it seems: silverwind/uppie@00ca357 (view the suppressed diff). Not sure what's exactly causing the overflow here.

@silverwind
Copy link
Member Author

Added display: block in an attempt to fix that overflow. Watch out for issues :)

@silverwind
Copy link
Member Author

Some weird black borders started to appear in expanded diffs. Not sure how to get rid of them, I think they are table borders:

screen shot 2015-09-04 at 4 17 39 pm

@Mottie
Copy link
Member

Mottie commented Sep 4, 2015

It's because some td's have the blob-code-inner class. You can add this to fix it:

td.blob-code-inner {
  display: table-cell !important;
}

@silverwind
Copy link
Member Author

Awesome, thanks 👍

@silverwind
Copy link
Member Author

So far I noticed no issues, I think it's good to go.

@simov
Copy link

simov commented Dec 10, 2015

Can we not use it in issue comments request/request#1932 (comment) at least ? That looks kind of funny and it's definitely not easy to read.

The code block placed inside an issue is much narrower than the one in the source code view, plus line wrapping makes sense only for certain text types.

@silverwind
Copy link
Member Author

With my current font, the inline block fits 89 characters, which isn't too bad as many people still adhere to 80 character lines. We should at least add an option on userstyles.org for people who prefer no wrapping and I think I'll explore a userscript addon to toggle wrapping.

@silverwind silverwind reopened this Dec 11, 2015
@simov
Copy link

simov commented Dec 11, 2015

80 character lines

That's kind of true but people tend to paste completely random stuff in the comment box. I can still change the style for myself only, but I though that's an actual issue.

@Mottie
Copy link
Member

Mottie commented Dec 11, 2015

Hey @silverwind, the second line targets code in comments. What is the .markdown-body in the first line targeting?

  /* GitHub Bug: Enable wrapping of long code lines */
  .blob-code-inner, .markdown-body > pre > code,
  .markdown-body > .highlight > pre {
    white-space: pre-wrap !important;
    word-break: break-all !important;
    display: block !important;
  }

@silverwind
Copy link
Member Author

something to test:

longlonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong

@silverwind
Copy link
Member Author

@Mottie can't remember. It's certainly not Gist. I think you can remove it.

@silverwind
Copy link
Member Author

Made a little toggle button for code boxes in Markdown:

For it to work, we'd have to reduce above selector to just .blob-code-inner. It's not working on dynamically added content yet, for that I'll have to modify the page's stylesheet on-the-fly.

https://gist.github.com/silverwind/6c1701f56e62204cc42b

@silverwind
Copy link
Member Author

@Mottie the second selector is actually for block with highlighting. Their markup is a bit different from non-highlighted boxes.

@Mottie
Copy link
Member

Mottie commented Dec 11, 2015

Maybe we should make our "GitHub Dark Script" repository again 😋

@Mottie
Copy link
Member

Mottie commented Dec 11, 2015

LOL - I still have the code from when the repository existed. It contains a script to colorize these comment boxes per author (based on their name).

@silverwind
Copy link
Member Author

Yeah, that was hell of a hack :)

Actually, I'll see if I can get something more general done. Like a script that can toggle on/off certain sections of the stylesheet, that'd be ideal for something like this wrap thing, but could be expanded to more options. I think a "GitHub Dark" option sub-panel is in order.

@Mottie
Copy link
Member

Mottie commented Jan 25, 2016

@silverwind Do you think we can close this issue now? 😛

@silverwind
Copy link
Member Author

I still would like to make the default to not wrap, wanna make that change? (Might require a option flip in the script too)

@Mottie
Copy link
Member

Mottie commented Jan 25, 2016

Ok, but I won't be able to get it done until later tonight.

@silverwind
Copy link
Member Author

No hurry 👍

@Mottie Mottie closed this as completed Jan 26, 2016
@Mottie
Copy link
Member

Mottie commented Jan 26, 2016

All done.

@silverwind
Copy link
Member Author

Standalone version for people who prefer wrapping without the script.

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