Skip to content

Commit

Permalink
Fix for lines-less remaining node
Browse files Browse the repository at this point in the history
  • Loading branch information
sourishkrout committed Oct 4, 2022
1 parent 1778dde commit ee0a340
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions internal/renderer/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ func (r *renderer) GetDocument(source []byte, n ast.Node) (document, error) {
return document{}, err
}

if remainingNode != nil && remainingNode.Lines().Len() == 0 {
remainingNode = remainingNode.NextSibling()
}

if remainingNode != nil {
start := remainingNode.Lines().At(0).Start
stop := len(source) - 1
Expand Down
2 changes: 1 addition & 1 deletion internal/renderer/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/yuin/goldmark/text"
)

var testCases = []string{"happy", "simple"}
var testCases = []string{"happy", "simple", "linesless"}

func TestParser_Renderer(t *testing.T) {
snapshotter := cupaloy.New(cupaloy.SnapshotSubdirectory("testdata/.snapshots"))
Expand Down
9 changes: 9 additions & 0 deletions internal/renderer/testdata/linesless.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
To deploy to production, run:

```sh
deployctl deploy --project=runme main.ts
```

---

<p align="center"><small>Copyright 2022 © <a href="http://stateful.com/">Stateful</a> – Apache 2.0 License</small></p>

0 comments on commit ee0a340

Please sign in to comment.