htmlcheck

package
v1.17.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 20 Imported by: 0

README

HTML check

The database used for HTML support tests is based on can I email.

The caniemail-data.json file used to determine client support is copied from the API

Documentation

Overview

Package htmlcheck is used for parsing HTML and returning HTML compatibility errors and warnings

Index

Constants

This section is empty.

Variables

View Source
var (

	// LimitFamilies will limit results to families if set
	LimitFamilies = []string{}

	// LimitPlatforms will limit results to platforms if set
	LimitPlatforms = []string{}

	// LimitClients will limit results to clients if set
	LimitClients = []string{}
)

Functions

func Platforms

func Platforms() (map[string][]string, error)

Platforms returns all platforms with their respective email clients

Types

type CanIEmail

type CanIEmail struct {
	APIVersion     string `json:"api_version"`
	LastUpdateDate string `json:"last_update_date"`
	// NiceNames map[string]string `json:"last_update_date"`
	NiceNames struct {
		Family   map[string]string `json:"family"`
		Platform map[string]string `json:"platform"`
		Support  map[string]string `json:"support"`
		Category map[string]string `json:"category"`
	} `json:"nicenames"`
	Data []JSONResult `json:"data"`
}

CanIEmail struct for JSON data

type JSONResult

type JSONResult struct {
	Slug           string                 `json:"slug"`
	Title          string                 `json:"title"`
	Description    string                 `json:"description"`
	URL            string                 `json:"url"`
	Category       string                 `json:"category"`
	Tags           []string               `json:"tags"`
	Keywords       string                 `json:"keywords"`
	LastTestDate   string                 `json:"last_test_date"`
	TestURL        string                 `json:"test_url"`
	TestResultsURL string                 `json:"test_results_url"`
	Stats          map[string]interface{} `json:"stats"`
	Notes          string                 `json:"notes"`
	NotesByNumber  map[string]string      `json:"notes_by_num"`
}

JSONResult struct for CanIEmail Data

type Response

type Response struct {
	// List of warnings from tests
	Warnings []Warning `json:"Warnings"`
	// All platforms tested, mainly for the web UI
	Platforms map[string][]string `json:"Platforms"`
	// Total overall score
	Total Total `json:"Total"`
}

Response represents the HTML check response struct

swagger:model HTMLCheckResponse

func RunTests

func RunTests(html string) (Response, error)

RunTests will run all tests on an HTML string

type Result

type Result struct {
	// Friendly name of result, combining family, platform & version
	Name string `json:"Name"`
	// Platform eg: ios, android, windows
	Platform string `json:"Platform"`
	// Family eg: Outlook, Mozilla Thunderbird
	Family string `json:"Family"`
	// Family version eg: 4.7.1, 2019-10, 10.3
	Version string `json:"Version"`
	// Support [yes, no, partial]
	Support string `json:"Support"`
	// Note number for partially supported if applicable
	NoteNumber string `json:"NoteNumber"` // where applicable
}

Result struct

swagger:model HTMLCheckResult

type Score

type Score struct {
	// Number of matches in the document
	Found int `json:"Found"`
	// Total percentage supported
	Supported float32 `json:"Supported"`
	// Total percentage partially supported
	Partial float32 `json:"Partial"`
	// Total percentage unsupported
	Unsupported float32 `json:"Unsupported"`
}

Score struct

swagger:model HTMLCheckScore

type Total

type Total struct {
	// Total number of tests done
	Tests int `json:"Tests"`
	// Total number of HTML nodes detected in message
	Nodes int `json:"Nodes"`
	// Overall percentage supported
	Supported float32 `json:"Supported"`
	// Overall percentage partially supported
	Partial float32 `json:"Partial"` // total percentage
	// Overall percentage unsupported
	Unsupported float32 `json:"Unsupported"` // total percentage
}

Total weighted result for all scores

swagger:model HTMLCheckTotal

type Warning

type Warning struct {
	// Slug identifier
	Slug string `json:"Slug"`
	// Friendly title
	Title string `json:"Title"`
	// Description
	Description string `json:"Description"`
	// URL to caniemail.com
	URL string `json:"URL"`
	// Category [css, html]
	Category string `json:"Category"`
	// Tags
	Tags []string `json:"Tags"`
	// Keywords
	Keywords string `json:"Keywords"`
	// Test results
	Results []Result `json:"Results"`
	// Notes based on results
	NotesByNumber map[string]string `json:"NotesByNumber"`
	// Test score calculated from results
	Score Score `json:"Score"`
}

Warning represents a failed test

swagger:model HTMLCheckWarning

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL