Skip to content

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

Open
@pablobm

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

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