Skip to content

.NET library that provides an API for html-validate NPM package

License

Notifications You must be signed in to change notification settings

atata-framework/atata-cli-htmlvalidate

Repository files navigation

Atata.Cli.HtmlValidate

NuGet GitHub release Build status Slack Atata docs Twitter

Atata.Cli.HtmlValidate is a .NET library that provides an API for html-validate NPM package.

The package targets .NET Standard 2.0, which supports .NET 5+, .NET Framework 4.6.1+ and .NET Core/Standard 2.0+.

Table of Contents

Features

Provides C#/.NET API for html-validate CLI. Check out https://html-validate.org documentation for more info.

Installation

NuGet Package

Install Atata.Cli.HtmlValidate NuGet package.

  • Package Manager:

    Install-Package Atata.Cli.HtmlValidate
    
  • .NET CLI:

    dotnet add package Atata.Cli.HtmlValidate
    

NPM Package

Requires html-validate NPM package to be installed.

  • Using NPM Command:
    npm install -g html-validate
    
  • Using Atata.Cli.Npm .NET library:
    new NpmCli()
        .InstallIfMissing(HtmlValidateCli.Name, global: true);
  • Using its own HtmlValidateCli class:
    new HtmlValidateCli()
        .RequireVersion("5.1.1");

Usage

The main class is HtmlValidateCli located in Atata.Cli.HtmlValidate namespace.

Validate HTML File

HtmlValidateResult result1 = HtmlValidateCli.InDirectory("some/dir")
    .Validate("testme.html");

Validate HTML File With Options

var options = new HtmlValidateOptions
{
    Config = "someconfig.json",
    Formatter = HtmlValidateFormatter.Codeframe("output.txt")
};

HtmlValidateResult result3 = HtmlValidateCli.InDirectory("some/dir")
    .Validate("testme.html", options);

Validate HTML File Asynchronously

HtmlValidateResult result2 = await HtmlValidateCli.InDirectory("some/dir")
    .ValidateAsync("testme.html");

HtmlValidateOptions Properties

  • HtmlValidateFormatter Formatter { get; set; }
    Gets or sets the formatter.
  • int? MaxWarnings { get; set; }
    Gets or sets the maximum allowed warnings count. The default value is null, which means that warnings are allowed. Use 0 to disallow warnings.
  • string Config { get; set; }
    Gets or sets the configuration file path (full or relative to CLI WorkingDirectory).
  • string[] Extensions { get; set; }
    Gets or sets the file extensions to use when searching for files in directories. For example: "html", "vue", etc.

HtmlValidateResult Properties

  • bool IsSuccessful { get; }
    Gets a value indicating whether this result is successful.
  • string Output { get; }
    Gets the text output of result.

Feedback

Any feedback, issues and feature requests are welcome.

If you faced an issue please report it to Atata.Cli.HtmlValidate Issues, ask a question on Stack Overflow using atata tag or use another Atata Contact way.

Thanks

The library is implemented thanks to the sponsorship of Lombiq Technologies.

SemVer

Atata Framework follows Semantic Versioning 2.0. Thus backward compatibility is followed and updates within the same major version (e.g. from 1.3 to 1.4) should not require code changes.

License

Atata is an open source software, licensed under the Apache License 2.0. See LICENSE for details.