From 9e83faa02c136da9e4749b696d8c7a0b363c0745 Mon Sep 17 00:00:00 2001
From: toasted-nutbread
Date: Sat, 30 Jan 2021 20:44:54 -0500
Subject: Html lint (#1336)
* Move style rules
* Fix non-unique IDs
* Remove erroneous ids
* Add title
* Fix invalid closing tag
* Install html-validate
* Add .htmlvalidate.json
* Update HTML and styles
* Add test-lint-html
* Update test files
* Update test-lint-html/css commands to have more explicit targets
---
.github/workflows/ci.yml | 4 +
.htmlvalidate.json | 18 ++
ext/bg/background.html | 3 +-
ext/bg/css/settings2.css | 25 +-
ext/bg/js/permissions-main.js | 4 +-
ext/bg/legal.html | 6 -
ext/bg/permissions.html | 4 +-
ext/bg/pitch-accents-preview.html | 2 +-
ext/bg/search.html | 2 +-
ext/bg/settings.html | 18 +-
ext/bg/settings2.html | 31 +-
ext/bg/template-renderer.html | 2 +-
ext/bg/welcome.html | 8 -
ext/fg/float.html | 2 +-
ext/mixed/display-templates.html | 10 +-
package-lock.json | 473 ++++++++++++++++++++++++++++++
package.json | 6 +-
test/data/html/test-document1.html | 10 +-
test/data/html/test-document2-frame1.html | 2 +-
test/data/html/test-document2.html | 14 +-
test/data/html/test-document3-frame1.html | 4 +-
test/data/html/test-document3-frame2.html | 4 +-
test/data/html/test-document3.html | 6 +-
test/data/html/test-dom-text-scanner.html | 8 +-
24 files changed, 578 insertions(+), 88 deletions(-)
create mode 100644 .htmlvalidate.json
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index c8b2adef..d928ffa1 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -23,6 +23,10 @@ jobs:
run: npm run test-lint-css
env:
CI: true
+ - name: Lint HTML
+ run: npm run test-lint-html
+ env:
+ CI: true
- name: Tests
run: npm run test-code
env:
diff --git a/.htmlvalidate.json b/.htmlvalidate.json
new file mode 100644
index 00000000..bb3c5221
--- /dev/null
+++ b/.htmlvalidate.json
@@ -0,0 +1,18 @@
+{
+ "root": true,
+ "extends": [
+ "html-validate:recommended"
+ ],
+ "rules": {
+ "element-required-attributes": "off",
+ "element-permitted-content": "off",
+ "text-content": "off",
+ "void-style": ["error", {"style": "omit"}],
+ "empty-heading": "off",
+ "wcag/h30": "off",
+ "no-inline-style": "off"
+ },
+ "elements": [
+ "html5"
+ ]
+}
\ No newline at end of file
diff --git a/ext/bg/background.html b/ext/bg/background.html
index 29cae072..29cd1d85 100644
--- a/ext/bg/background.html
+++ b/ext/bg/background.html
@@ -2,7 +2,7 @@
-
+
Background
@@ -53,6 +53,7 @@
This element must appear directly inside the element, and it must not be closed properly.
https://bugzilla.mozilla.org/show_bug.cgi?id=1603985
-->
+
diff --git a/ext/bg/css/settings2.css b/ext/bg/css/settings2.css
index 01c19af4..c0751d47 100644
--- a/ext/bg/css/settings2.css
+++ b/ext/bg/css/settings2.css
@@ -150,6 +150,10 @@ code {
label {
cursor: pointer;
}
+pre {
+ white-space: pre-wrap;
+ margin: 0;
+}
/* Text styles */
@@ -1462,15 +1466,8 @@ button.anki-card-field-value-menu-button {
border-collapse: collapse;
border-spacing: 0;
}
-.anki-field-marker-info-table>thead {
- font-weight: bold;
-}
-code.anki-field-marker {
- white-space: nowrap;
- font-size: 0.85em;
+.anki-field-marker-info-table tr.anki-field-marker-info-table-heading {
font-weight: bold;
-}
-.anki-field-marker-info-table thead tr {
background-color: var(--input-background-color);
}
.anki-field-marker-info-table td {
@@ -1485,6 +1482,11 @@ code.anki-field-marker {
.anki-field-marker-info-table td:nth-last-child(n+2) {
border-right: none;
}
+code.anki-field-marker {
+ white-space: nowrap;
+ font-size: 0.85em;
+ font-weight: bold;
+}
.anki-card-templates-layout {
display: flex;
@@ -1948,6 +1950,13 @@ input.sentence-termination-character-input2 {
padding-left: 0.375em;
}
+.inline-icon {
+ position: relative;
+ width: calc(1em * (16 / var(--font-size-no-units)));
+ height: calc(1em * (16 / var(--font-size-no-units)));
+ top: calc(1em * (3 / var(--font-size-no-units)));
+}
+
/* Generic layouts */
.margin-above {
diff --git a/ext/bg/js/permissions-main.js b/ext/bg/js/permissions-main.js
index cd03dd72..366a057b 100644
--- a/ext/bg/js/permissions-main.js
+++ b/ext/bg/js/permissions-main.js
@@ -82,7 +82,9 @@ async function updatePermissionCheckbox(checkbox, permissions, value) {
const documentFocusController = new DocumentFocusController();
documentFocusController.prepare();
- document.querySelector('#extension-id-example').textContent = chrome.runtime.getURL('/');
+ for (const node of document.querySelectorAll('.extension-id-example')) {
+ node.textContent = chrome.runtime.getURL('/');
+ }
api.forwardLogsToBackend();
await yomichan.prepare();
diff --git a/ext/bg/legal.html b/ext/bg/legal.html
index 85d782a5..3a829abb 100644
--- a/ext/bg/legal.html
+++ b/ext/bg/legal.html
@@ -13,12 +13,6 @@
-
diff --git a/ext/bg/permissions.html b/ext/bg/permissions.html
index 05266b22..57b4b215 100644
--- a/ext/bg/permissions.html
+++ b/ext/bg/permissions.html
@@ -55,7 +55,7 @@
as this can be used to fingerprint browser configuration.
- Example: Origin:
+ Example: Origin:
@@ -70,7 +70,7 @@
as this can be used to fingerprint browser configuration.
- Example: Origin:
+ Example: Origin:
diff --git a/ext/bg/pitch-accents-preview.html b/ext/bg/pitch-accents-preview.html
index 3adae422..b449222b 100644
--- a/ext/bg/pitch-accents-preview.html
+++ b/ext/bg/pitch-accents-preview.html
@@ -35,7 +35,7 @@
Graph -
-