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

Misaligned line numbers in diff files with `line_numbers: :inline` #232

Open
pablobm opened this Issue Dec 26, 2018 · 1 comment

Comments

Projects
None yet
1 participant
@pablobm
Copy link

pablobm commented Dec 26, 2018

Say we have a diff file, test.diff:

--- file1	2018-12-26 11:14:56.000000000 +0000
+++ file2	2018-12-26 11:15:08.000000000 +0000
@@ -1,4 +1,3 @@
 a
-bcd
-ef
+bCd
 g

And we run CodeRay with the following options:

CodeRay.scan(File.read("test.diff"), :diff).page(css: :class, line_numbers: :inline)

The resulting HTML+CSS shows the line numbers misaligned, as follows:

bug-original

The following example is the same output, with the CSS rules width: 40em; margin: auto; applied to the .CodeRay block to highlight "wrapped-over" line numbers and content:

bug-limited-width

This is the expected behaviour, achieved by not using the option line_numbers: :inline:

expected-behaviour

@pablobm

This comment has been minimized.

Copy link
Author

pablobm commented Dec 26, 2018

At first inspection, it would appear that the CSS properties for .CodeRay .line don't play well with the line numbers. This class is applied to the lines with colour background to allow the colour cover the whole line. When these properties are removed, the problem disappears, but the colour stops covering the whole line:

css-workaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.