Skip to content

Commit 5bf0575

Browse files
committed
Replace space to   for HTML Rendering.
Reason: Some javascript frameworks(ex. vue.js) manipulate HTML tags when drawing. At that time, if there is a space-only DOM element, the space in the DOM element is deleted. Before: `` ` <span> </span> `` ` After (space deleted) `` ` <span></span> `` ` In order to avoid this, it has been modified to render with &nbsp; only when there is no diff.
1 parent faeb7b7 commit 5bf0575

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/line-by-line-printer.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@
211211
lineWithoutPrefix = lineWithPrefix.line;
212212
}
213213

214+
if (prefix === ' ') {
215+
prefix = '&nbsp;';
216+
}
217+
214218
return hoganUtils.render(genericTemplatesPath, 'line',
215219
{
216220
type: type,

src/side-by-side-printer.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@
244244
lineWithoutPrefix = lineWithPrefix.line;
245245
}
246246

247+
if (prefix === ' ') {
248+
prefix = '&nbsp;';
249+
}
250+
247251
return hoganUtils.render(genericTemplatesPath, 'line',
248252
{
249253
type: type,

0 commit comments

Comments
 (0)