镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

Description

@pablobm

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

Activity

  1. pablobm commented on Dec 26, 2018

    @pablobm
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions