From 11ec623eff7d2394d4771ce270914239ba8c1d1e Mon Sep 17 00:00:00 2001 From: DigiLive Date: Tue, 17 Nov 2020 10:57:53 +0100 Subject: [PATCH] Fix html syntax error Html Unified renderer causes following error when rendering skipped lines: Element div not allowed as child of element span in this context. --- example/dark-theme.css | 1 + example/styles.css | 1 + lib/jblond/Diff/Renderer/Html/Unified.php | 2 +- tests/resources/htmlUnified.txt | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/example/dark-theme.css b/example/dark-theme.css index c6ee4c6..8bd57ba 100644 --- a/example/dark-theme.css +++ b/example/dark-theme.css @@ -53,6 +53,7 @@ a, a:visited { .Differences .Skipped { background: #F7F7F7; color: #000000; + display: block; } .Differences ins, diff --git a/example/styles.css b/example/styles.css index fb6eaca..305c9e0 100644 --- a/example/styles.css +++ b/example/styles.css @@ -47,6 +47,7 @@ pre { .Differences .Skipped { background: #F7F7F7; + display: block; } /* diff --git a/lib/jblond/Diff/Renderer/Html/Unified.php b/lib/jblond/Diff/Renderer/Html/Unified.php index 914aaf2..e01932a 100644 --- a/lib/jblond/Diff/Renderer/Html/Unified.php +++ b/lib/jblond/Diff/Renderer/Html/Unified.php @@ -82,7 +82,7 @@ public function generateDiffHeader(): string */ public function generateSkippedLines(): string { - return '
'; + return ''; } diff --git a/tests/resources/htmlUnified.txt b/tests/resources/htmlUnified.txt index fc1adee..8827106 100644 --- a/tests/resources/htmlUnified.txt +++ b/tests/resources/htmlUnified.txt @@ -1 +1 @@ -<html>
    <head>
        <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
        <title>Hello World!</title>
        <title>Hello You!</title>
    </head>
    <body>
        <h1>This is demo content to show features of the php-diff package.</h1>
        <h2>This line is removed from version2.</h2>
        <h2>This line is the same for both versions.</h2>
        <h2>this line has inline differences between both versions.</h2>
        <h2>This line has differences between both versions.</h2>
        <h2>This line is the same for both versions.</h2>
        <h2>This line also has inline differences between both versions.</h2>
        <h2>This line also has InLine differences between both versions.</h2>
        <h2>This line is the same for both versions.</h2>
        <h2>This line is added to version2.</h2>

        <p>
            It's also compatible with multibyte characters (like Chinese and emoji) as shown below:
            另外我覺得那個評的白色櫃子有點沒有必要欸。外觀我就不說了 ,怎麼連空間都那麼狹隘。不過倒是從這個地方看出所謂的“改革”
            Do you know what "金槍魚罐頭" means in Chinese?
            🍏🍎🙂
            另外我覺得那個評的白色櫃子有點沒有必要欸。外觀我就不說了 ,怎麼連空間都那麼狹隘。不過倒是從這個地方看出所謂的“改革”
            Do you know what "魚の缶詰" means in Chinese?
            🍎🍏🙂
        </p>

        <p>Just some lines to demonstrate the collapsing of a block of lines which are the same in both versions.</p>
        <p>Just some lines to demonstrate the collapsing of a block of lines which are the same in both versions.</p>
        <p>Just some lines to demonstrate the collapsing of a block of lines which are the same in both versions.</p>
        <p>Just some lines to demonstrate the collapsing of a block of lines which are the same in both versions.</p>
        <h2>This line also has inline differences between both versions. It's the whitespace in front.</h2>
        <h2>This line also has inline differences between both versions. It's the whitespace in front.</h2>
        <h2>This line is the same for both versions.</h2>
        <h2>This line also has inline differences between both versions.</h2>
        <h2>This line also has inline differences between both versions!</h2>
    </body>
</html>

\ No newline at end of file +<html>
    <head>
        <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
        <title>Hello World!</title>
        <title>Hello You!</title>
    </head>
    <body>
        <h1>This is demo content to show features of the php-diff package.</h1>
        <h2>This line is removed from version2.</h2>
        <h2>This line is the same for both versions.</h2>
        <h2>this line has inline differences between both versions.</h2>
        <h2>This line has differences between both versions.</h2>
        <h2>This line is the same for both versions.</h2>
        <h2>This line also has inline differences between both versions.</h2>
        <h2>This line also has InLine differences between both versions.</h2>
        <h2>This line is the same for both versions.</h2>
        <h2>This line is added to version2.</h2>

        <p>
            It's also compatible with multibyte characters (like Chinese and emoji) as shown below:
            另外我覺得那個評的白色櫃子有點沒有必要欸。外觀我就不說了 ,怎麼連空間都那麼狹隘。不過倒是從這個地方看出所謂的“改革”
            Do you know what "金槍魚罐頭" means in Chinese?
            🍏🍎🙂
            另外我覺得那個評的白色櫃子有點沒有必要欸。外觀我就不說了 ,怎麼連空間都那麼狹隘。不過倒是從這個地方看出所謂的“改革”
            Do you know what "魚の缶詰" means in Chinese?
            🍎🍏🙂
        </p>

        <p>Just some lines to demonstrate the collapsing of a block of lines which are the same in both versions.</p>
        <p>Just some lines to demonstrate the collapsing of a block of lines which are the same in both versions.</p>
        <p>Just some lines to demonstrate the collapsing of a block of lines which are the same in both versions.</p>
        <p>Just some lines to demonstrate the collapsing of a block of lines which are the same in both versions.</p>
        <h2>This line also has inline differences between both versions. It's the whitespace in front.</h2>
        <h2>This line also has inline differences between both versions. It's the whitespace in front.</h2>
        <h2>This line is the same for both versions.</h2>
        <h2>This line also has inline differences between both versions.</h2>
        <h2>This line also has inline differences between both versions!</h2>
    </body>
</html>

\ No newline at end of file