Skip to content

Commit

Permalink
feat(parser/renderer): support the menu inline macro
Browse files Browse the repository at this point in the history
Only if `experimental` attribute is set

Fixes #940

Signed-off-by: Xavier Coulon <[email protected]>
  • Loading branch information
xcoulon committed Feb 24, 2022
1 parent 32ef65c commit cd427f1
Show file tree
Hide file tree
Showing 13 changed files with 8,442 additions and 8,074 deletions.
2 changes: 1 addition & 1 deletion pkg/parser/inline_button_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
. "github.com/onsi/gomega" // nolint:golintt
)

var _ = Describe("buttons", func() {
var _ = Describe("inline buttons", func() {

Context("in final documents", func() {

Expand Down
139 changes: 139 additions & 0 deletions pkg/parser/inline_menu_test.go
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))
})
})
})
Loading

0 comments on commit cd427f1

Please sign in to comment.