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

Long code lines expands text outside view on mobile. #10

Closed
stigvoss opened this issue Jan 4, 2020 · 5 comments
Closed

Long code lines expands text outside view on mobile. #10

stigvoss opened this issue Jan 4, 2020 · 5 comments

Comments

@stigvoss
Copy link
Contributor

stigvoss commented Jan 4, 2020

I am experiencing issues where long code lines in a code block can cause mobile browsers to overflow without scrollbars either in the view or the code block.

An example would be a code block like below:

try
{
    tokenSource.CancelAfter(requestTimeout);
}

I am attempted to fix the issue, but unsuccessfully.

@ahmadajmi
Copy link
Owner

The following CSS might be a good fix:

pre { word-break: break-all; }

@stigvoss
Copy link
Contributor Author

stigvoss commented Jan 7, 2020

The break-all keyword does not seem to be recognized by my Firefox browser, although anywhere seem to exist and works for breaking the lines, well, anywhere.

It works as a fix, I assume the alternative would be to allow horizontal scrolling in code blocks. I'm not sure which is the better solution as both broken lines and scrolling makes it difficult to read code on a mobile device.

Would you know of a way to allow horizontal scrolling in a code block?

@stigvoss
Copy link
Contributor Author

After having a look at the issue again, I have to conclude that I confused word-wrap and the word-break you refer to above. You are correct that the following will solve the issue.

pre {
  word-wrap: break-word;
  word-break: break-all;
}

Besides that, the issue only seemed to surface in Firefox, not Chrome.

@ahmadajmi
Copy link
Owner

ahmadajmi commented Jan 17, 2020

Thank you! I merged the PR. I tested it in Firefox and seems to be working fine too.

Screenshot: Screen Shot 2020-01-17 at 5 04 26 PM

@ahmadajmi
Copy link
Owner

Would you know of a way to allow horizontal scrolling in a code block?

I created a new issue at the moment for this and I will look into it further.

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

2 participants