From 5bf0575b46e924890e65001225ddbcacaa365e0a Mon Sep 17 00:00:00 2001 From: Koki Oyatsu Date: Sun, 7 Jul 2019 02:39:50 +0900 Subject: [PATCH 1/2] 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: `` ` `` ` After (space deleted) `` ` `` ` In order to avoid this, it has been modified to render with   only when there is no diff. --- src/line-by-line-printer.js | 4 ++++ src/side-by-side-printer.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/line-by-line-printer.js b/src/line-by-line-printer.js index 33722b6..49f183f 100644 --- a/src/line-by-line-printer.js +++ b/src/line-by-line-printer.js @@ -211,6 +211,10 @@ lineWithoutPrefix = lineWithPrefix.line; } + if (prefix === ' ') { + prefix = ' '; + } + return hoganUtils.render(genericTemplatesPath, 'line', { type: type, diff --git a/src/side-by-side-printer.js b/src/side-by-side-printer.js index 6a739e5..f11572c 100644 --- a/src/side-by-side-printer.js +++ b/src/side-by-side-printer.js @@ -244,6 +244,10 @@ lineWithoutPrefix = lineWithPrefix.line; } + if (prefix === ' ') { + prefix = ' '; + } + return hoganUtils.render(genericTemplatesPath, 'line', { type: type, From 201c6a9f5cb82502ae87b51dfc7b213efa2a1f9c Mon Sep 17 00:00:00 2001 From: Koki Oyatsu Date: Sun, 7 Jul 2019 02:51:50 +0900 Subject: [PATCH 2/2] Replace space to   for HTML Rendering.(fix test) --- test/diff2html-tests.js | 26 +++++++++++++------------- test/line-by-line-tests.js | 2 +- test/side-by-side-printer-tests.js | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/test/diff2html-tests.js b/test/diff2html-tests.js index 23e83da..af9914c 100644 --- a/test/diff2html-tests.js +++ b/test/diff2html-tests.js @@ -335,7 +335,7 @@ describe('Diff2Html', function() { ' \n' + ' \n' + '
\n' + - ' \n' + + '  \n' + ' # Change Log\n' + '
\n' + ' \n' + @@ -346,7 +346,7 @@ describe('Diff2Html', function() { ' \n' + ' \n' + '
\n' + - ' \n' + + '  \n' + ' All notable changes to this project will be documented in this file.\n' + '
\n' + ' \n' + @@ -357,7 +357,7 @@ describe('Diff2Html', function() { ' \n' + ' \n' + '
\n' + - ' \n' + + '  \n' + ' This project adheres to [Semantic Versioning](http://semver.org/).\n' + '
\n' + ' \n' + @@ -379,7 +379,7 @@ describe('Diff2Html', function() { ' \n' + ' \n' + '
\n' + - ' \n' + + '  \n' + ' $a="<table><tr><td>\n' + '
\n' + ' \n' + @@ -390,7 +390,7 @@ describe('Diff2Html', function() { ' \n' + ' \n' + '
\n' + - ' \n' + + '  \n' + ' $a="<table><tr><td>- 1.1.9: Fix around ubuntu's inability to cache promises. [#877](https://github.com/FredrikNoren/ungit/pull/878)\n' + '
\n' + ' \n' + @@ -401,7 +401,7 @@ describe('Diff2Html', function() { ' \n' + ' \n' + '
\n' + - ' \n' + + '  \n' + ' - 1.1.8:\n' + '
\n' + ' \n' + @@ -418,7 +418,7 @@ describe('Diff2Html', function() { ' \n' + ' \n' + '
\n' + - ' \n' + + '  \n' + ' - 1.1.7:\n' + '
\n' + ' \n' + @@ -429,7 +429,7 @@ describe('Diff2Html', function() { ' \n' + ' \n' + '
\n' + - ' \n' + + '  \n' + ' - Fix diff flickering issue and optimization [#865](https://github.com/FredrikNoren/ungit/pull/865)\n' + '
\n' + ' \n' + @@ -440,7 +440,7 @@ describe('Diff2Html', function() { ' \n' + ' \n' + '
\n' + - ' \n' + + '  \n' + ' - Fix credential dialog issue [#864](https://github.com/FredrikNoren/ungit/pull/864)\n' + '
\n' + ' \n' + @@ -473,7 +473,7 @@ describe('Diff2Html', function() { ' \n' + ' \n' + '
\n' + - ' \n' + + '  \n' + ' - 1.1.6: Fix path auto complete [#861](https://github.com/FredrikNoren/ungit/issues/861)\n' + '
\n' + ' \n' + @@ -484,7 +484,7 @@ describe('Diff2Html', function() { ' \n' + ' \n' + '
\n' + - ' \n' + + '  \n' + ' - 1.1.5: Update "Toggle all" button after commit or changing selected files [#859](https://github.com/FredrikNoren/ungit/issues/859)\n' + '
\n' + ' \n' + @@ -495,7 +495,7 @@ describe('Diff2Html', function() { ' \n' + ' \n' + '
\n' + - ' \n' + + '  \n' + ' - 1.1.4: [patch] Promise refactoring\n' + '
\n' + ' \n' + @@ -506,7 +506,7 @@ describe('Diff2Html', function() { ' \n' + ' \n' + '
\n' + - ' \n' + + '  \n' + '
\n' + ' \n' + '\n' + diff --git a/test/line-by-line-tests.js b/test/line-by-line-tests.js index 054b4d5..72d3711 100644 --- a/test/line-by-line-tests.js +++ b/test/line-by-line-tests.js @@ -559,7 +559,7 @@ describe('LineByLinePrinter', function() { ' \n' + ' \n' + '
\n' + - ' \n' + + '  \n' + ' one context line\n' + '
\n' + ' \n' + diff --git a/test/side-by-side-printer-tests.js b/test/side-by-side-printer-tests.js index 523e9ce..3a1258b 100644 --- a/test/side-by-side-printer-tests.js +++ b/test/side-by-side-printer-tests.js @@ -84,7 +84,7 @@ describe('SideBySidePrinter', function() { ' \n' + ' \n' + '
\n' + - ' \n' + + '  \n' + ' context\n' + '
\n' + ' \n' + @@ -121,7 +121,7 @@ describe('SideBySidePrinter', function() { ' \n' + ' \n' + '
\n' + - ' \n' + + '  \n' + ' context\n' + '
\n' + ' \n' +