go-md-spec-check

module
v0.0.1-beta Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2022 License: MIT

README

Markdown Specification Checker for Go

Go Reference

go-md-spec-check is a simple golang package that checks if a function can convert Markdown to HTML according to the CommonMark specification.

// go 1.16+
go get github.com/KEINOS/go-md-spec-check

In the below example, mdspec.SpecCheck() runs myMarkdownParser() against about 500-600 test cases and checks that the results comply with the given version of the CommonMark specification.

import (
  "fmt"
  "log"

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

func Example() {
    // Sample Markdown-to-HTML conversion function that does not do its job.
    myMarkdownParser := func(markdown string) (string, error) {
        return "<p>Hello, World!</p>", nil
    }

    // Check if the `myMarkdownParser()` complies with the CommonMark specification
    // version 0.30.
    // Choices: "v0.13", "v0.14" ... "v0.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>"
}

Statuses

UnitTests PlatformTests golangci-lint CodeQL-Analysis

codecov Go Report Card Weekly Update

Contributing

Go Reference Opened Issues PR

We are open to anything that helps us improve.

  • Branch to PR: main
  • Report an issue: issues @ GitHub
    • Please attach reproducible test cases.

Directories

Path Synopsis
_specs
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