Skip to content

KEINOS/go-md-spec-check

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go1.18+ Go Reference

Markdown Specification Checker for Go

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

Usage

// Download module (go 1.18+)
go get github.com/KEINOS/go-md-spec-check
// Import package
import "github.com/KEINOS/go-md-spec-check/mdspec"

In the below example, mdspec.SpecCheck() runs myMarkdownParser() against about 500-600 test cases over the CommonMark v0.30 specification. And returns the first error encountered that does not comply with 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>"
}

Contributing

go1.18+ Go Reference Opened Issues PR

We are open to anything that helps us improve. We have 100% test coverage, so feel free to play with the code!

  • Branch to PR: main
  • Report an issue: issues @ GitHub
    • Please attach reproducible test cases. It helps us a lot.

Statuses

UnitTests PlatformTests golangci-lint CodeQL-Analysis

codecov Go Report Card Weekly Update

License, copyright and credits

About

A simple Markdown specification checker for Go. (Ensure compliance with the "CommonMark")

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Languages