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 lines do not wrap properly #66

Open
JonnoFTW opened this issue Jul 20, 2015 · 9 comments
Open

Long lines do not wrap properly #66

JonnoFTW opened this issue Jul 20, 2015 · 9 comments

Comments

@JonnoFTW
Copy link

I am trying to view a .tex file with very long lines, but the <pre> element does not split these long lines despite it having element style:

word-wrap: break-word;
white-space: pre-wrap;

Adding !important to these rules makes the line wrap, but there is no padding at the start of the newline, so it goes below the line number margin:

http://puu.sh/j5Gbj/4b64065969.png

@tsenart
Copy link
Owner

tsenart commented Jul 21, 2015

Have you got an URL I can reproduce this with?

@JonnoFTW
Copy link
Author

@tsenart
Copy link
Owner

tsenart commented Aug 8, 2016

@JonnoFTW: Have you got any fix in mind?

@JonnoFTW
Copy link
Author

JonnoFTW commented Aug 9, 2016

I don't know sorry, my CSS skills aren't that good.

@YellowAfterlife
Copy link

YellowAfterlife commented Oct 10, 2016

It seems like a commonly used method for dealing with this is making the "code area" a <table> with two columns per line/row - one for line numbers (containing a ::before akin to how .line does already), and one for actual code. This way, when the code wraps, the line-number-cell extends it's height, and it remains aligned accordingly.

<table>
<tr><td class="line"></td><td>(line 1)</td></tr>
<tr><td class="line"></td><td>(line 2)</td></tr>
</table>
pre table {
    border-spacing: 0;
    border-collapse: collapse;
}
pre td.line {
    width: 1%;
    white-space: nowrap;
    text-align: right;
    min-width: 2em;
}

GitHub uses a similar approach for displaying code in repositories.

@tsenart
Copy link
Owner

tsenart commented Oct 10, 2016

@YellowAfterlife: Would you draft a PR?

@YellowAfterlife
Copy link

I'll try tomorrow. Been a little while since I've last poked with actual Chrome extensions (as opposed to making userscripts).

@YellowAfterlife
Copy link

@tsenart This wasn't particularly "tomorrow", but here: #88

@tsenart
Copy link
Owner

tsenart commented Nov 9, 2016

@YellowAfterlife: I'll take a look at your PR tomorrow.

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

3 participants