Commit graph

115 commits

Author SHA1 Message Date
Abhinav Gupta
f98eb987aa Remove "testing" import from public interface
Currently, the DoTestCase, DoTestCaseFile, and DoTestCases functions,
are exposed as part of the public interface.

    func DoTestCase(m Markdown, testCase MarkdownTestCase, t *testing.T)
    func DoTestCaseFile(m Markdown, filename string, t *testing.T)
    func DoTestCases(m goldmark.Markdown, cases []MarkdownTestCase, t *testing.T)

Implementing these functions requires importing the `testing` package.
Importing the `testing` package [automatically registers][1] a number of
global [command line flags][2].

  [1]: https://golang.org/src/testing/testing.go#L252
  [2]: https://golang.org/cmd/go/#hdr-Testing_flags

The effect of this is that any application using the standard `flag`
package with goldmark will automatically get a number of unwanted
command line flags. This is verifiable with the following program,

    package main

    import (
    	"flag"

    	_ "github.com/yuin/goldmark"
    )

    func main() {
    	flag.Parse()
    }

To fix this, the `testing` import needs to be removed from all non-test
files. There are two ways to go about it,

- If the functions are meant for external use, you can define an
  interface with a subset of the methods of `testing.T` and switch the
  functions to consume that. This is what testing libraries like
  [gomock] and [testify] do.
- If the functions are meant for internal use, you can remove them from
  the public interface of the library and use them only from tests.

  [gomock]: https://godoc.org/github.com/golang/mock/gomock#TestReporter
  [testify]: https://godoc.org/github.com/stretchr/testify/require#TestingT

Since these functions are meant to be used by external extensions, I've
introduced a TestingT interface that is a subset of the functionality
provided by `testing.T`. It supports the standard operations: logging,
skiping, and failing tests,
2019-08-25 03:18:10 -07:00
Yusuke Inuzuka
d7e925c896
Merge pull request #23 from abhinav/iota-types
ast: Specify types for iota-based constants
2019-08-25 17:49:14 +09:00
Abhinav Gupta
45376ddb05 ast: Specify types for iota-based constants
Including the type of a constant improves discoverability because the
constant is listed next to the type in the godocs.

Before:

```
$ go doc -all . WalkStatus
type WalkStatus int
    WalkStatus represents a current status of the Walk function.
```

After:

```shell
$ go doc -all . WalkStatus
type WalkStatus int
    WalkStatus represents a current status of the Walk function.

const (
	// WalkStop indicates no more walking needed.
	WalkStop WalkStatus = iota + 1

	// WalkSkipChildren indicates that Walk wont walk on children of current
	// node.
	WalkSkipChildren

	// WalkContinue indicates that Walk can continue to walk.
	WalkContinue
)
```

This commit the `iota`-based constants in the AST package to follow
this.
2019-08-24 12:17:57 -07:00
Yusuke Inuzuka
b067a12f6b
Copied from #20 2019-08-20 18:33:01 +09:00
Yusuke Inuzuka
3190eb8348
Merge pull request #19 from b3log/master
Simplify logic
2019-08-16 18:17:17 +09:00
Liang Ding
e7035b1993
♻️ Remove redundant check 2019-08-10 00:39:46 +08:00
Liang Ding
008c258471
♻️ Simplify logic 2019-08-09 23:48:38 +08:00
Liang Ding
0c44174564
🎨 Remove redundant slice assignment 2019-08-09 23:46:25 +08:00
Yusuke Inuzuka
7950956e28
Merge pull request #18 from b3log/master
Fix some typos
2019-08-07 19:28:25 +09:00
Liang Ding
6f6884271d
✏️ Fix typos 2019-08-07 18:15:09 +08:00
Liang Ding
d29104889a
✏️ Fix some tyops in doc comments 2019-08-07 18:08:43 +08:00
Yusuke Inuzuka
17a47ea1e7
Update README.md 2019-07-26 10:32:48 +09:00
yuin
a27b0ef209 Fix bugs found in fuzzing 2019-07-25 16:59:07 +09:00
yuin
21b4a046d0 Fix bugs in footnotes 2019-07-24 20:55:37 +09:00
yuin
19b18e85fc Fix bug found in fuzzing 2019-07-24 20:16:54 +09:00
yuin
883918a85c Fix bugs found in fuzzing 2019-07-18 18:01:01 +09:00
Yusuke Inuzuka
36e42c4e73
Merge pull request #17 from litao91/fixlist
Fix inaccurate indent calculation of list_item and add extra test
2019-07-16 17:24:29 +09:00
LI Tao
6369ad43e8 Fix inaccurate indent calculation of list_item and add extra test to cover the case 2019-07-16 13:05:14 +08:00
Yusuke Inuzuka
032792ae55
Update README.md 2019-07-15 11:40:31 +09:00
Yusuke Inuzuka
b7348f0573
Merge pull request #14 from litao91/mathjax
Mention mathjax plugin in README.md
2019-07-15 11:39:05 +09:00
LI Tao
0fc2859377 Mention mathjax plugin in README.md 2019-07-15 05:59:08 +08:00
yuin
57c4df05d5 Merge branch 'master' of github.com:yuin/goldmark 2019-07-12 18:52:32 +09:00
yuin
dd1590372c Add a new attribute parser 2019-07-12 18:52:15 +09:00
Yusuke Inuzuka
8aee2d32fd
Update README.md 2019-07-09 17:43:07 +09:00
yuin
23ace7da03 Add goldmark-meta to the README 2019-05-30 18:31:55 +09:00
yuin
05645dd3c4 Add String node 2019-05-30 16:07:04 +09:00
yuin
7b1dd7b221 Issue #12 : dos style newline breaks fence code block 2019-05-23 11:27:25 +09:00
Yusuke Inuzuka
9b1570bcde
Merge pull request #10 from mironovalexey/patch-2
Update README.md
2019-05-19 14:50:01 +09:00
Alexey Mironov
9cf9f6802e
Update README.md
To simplify a copy-paste.
2019-05-19 07:41:10 +03:00
Yusuke Inuzuka
ddce9bf23e
Update README.md 2019-05-17 11:24:44 +09:00
Yusuke Inuzuka
3802559573
Merge pull request #9 from dertseha/patch-1
fixed typo
2019-05-17 11:23:30 +09:00
Christian Haas
8df88b3d75
fixed typo 2019-05-16 22:10:05 +02:00
yuin
4586ec683b Rename test function 2019-05-16 19:53:54 +09:00
yuin
f95910174c Merge branch 'master' of https://github.com/yuin/goldmark 2019-05-16 19:47:05 +09:00
yuin
2ddc99baff Add extension tests, Fix bugs in extensions 2019-05-16 19:46:36 +09:00
Yusuke Inuzuka
7d92c09d44
Update README.md 2019-05-16 12:40:01 +09:00
yuin
1963434c50 Fix some vet errors, Improve attributes on ATXHeadings 2019-05-16 12:37:49 +09:00
yuin
e481813300 Issue #4: Fix invalid leading spaces with attributes 2019-05-15 23:06:08 +09:00
yuin
6703518300 Issue #4: Fix invalid leading spaces with attributes 2019-05-15 22:56:52 +09:00
Yusuke Inuzuka
e59897f8e5
Merge pull request #6 from mironovalexey/patch-1
Update README.md
2019-05-15 18:14:40 +09:00
Alexey Mironov
4febcc9861
Update README.md
It seems that this function has changed its name.
2019-05-15 12:11:49 +03:00
yuin
4ff89123a4 Issue #5 : Fixed 'index out of range' error when FilterTags exists 2019-05-15 17:54:37 +09:00
yuin
31fd0f6b4c Issue #3 : failed to parse attributes 2019-05-15 17:43:57 +09:00
yuin
2988e183ed Issue #2 : EOF breaks parsing 2019-05-15 00:56:22 +09:00
yuin
ad605c0a32 Performance optimizations 2019-05-06 12:34:17 +09:00
yuin
d9164d2556 Rename options names 2019-05-06 01:14:17 +09:00
yuin
28b28e34bb Add Typographer extension 2019-05-06 00:53:22 +09:00
yuin
08a89f162a Refactoring 2019-05-05 15:08:50 +09:00
yuin
00356b97b1 Fix typo 2019-05-05 13:43:49 +09:00
yuin
785421acb4 Add WithAttribute 2019-05-05 13:42:39 +09:00