Skip to content

fix: Use GitHub style line prefix and fix code selection #347

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions src/templates/generic-line.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,7 @@
</td>
<td class="{{type}}">
<div class="{{contentClass}} {{type}}">
{{#prefix}}
<span class="d2h-code-line-prefix">{{{prefix}}}</span>
{{/prefix}}
{{^prefix}}
<span class="d2h-code-line-prefix">&nbsp;</span>
{{/prefix}}
{{#content}}
<span class="d2h-code-line-ctn">{{{content}}}</span>
{{/content}}
{{^content}}
<span class="d2h-code-line-ctn"><br></span>
{{/content}}
<span class="d2h-code-line-ctn" data-prefix="{{#prefix}}{{{prefix}}}{{/prefix}}{{^prefix}}&nbsp;{{/prefix}}">{{#content}}{{{content}}}{{/content}}{{^content}}<br>{{/content}}</span>
</div>
</td>
</tr>
8 changes: 6 additions & 2 deletions src/ui/css/diff2html.css
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,16 @@
text-align: left;
}

.d2h-code-line-prefix {
/* .d2h-code-line-prefix {
display: inline;
background: none;
padding: 0;
word-wrap: normal;
white-space: pre;
} */

.d2h-code-line-ctn:before {
content: attr(data-prefix);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would need an additional padding-right: 7px or so to be visually equal to the current state.

}

.d2h-code-line-ctn {
Expand Down Expand Up @@ -207,7 +211,7 @@

.d2h-code-linenumber,
.d2h-code-side-linenumber,
.d2h-code-line-prefix,
/* .d2h-code-line-prefix, */
.d2h-emptyplaceholder {
user-select: none;
}
Expand Down