mirror of https://github.com/dirtbags/moth.git
Enable table and dictonary markdown extensions
This commit is contained in:
parent
b31036960b
commit
1c2dd4695f
|
@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
It still works the same way if you register a team in `teamids.txt`,
|
||||
but now you can use anything and it will put you on an already existing team
|
||||
named `<devel:$ID>`.
|
||||
- switched from `blackfriday` to `goldmark`, to support CommonMark
|
||||
|
||||
## [v4.0.2] - 2020-10-29
|
||||
### Added
|
||||
|
|
|
@ -24,6 +24,21 @@ answer: RFC822 answer
|
|||
|
||||
RFC822 body
|
||||
`)
|
||||
var testMothMarkdown = []byte(`---
|
||||
answers:
|
||||
- answer
|
||||
pre:
|
||||
authors:
|
||||
- Fred
|
||||
---
|
||||
|
||||
one | two
|
||||
--- | ---
|
||||
1 | 2
|
||||
|
||||
Term
|
||||
: definition of that term
|
||||
`)
|
||||
|
||||
func newTestFs() afero.Fs {
|
||||
fs := afero.NewMemMapFs()
|
||||
|
@ -31,7 +46,7 @@ func newTestFs() afero.Fs {
|
|||
afero.WriteFile(fs, "cat0/1/moo.txt", []byte("Moo."), 0644)
|
||||
afero.WriteFile(fs, "cat0/2/puzzle.md", testMothRfc822, 0644)
|
||||
afero.WriteFile(fs, "cat0/3/puzzle.moth", testMothYaml, 0644)
|
||||
afero.WriteFile(fs, "cat0/4/puzzle.md", testMothYaml, 0644)
|
||||
afero.WriteFile(fs, "cat0/4/puzzle.md", testMothMarkdown, 0644)
|
||||
afero.WriteFile(fs, "cat0/5/puzzle.md", testMothYaml, 0644)
|
||||
afero.WriteFile(fs, "cat0/10/puzzle.md", []byte(`---
|
||||
Answers:
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
|
||||
"github.com/spf13/afero"
|
||||
"github.com/yuin/goldmark"
|
||||
"github.com/yuin/goldmark/extension"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
|
@ -285,7 +286,14 @@ func (fp FsPuzzle) staticPuzzle() (StaticPuzzle, []byte, error) {
|
|||
}
|
||||
|
||||
body := new(bytes.Buffer)
|
||||
goldmark.Convert(bodyBuf.Bytes(), body)
|
||||
|
||||
md := goldmark.New(
|
||||
goldmark.WithExtensions(
|
||||
extension.Table,
|
||||
extension.DefinitionList,
|
||||
),
|
||||
)
|
||||
md.Convert(bodyBuf.Bytes(), body)
|
||||
|
||||
return static, body.Bytes(), err
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package transpile
|
|||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/afero"
|
||||
|
@ -63,6 +64,14 @@ func TestPuzzle(t *testing.T) {
|
|||
t.Error("Legacy `puzzle.moth` file:", err)
|
||||
}
|
||||
|
||||
if puzzle, err := NewFsPuzzlePoints(catFs, 4).Puzzle(); err != nil {
|
||||
t.Error("Markdown test file:", err)
|
||||
} else if !strings.Contains(puzzle.Pre.Body, "<table>") {
|
||||
t.Error("Markdown table extension isn't making tables")
|
||||
} else if !strings.Contains(puzzle.Pre.Body, "<dl>") {
|
||||
t.Error("Markdown dictionary extension isn't making tables")
|
||||
}
|
||||
|
||||
if _, err := NewFsPuzzlePoints(catFs, 99).Puzzle(); err == nil {
|
||||
t.Error("Non-existent puzzle", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue