Skip to content

Commit

Permalink
validate html
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredsburrows committed Jan 27, 2024
1 parent ccc85ad commit c8e9310
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 42 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ plugins {
alias(libs.plugins.maven.publish) apply false
alias(libs.plugins.plugin.publish) apply false
alias(libs.plugins.versions)
alias(libs.plugins.license)
id 'java-gradle-plugin'
id 'java-library'
id 'groovy'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import java.net.URISyntaxException
/**
* Renders information in a format suitable for logging to the console.
*
* Taken from: https://github.com/gradle/gradle/blob/master/subprojects/logging/src/main/java/org/gradle/internal/logging/ConsoleRenderer.java
* Taken from: https://github.com/gradle/gradle/blob/f3828bbb3350292dcbea7f505464eb5d30cb9d44/platforms/core-runtime/logging/src/main/java/org/gradle/internal/logging/ConsoleRenderer.java
*/
class ConsoleRenderer {

Expand All @@ -29,7 +29,7 @@ class ConsoleRenderer {
/**
* Wraps a checked exception. Carries no other context.
*
* Taken from: https://github.com/gradle/gradle/blob/master/subprojects/base-services/src/main/java/org/gradle/internal/UncheckedException.java
* Taken from: https://github.com/gradle/gradle/blob/f3828bbb3350292dcbea7f505464eb5d30cb9d44/platforms/core-runtime/base-services/src/main/java/org/gradle/internal/UncheckedException.java
*/
private class UncheckedException : RuntimeException {
constructor(cause: Throwable) : super(cause)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import kotlinx.html.TagConsumer
import kotlinx.html.attributesMapOf
import kotlinx.html.body
import kotlinx.html.br
import kotlinx.html.dd
import kotlinx.html.dl
import kotlinx.html.dt
import kotlinx.html.h3
Expand Down Expand Up @@ -114,13 +115,15 @@ class HtmlReport(private val projects: List<Model>) : Report {
+Entities.copy
+" $copyrightYear ${developer.id}"
}
dd { }
}
} else {
dt {
+COPYRIGHT
+Entities.copy
+" $copyrightYear $DEFAULT_AUTHOR"
}
dd { }
}
}
}
Expand Down Expand Up @@ -249,7 +252,7 @@ class HtmlReport(private val projects: List<Model>) : Report {
private const val EXTENSION = "html"
private const val NAME = "HTML"
const val DOCTYPE = "<!DOCTYPE html>"
const val META = "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />"
const val META = "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">"
const val CSS_STYLE =
"body { font-family: sans-serif } pre { background-color: #eeeeee; padding: 1em; white-space: pre-wrap; word-break: break-word; display: inline-block }"
const val OPEN_SOURCE_LIBRARIES = "Open source licenses"
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class LicensePluginJavaSpec extends Specification {
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style>body { font-family: sans-serif } pre { background-color: #eeeeee; padding: 1em; white-space: pre-wrap; word-break: break-word; display: inline-block }</style>
<title>Open source licenses</title>
</head>
Expand Down Expand Up @@ -104,7 +104,7 @@ final class LicensePluginJavaSpec extends Specification {
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style>body { font-family: sans-serif } pre { background-color: #eeeeee; padding: 1em; white-space: pre-wrap; word-break: break-word; display: inline-block }</style>
<title>Open source licenses</title>
</head>
Expand All @@ -115,6 +115,7 @@ final class LicensePluginJavaSpec extends Specification {
<a href="#0">firebase-core (10.0.1)</a>
<dl>
<dt>Copyright &copy; 20xx The original author or authors</dt>
<dd></dd>
</dl>
</li>
<a name="0"></a>
Expand Down Expand Up @@ -187,7 +188,7 @@ final class LicensePluginJavaSpec extends Specification {
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style>body { font-family: sans-serif } pre { background-color: #eeeeee; padding: 1em; white-space: pre-wrap; word-break: break-word; display: inline-block }</style>
<title>Open source licenses</title>
</head>
Expand All @@ -198,12 +199,14 @@ final class LicensePluginJavaSpec extends Specification {
<a href="#1934118923">appcompat-v7 (26.1.0)</a>
<dl>
<dt>Copyright &copy; 20xx The original author or authors</dt>
<dd></dd>
</dl>
</li>
<li>
<a href="#1934118923">design (26.1.0)</a>
<dl>
<dt>Copyright &copy; 20xx The original author or authors</dt>
<dd></dd>
</dl>
</li>
<a name="1934118923"></a>
Expand Down Expand Up @@ -295,7 +298,7 @@ final class LicensePluginJavaSpec extends Specification {
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style>body { font-family: sans-serif } pre { background-color: #eeeeee; padding: 1em; white-space: pre-wrap; word-break: break-word; display: inline-block }</style>
<title>Open source licenses</title>
</head>
Expand Down Expand Up @@ -354,7 +357,7 @@ final class LicensePluginJavaSpec extends Specification {
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style>body { font-family: sans-serif } pre { background-color: #eeeeee; padding: 1em; white-space: pre-wrap; word-break: break-word; display: inline-block }</style>
<title>Open source licenses</title>
</head>
Expand All @@ -365,6 +368,7 @@ final class LicensePluginJavaSpec extends Specification {
<a href="#-296292112">Fake dependency name (1.0.0)</a>
<dl>
<dt>Copyright &copy; 2017 name</dt>
<dd></dd>
</dl>
</li>
<a name="-296292112"></a>
Expand Down Expand Up @@ -445,7 +449,7 @@ final class LicensePluginJavaSpec extends Specification {
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style>body { font-family: sans-serif } pre { background-color: #eeeeee; padding: 1em; white-space: pre-wrap; word-break: break-word; display: inline-block }</style>
<title>Open source licenses</title>
</head>
Expand All @@ -456,6 +460,7 @@ final class LicensePluginJavaSpec extends Specification {
<a href="#1195092182">Fake dependency name (1.0.0)</a>
<dl>
<dt>Copyright &copy; 2017 name</dt>
<dd></dd>
</dl>
</li>
<a name="1195092182"></a>
Expand Down Expand Up @@ -545,7 +550,7 @@ final class LicensePluginJavaSpec extends Specification {
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style>body { font-family: sans-serif } pre { background-color: #eeeeee; padding: 1em; white-space: pre-wrap; word-break: break-word; display: inline-block }</style>
<title>Open source licenses</title>
</head>
Expand All @@ -556,6 +561,7 @@ final class LicensePluginJavaSpec extends Specification {
<a href="#1934118923">Retrofit (2.3.0)</a>
<dl>
<dt>Copyright &copy; 20xx The original author or authors</dt>
<dd></dd>
</dl>
</li>
<a name="1934118923"></a>
Expand All @@ -566,6 +572,7 @@ final class LicensePluginJavaSpec extends Specification {
<a href="#-296292112">Fake dependency name (1.0.0)</a>
<dl>
<dt>Copyright &copy; 2017 name</dt>
<dd></dd>
</dl>
</li>
<a name="-296292112"></a>
Expand Down Expand Up @@ -676,7 +683,7 @@ final class LicensePluginJavaSpec extends Specification {
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style>body { font-family: sans-serif } pre { background-color: #eeeeee; padding: 1em; white-space: pre-wrap; word-break: break-word; display: inline-block }</style>
<title>Open source licenses</title>
</head>
Expand All @@ -687,12 +694,14 @@ final class LicensePluginJavaSpec extends Specification {
<a href="#1934118923">appcompat-v7 (26.1.0)</a>
<dl>
<dt>Copyright &copy; 20xx The original author or authors</dt>
<dd></dd>
</dl>
</li>
<li>
<a href="#1934118923">design (26.1.0)</a>
<dl>
<dt>Copyright &copy; 20xx The original author or authors</dt>
<dd></dd>
</dl>
</li>
<a name="1934118923"></a>
Expand Down Expand Up @@ -860,7 +869,7 @@ final class LicensePluginJavaSpec extends Specification {
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style>body { font-family: sans-serif } pre { background-color: #eeeeee; padding: 1em; white-space: pre-wrap; word-break: break-word; display: inline-block }</style>
<title>Open source licenses</title>
</head>
Expand All @@ -871,12 +880,14 @@ final class LicensePluginJavaSpec extends Specification {
<a href="#1934118923">appcompat-v7 (26.1.0)</a>
<dl>
<dt>Copyright &copy; 20xx The original author or authors</dt>
<dd></dd>
</dl>
</li>
<li>
<a href="#1934118923">design (26.1.0)</a>
<dl>
<dt>Copyright &copy; 20xx The original author or authors</dt>
<dd></dd>
</dl>
</li>
<a name="1934118923"></a>
Expand Down Expand Up @@ -983,7 +994,7 @@ final class LicensePluginJavaSpec extends Specification {
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style>body { font-family: sans-serif } pre { background-color: #eeeeee; padding: 1em; white-space: pre-wrap; word-break: break-word; display: inline-block }</style>
<title>Open source licenses</title>
</head>
Expand All @@ -994,12 +1005,14 @@ final class LicensePluginJavaSpec extends Specification {
<a href="#1934118923">appcompat-v7 (26.1.0)</a>
<dl>
<dt>Copyright &copy; 20xx The original author or authors</dt>
<dd></dd>
</dl>
</li>
<li>
<a href="#1934118923">design (26.1.0)</a>
<dl>
<dt>Copyright &copy; 20xx The original author or authors</dt>
<dd></dd>
</dl>
</li>
<a name="1934118923"></a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ final class HtmlReportSpec extends Specification {
def actual = report.toString()
def expected =
"""
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style>body { font-family: sans-serif } pre { background-color: #eeeeee; padding: 1em; white-space: pre-wrap; word-break: break-word; display: inline-block }</style>
<title>Open source licenses</title>
</head>
<body>
<h3>None</h3>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style>body { font-family: sans-serif } pre { background-color: #eeeeee; padding: 1em; white-space: pre-wrap; word-break: break-word; display: inline-block }</style>
<title>Open source licenses</title>
</head>
<body>
<h3>None</h3>
</body>
</html>
"""

then:
Expand Down Expand Up @@ -74,7 +74,7 @@ final class HtmlReportSpec extends Specification {
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style>body { font-family: sans-serif } pre { background-color: #eeeeee; padding: 1em; white-space: pre-wrap; word-break: break-word; display: inline-block }</style>
<title>Open source licenses</title>
</head>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ final class TestUtils {
text = text.replaceAll('<br>', '<br/>')
text = text.replaceAll('<hr>', '<hr/>')
text = text.replaceAll('&copy;', '(c)')
text = text.replaceAll('<meta http-equiv="content-type" content="text/html; charset=utf-8">', '<meta http-equiv="content-type" content="text/html; charset=utf-8" />')
// Unicode code points being transformed strangely - normalize
text = text.replaceAll('Karol Wr.*niak', 'Karol WrXXniak')
return text
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ktlint = { id = "org.jlleitschuh.gradle.ktlint", version = "11.6.1" }
maven-publish = { id = "com.vanniktech.maven.publish", version = "0.27.0" }
plugin-publish = { id = "com.gradle.plugin-publish", version = "1.2.1" }
versions = { id = "com.github.ben-manes.versions", version = "0.51.0" }
license = { id = "com.jaredsburrows.license", version = "0.9.4" }

[libraries]
android-plugin = { module = "com.android.tools.build:gradle", version = "3.6.4" }
Expand Down

0 comments on commit c8e9310

Please sign in to comment.