Skip to content

Commit

Permalink
Release v1.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilafian committed Nov 10, 2023
1 parent a762a97 commit 1d3abd3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dist/w3c-html-validator.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! w3c-html-validator v1.6.0 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
//! w3c-html-validator v1.6.1 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License

export type ValidatorSettings = {
html: string;
Expand Down
14 changes: 8 additions & 6 deletions dist/w3c-html-validator.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
//! w3c-html-validator v1.6.0 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
//! w3c-html-validator v1.6.1 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License

import chalk from 'chalk';
import fs from 'fs';
import log from 'fancy-log';
import request from 'superagent';
import slash from 'slash';
const w3cHtmlValidator = {
version: '1.6.0',
version: '1.6.1',
validate(options) {
const defaults = {
checkUrl: 'https://validator.w3.org/nu/',
Expand All @@ -20,9 +21,10 @@ const w3cHtmlValidator = {
throw Error('[w3c-html-validator] Invalid ignoreLevel option: ' + settings.ignoreLevel);
if (settings.output !== 'json' && settings.output !== 'html')
throw Error('[w3c-html-validator] Option "output" must be "json" or "html".');
const mode = settings.html ? 'html' : settings.filename ? 'filename' : 'website';
const filename = settings.filename ? slash(settings.filename) : null;
const mode = settings.html ? 'html' : filename ? 'filename' : 'website';
const readFile = (filename) => fs.readFileSync(filename, 'utf-8').replace(/\r/g, '');
const inputHtml = settings.html ?? (settings.filename ? readFile(settings.filename) : null);
const inputHtml = settings.html ?? (filename ? readFile(filename) : null);
const makePostRequest = () => request.post(settings.checkUrl)
.set('Content-Type', 'text/html; encoding=utf-8')
.send(inputHtml);
Expand All @@ -35,7 +37,7 @@ const w3cHtmlValidator = {
const success = '<p class="success">';
const titleLookup = {
html: 'HTML String (characters: ' + inputHtml?.length + ')',
filename: settings.filename,
filename: filename,
website: settings.website,
};
const filterMessages = (response) => {
Expand All @@ -52,7 +54,7 @@ const w3cHtmlValidator = {
mode: mode,
title: titleLookup[mode],
html: inputHtml,
filename: settings.filename || null,
filename: filename,
website: settings.website || null,
output: settings.output,
status: response.statusCode || -1,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "w3c-html-validator",
"version": "1.6.0",
"version": "1.6.1",
"description": "Check the markup validity of HTML files using the W3C validator",
"license": "MIT",
"type": "module",
Expand Down

0 comments on commit 1d3abd3

Please sign in to comment.