From b9368b576d3b380b87e07d5dc5433d3485282dab Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Tue, 18 Nov 2025 17:16:49 +0100 Subject: [PATCH] Lint and format the HTML in using Prettier The linter found some issues in viewer.html with which isn't required and a missing closing div in test/resources/reftest-analyzer.html. The HTML can now be nicely formatted. In order to not break the build for mozilla-central, the preprocessor has been fixed in order to take into account the white spaces at the beginning of a comment line. And finally, make .prettierrc (which is supposed to be either json or yaml) itself lintable. --- .prettierrc | 15 +- examples/components/pageviewer.html | 42 +- examples/components/simpleviewer.html | 58 +- examples/components/singlepageviewer.html | 58 +- examples/image_decoders/jpeg_viewer.html | 38 +- examples/learning/helloworld.html | 123 ++-- examples/learning/helloworld64.html | 134 ++--- examples/learning/prevnext.html | 235 ++++---- examples/mobile-viewer/viewer.html | 14 +- examples/text-only/index.html | 17 +- examples/webpack/index.html | 18 +- extensions/chromium/options/options.html | 312 +++++----- external/builder/builder.mjs | 4 +- gulpfile.mjs | 5 +- test/font/font_test.html | 37 +- test/resources/reftest-analyzer.html | 263 ++++----- test/test_slave.html | 18 +- test/unit/unit_test.html | 93 ++- web/viewer-geckoview.html | 61 +- web/viewer-snippet-chrome-extension.html | 4 +- web/viewer-snippet-chrome-overlays.html | 16 +- web/viewer-snippet.html | 2 +- web/viewer.html | 687 +++++++++++++++++----- 23 files changed, 1306 insertions(+), 948 deletions(-) diff --git a/.prettierrc b/.prettierrc index 3455ffe60..49e6b8e7e 100644 --- a/.prettierrc +++ b/.prettierrc @@ -9,10 +9,17 @@ "overrides": [ { - files: ["tsconfig.json"], - options: { - parser: "json", - }, + "files": ["tsconfig.json", ".prettierrc"], + "options": { + "parser": "json" + } }, + { + "files": ["**/*.html"], + "options": { + "parser": "html", + "printWidth": 160 + } + } ] } diff --git a/examples/components/pageviewer.html b/examples/components/pageviewer.html index 267f8cc29..76f7e3684 100644 --- a/examples/components/pageviewer.html +++ b/examples/components/pageviewer.html @@ -1,4 +1,4 @@ - + - - - - - PDF.js page viewer using built components + + + + + PDF.js page viewer using built components - + - + - - - + + + - -
+ +
- - + + diff --git a/examples/components/simpleviewer.html b/examples/components/simpleviewer.html index e6493263d..8504062d5 100644 --- a/examples/components/simpleviewer.html +++ b/examples/components/simpleviewer.html @@ -1,4 +1,4 @@ - + - - - - - PDF.js viewer using built components + + + + + PDF.js viewer using built components - + - + - - - + + + - -
-
-
+ +
+
+
- - + + diff --git a/examples/components/singlepageviewer.html b/examples/components/singlepageviewer.html index 3636dbe77..3e71aad80 100644 --- a/examples/components/singlepageviewer.html +++ b/examples/components/singlepageviewer.html @@ -1,4 +1,4 @@ - + - - - - - PDF.js Single Page Viewer using built components + + + + + PDF.js Single Page Viewer using built components - + - + - - - + + + - -
-
-
+ +
+
+
- - + + diff --git a/examples/image_decoders/jpeg_viewer.html b/examples/image_decoders/jpeg_viewer.html index 87f757bd6..a120efedd 100644 --- a/examples/image_decoders/jpeg_viewer.html +++ b/examples/image_decoders/jpeg_viewer.html @@ -1,4 +1,4 @@ - + - - - - - PDF.js standalone JpegImage parser + + + + + PDF.js standalone JpegImage parser - + - - + + - - + + - - + + diff --git a/examples/learning/helloworld.html b/examples/learning/helloworld.html index 6a74298f8..028fb015f 100644 --- a/examples/learning/helloworld.html +++ b/examples/learning/helloworld.html @@ -1,76 +1,71 @@ - + - - - 'Hello, world!' example - - + + + 'Hello, world!' example + + +

'Hello, world!' example

-

'Hello, world!' example

+ - + - + - // - // Render PDF page into canvas context - // - const renderContext = { - canvasContext: context, - transform, - viewport, - }; - page.render(renderContext); - - -
-

JavaScript code:

-

-
-
+    
+

JavaScript code:

+

+    
+  
 
diff --git a/examples/learning/helloworld64.html b/examples/learning/helloworld64.html
index ed98e189f..5b833a2db 100644
--- a/examples/learning/helloworld64.html
+++ b/examples/learning/helloworld64.html
@@ -1,81 +1,77 @@
-
+
 
-
-  
-  'Hello, world!' base64 example
-
-
+  
+    
+    'Hello, world!' base64 example
+  
+  
+    

'Hello, world!' example

-

'Hello, world!' example

+ - + - + - // Render PDF page into canvas context. - var renderContext = { - canvasContext: context, - transform, - viewport, - }; - page.render(renderContext); - - -
-

JavaScript code:

-

-
-
+    
+

JavaScript code:

+

+    
+  
 
diff --git a/examples/learning/prevnext.html b/examples/learning/prevnext.html
index e1043bf1e..5249d32aa 100644
--- a/examples/learning/prevnext.html
+++ b/examples/learning/prevnext.html
@@ -1,139 +1,134 @@
-
+
 
-
-  
-  Previous/Next example
-
-
+  
+    
+    Previous/Next example
+  
+  
+    

'Previous/Next' example

-

'Previous/Next' example

+
+ + +     + Page: / +
-
- - -     - Page: / -
+
+ +
-
- -
+ - + - - + // Initial/first page rendering + renderPage(pageNum); + + diff --git a/examples/mobile-viewer/viewer.html b/examples/mobile-viewer/viewer.html index 6bd8b5406..1812db948 100644 --- a/examples/mobile-viewer/viewer.html +++ b/examples/mobile-viewer/viewer.html @@ -1,4 +1,4 @@ - + - - + + PDF.js viewer - - + + @@ -46,12 +46,12 @@ limitations under the License. - + - + diff --git a/examples/text-only/index.html b/examples/text-only/index.html index 2acbd553e..410307cc8 100644 --- a/examples/text-only/index.html +++ b/examples/text-only/index.html @@ -1,14 +1,13 @@ - + - - + + Text-only PDF.js example - - -

Text-only PDF.js example

-
-
- + + +

Text-only PDF.js example

+
+ diff --git a/examples/webpack/index.html b/examples/webpack/index.html index ed25387f2..a9ba7bd12 100644 --- a/examples/webpack/index.html +++ b/examples/webpack/index.html @@ -1,11 +1,11 @@ - + - - - webpack example - - - - - + + + webpack example + + + + + diff --git a/extensions/chromium/options/options.html b/extensions/chromium/options/options.html index bd18c2456..e83db6c62 100644 --- a/extensions/chromium/options/options.html +++ b/extensions/chromium/options/options.html @@ -15,171 +15,171 @@ See the License for the specific language governing permissions and limitations under the License. --> - - -PDF.js viewer options - - - -
- + + + PDF.js viewer options + + + +
+ - + - + - + - + - + - + - + - + - + - + - - + + diff --git a/external/builder/builder.mjs b/external/builder/builder.mjs index 929a9cf87..b81ee107d 100644 --- a/external/builder/builder.mjs +++ b/external/builder/builder.mjs @@ -151,7 +151,7 @@ function preprocess(inFilename, outFilename, defines) { let state = STATE_NONE; const stack = []; const control = - /^(?:\/\/|\s*\/\*|)?$)?/; + /^(?:\/\/|\s*\/\*|\s*)?$)?/; while ((line = readLine()) !== null) { ++lineNumber; @@ -213,7 +213,7 @@ function preprocess(inFilename, outFilename, defines) { ) { writeLine( line - .replaceAll(/^\/\/|^$/g, "") ); diff --git a/gulpfile.mjs b/gulpfile.mjs index 196f5f214..9717a334a 100644 --- a/gulpfile.mjs +++ b/gulpfile.mjs @@ -2023,7 +2023,7 @@ gulp.task( gulp.task("lint", function (done) { console.log(); - console.log("### Linting JS/CSS/JSON/SVG files"); + console.log("### Linting JS/CSS/JSON/SVG/HTML files"); // Ensure that we lint the Firefox specific *.jsm files too. const esLintOptions = [ @@ -2047,9 +2047,10 @@ gulp.task("lint", function (done) { const prettierOptions = [ "node_modules/prettier/bin/prettier.cjs", "**/*.json", + "**/*.html", ]; if (process.argv.includes("--fix")) { - prettierOptions.push("--log-level", "silent", "--write"); + prettierOptions.push("--log-level", "error", "--write"); } else { prettierOptions.push("--log-level", "warn", "--check"); } diff --git a/test/font/font_test.html b/test/font/font_test.html index c8b09b700..4b8d5abcd 100644 --- a/test/font/font_test.html +++ b/test/font/font_test.html @@ -1,25 +1,24 @@ - + - - PDF.js font tests + + PDF.js font tests - + - - + + - - - - - + + + + diff --git a/test/resources/reftest-analyzer.html b/test/resources/reftest-analyzer.html index 00f9eaa0d..2dcc77421 100644 --- a/test/resources/reftest-analyzer.html +++ b/test/resources/reftest-analyzer.html @@ -1,4 +1,4 @@ - + - - Reftest analyzer - - - - - -
-

Reftest analyzer

-

- Paste your log into this textarea:
-
- -

-

-
...or load it from a file:
- -

-
-
Loading log...
-
-
-
- - - - - - - - - - - - - - - - - -
Pixel at:
Test:
Reference:
-
-
? -
-

Move the mouse over the reftest image on the right to show - magnified pixels on the left. The color information above is for - the pixel centered in the magnified view.

-

The test is shown in the upper triangle of each pixel and - the reference is shown in the lower triangle.

+ + Reftest analyzer + + + + + +
+

Reftest analyzer

+

+ Paste your log into this textarea:
+
+ +

+

+
...or load it from a file:
+ +

+
+
Loading log...
+
+
+
+ + + + + + + + + + + + + + + + + +
Pixel at:
Test:
Reference:
+
+
+ ? +
+

+ Move the mouse over the reftest image on the right to show magnified pixels on the left. The color information above is for the pixel centered + in the magnified view. +

+

The test is shown in the upper triangle of each pixel and the reference is shown in the lower triangle.

+
+
+ + + +
-
- - - +
+
-
-
-
-
-
-
- - - - Shortcuts: n=next p=previous t=toggle d=differences -
-
- - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - + + + + - - + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + +
+
-
- + diff --git a/test/test_slave.html b/test/test_slave.html index 8d202ce37..b8eb0beea 100644 --- a/test/test_slave.html +++ b/test/test_slave.html @@ -1,4 +1,4 @@ - + - - + + PDF.js viewer - - - + + + - - - - - - + + + + + + - - - + + + - + - - - - + + +
-
-
+
+
@@ -119,16 +117,21 @@ See https://github.com/adobe-type-tools/cmap-resources
- +
- - + +
-
- -
+
+ +
+
diff --git a/web/viewer-snippet-chrome-extension.html b/web/viewer-snippet-chrome-extension.html index 5c8b404c8..3187cd495 100644 --- a/web/viewer-snippet-chrome-extension.html +++ b/web/viewer-snippet-chrome-extension.html @@ -1,4 +1,4 @@ - - + + diff --git a/web/viewer-snippet-chrome-overlays.html b/web/viewer-snippet-chrome-overlays.html index 1089963d1..fff0eb2f3 100644 --- a/web/viewer-snippet-chrome-overlays.html +++ b/web/viewer-snippet-chrome-overlays.html @@ -4,7 +4,9 @@ users with recognizing which checkbox they have to click when they visit chrome://extensions. --> -

- Click on - "Allow access to file URLs" - at + word-break: break-all; + " + > + Click on "Allow access to file URLs" at chrome://extensions -
+
to view this PDF file.

or select the file again: - +

diff --git a/web/viewer-snippet.html b/web/viewer-snippet.html index 3baf94773..15d0d71a4 100644 --- a/web/viewer-snippet.html +++ b/web/viewer-snippet.html @@ -1,3 +1,3 @@ - + diff --git a/web/viewer.html b/web/viewer.html index 1ee1a4c4e..e56f02441 100644 --- a/web/viewer.html +++ b/web/viewer.html @@ -1,4 +1,4 @@ - + - - - - - + + + + + PDF.js viewer - - - - - - - + + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - + @@ -105,17 +105,53 @@ See https://github.com/adobe-type-tools/cmap-resources
- - - -
@@ -124,42 +160,63 @@ See https://github.com/adobe-type-tools/cmap-resources
-
-
-
- - - +
+ + +
- + +
-
- +
- +
@@ -231,7 +298,14 @@ See https://github.com/adobe-type-tools/cmap-resources - + @@ -246,7 +320,17 @@ See https://github.com/adobe-type-tools/cmap-resources
-
- +
- +
- +
-
-
- +
-
-
+
@@ -495,7 +757,8 @@ See https://github.com/adobe-type-tools/cmap-resources
-
+
+
@@ -503,7 +766,7 @@ See https://github.com/adobe-type-tools/cmap-resources
- +
@@ -583,7 +846,7 @@ See https://github.com/adobe-type-tools/cmap-resources
- +
@@ -597,7 +860,7 @@ See https://github.com/adobe-type-tools/cmap-resources
- +
@@ -606,7 +869,9 @@ See https://github.com/adobe-type-tools/cmap-resources
- +
@@ -621,17 +886,43 @@ See https://github.com/adobe-type-tools/cmap-resources
- +
-
+
+
+ + +
+
- +
@@ -640,15 +931,23 @@ See https://github.com/adobe-type-tools/cmap-resources
- +
- +
- - - + + +
@@ -667,7 +966,15 @@ See https://github.com/adobe-type-tools/cmap-resources
- + +
@@ -677,8 +984,12 @@ See https://github.com/adobe-type-tools/cmap-resources
- - + + @@ -696,7 +1007,9 @@ See https://github.com/adobe-type-tools/cmap-resources
- +
@@ -708,13 +1021,37 @@ See https://github.com/adobe-type-tools/cmap-resources
- - - + + +
- +
@@ -722,7 +1059,17 @@ See https://github.com/adobe-type-tools/cmap-resources
- +
@@ -733,7 +1080,7 @@ See https://github.com/adobe-type-tools/cmap-resources - +
@@ -741,14 +1088,16 @@ See https://github.com/adobe-type-tools/cmap-resources
- +
- +
- + @@ -760,58 +1109,68 @@ See https://github.com/adobe-type-tools/cmap-resources
- +
- - + +
- + - -
-
- -
-
-
- - - - - + +
+
+ +
+
+
+ + + + + +
+ +
+
+ +
-
-
- - -
-
-
+ - -
-
- + +
+
+ +
+ +
+ + +
- -
- - -
-
-
+ - - + +
@@ -823,11 +1182,12 @@ See https://github.com/adobe-type-tools/cmap-resources
- - - - - + + + + + + - - + + + +