ahmadajmi / type

🎉 Minimal and Clean Free Jekyll Theme
https://type-jekyll.aspirethemes.com/
MIT License
212 stars 141 forks source link

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

Closed stigvoss closed 4 years ago

stigvoss commented 4 years ago

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 commented 4 years ago

The following CSS might be a good fix:

pre { word-break: break-all; }
stigvoss commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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.