Skip to content

Commit

Permalink
User MDeiml/tree-sitter-markdown as markdown grammar instead
Browse files Browse the repository at this point in the history
  • Loading branch information
FeiyouG committed Aug 9, 2022
1 parent 288f3d6 commit 4608d44
Show file tree
Hide file tree
Showing 42 changed files with 129,341 additions and 59,230 deletions.
35,365 changes: 0 additions & 35,365 deletions markdown/parser.c

This file was deleted.

322 changes: 0 additions & 322 deletions markdown/scanner.cc

This file was deleted.

15 changes: 15 additions & 0 deletions markdown/tree-sitter-markdown-inline/binding.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package markdown_inline

//#include "parser.h"
//TSLanguage *tree_sitter_markdown_inline();
import "C"
import (
"unsafe"

sitter "github.com/smacker/go-tree-sitter"
)

func GetLanguage() *sitter.Language {
ptr := unsafe.Pointer(C.tree_sitter_markdown_inline())
return sitter.NewLanguage(ptr)
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package markdown_test
package markdown_inline_test

import (
"context"
"testing"

sitter "github.com/smacker/go-tree-sitter"
"github.com/smacker/go-tree-sitter/markdown"
"github.com/smacker/go-tree-sitter/markdown/tree-sitter-markdown-inline"
"github.com/stretchr/testify/assert"
)

func TestGrammar(t *testing.T) {
assert := assert.New(t)

n, err := sitter.ParseCtx(context.Background(), []byte("# This is a header"), markdown.GetLanguage())
n, err := sitter.ParseCtx(context.Background(), []byte("# This is a heading"), markdown_inline.GetLanguage())
assert.NoError(err)
assert.Equal(
"(document (atx_heading (atx_h1_marker) (heading_content (text))))",
"(inline)",
n.String(),
)
}
Loading

0 comments on commit 4608d44

Please sign in to comment.