-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(parser/renderer): support the menu inline macro
Only if `experimental` attribute is set Fixes #940 Signed-off-by: Xavier Coulon <[email protected]>
- Loading branch information
Showing
13 changed files
with
8,442 additions
and
8,074 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
package parser_test | ||
|
||
import ( | ||
"github.com/bytesparadise/libasciidoc/pkg/types" | ||
. "github.com/bytesparadise/libasciidoc/testsupport" | ||
|
||
. "github.com/onsi/ginkgo" // nolint:golint | ||
. "github.com/onsi/gomega" // nolint:golintt | ||
) | ||
|
||
var _ = Describe("inline menus", func() { | ||
|
||
Context("in final documents", func() { | ||
|
||
It("with main path", func() { | ||
source := `:experimental: | ||
Select menu:File[].` | ||
expected := &types.Document{ | ||
Elements: []interface{}{ | ||
&types.DocumentHeader{ | ||
Elements: []interface{}{ | ||
&types.AttributeDeclaration{ | ||
Name: "experimental", | ||
}, | ||
}, | ||
}, | ||
&types.Paragraph{ | ||
Elements: []interface{}{ | ||
&types.StringElement{ | ||
Content: "Select ", | ||
}, | ||
&types.InlineMenu{ | ||
Path: []string{ | ||
"File", | ||
}, | ||
}, | ||
&types.StringElement{ | ||
Content: ".", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
Expect(ParseDocument(source)).To(MatchDocument(expected)) | ||
}) | ||
|
||
It("with single sub path", func() { | ||
source := `:experimental: | ||
Select menu:File[Save].` | ||
expected := &types.Document{ | ||
Elements: []interface{}{ | ||
&types.DocumentHeader{ | ||
Elements: []interface{}{ | ||
&types.AttributeDeclaration{ | ||
Name: "experimental", | ||
}, | ||
}, | ||
}, | ||
&types.Paragraph{ | ||
Elements: []interface{}{ | ||
&types.StringElement{ | ||
Content: "Select ", | ||
}, | ||
&types.InlineMenu{ | ||
Path: []string{ | ||
"File", | ||
"Save", | ||
}, | ||
}, | ||
&types.StringElement{ | ||
Content: ".", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
Expect(ParseDocument(source)).To(MatchDocument(expected)) | ||
}) | ||
|
||
It("with multiple sub paths", func() { | ||
source := `:experimental: | ||
Select menu:File[Zoom > Reset].` | ||
expected := &types.Document{ | ||
Elements: []interface{}{ | ||
&types.DocumentHeader{ | ||
Elements: []interface{}{ | ||
&types.AttributeDeclaration{ | ||
Name: "experimental", | ||
}, | ||
}, | ||
}, | ||
&types.Paragraph{ | ||
Elements: []interface{}{ | ||
&types.StringElement{ | ||
Content: "Select ", | ||
}, | ||
&types.InlineMenu{ | ||
Path: []string{ | ||
"File", | ||
"Zoom", | ||
"Reset", | ||
}, | ||
}, | ||
&types.StringElement{ | ||
Content: ".", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
Expect(ParseDocument(source)).To(MatchDocument(expected)) | ||
}) | ||
|
||
It("when experimental is not enabled", func() { | ||
source := `Select menu:File[Zoom > Reset].` | ||
expected := &types.Document{ | ||
Elements: []interface{}{ | ||
&types.Paragraph{ | ||
Elements: []interface{}{ | ||
&types.StringElement{ | ||
Content: "Select menu:File[Zoom ", | ||
}, | ||
&types.SpecialCharacter{ | ||
Name: ">", | ||
}, | ||
&types.StringElement{ | ||
Content: " Reset].", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
Expect(ParseDocument(source)).To(MatchDocument(expected)) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.