mdspec

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Example
package main

import (
	"fmt"

	"github.com/KEINOS/go-md-spec-check/mdspec"
)

func main() {
	// Sample Markdown-to-HTML conversion function that does not do its job.
	myMarkdownParser := func(markdown string) (string, error) {
		// Do something with the given markdown and return the parsed HTML.
		parsedHTML := "<p>Hello, World!</p>"

		return parsedHTML, nil
	}

	// Check if the `myMarkdownParser()` complies with the CommonMark specification
	// version 0.30.
	err := mdspec.SpecCheck("v0.30", myMarkdownParser)
	if err != nil {
		fmt.Println(err.Error())
	}
}
Output:

error 1_Tabs: the given function did not return the expected HTML result.
given markdown: "\tfoo\tbaz\t\tbim\n"
expect HTML: "<pre><code>foo\tbaz\t\tbim\n</code></pre>\n"
actual HTML: "<p>Hello, World!</p>"

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListVersion

func ListVersion() ([]string, error)

ListVersion returns a list of all available versions of the specification.

Example
package main

import (
	"fmt"
	"log"

	"github.com/KEINOS/go-md-spec-check/mdspec"
)

func main() {
	list, err := mdspec.ListVersion()
	if err != nil {
		log.Fatal(err)
	}

	for _, v := range list {
		fmt.Println(v)
	}
}
Output:

v0.31.2
v0.30
v0.29
v0.28
v0.27
v0.26
v0.25
v0.24
v0.23
v0.22
v0.21
v0.20
v0.19
v0.18
v0.17
v0.16
v0.15
v0.14
v0.13

func SpecCheck

func SpecCheck(specVersion string, yourFunc func(string) (string, error)) error

SpecCheck checks if `yourFunc“ complies with the specified CommonMark version specification using official test cases.

Usage:

err := mdspec.SpecCheck("v1.14", myFunc)

Types

This section is empty.

Directories

Path Synopsis
This package downloads the test cases from the official spec repository.
This package downloads the test cases from the official spec repository.

Jump to

Keyboard shortcuts

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