-
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): support concealed index terms (#475)
support the `(((` syntax in paragraphs, but discard the element from the final document, so no rendering is done. Fixes #473 Signed-off-by: Xavier Coulon <[email protected]>
- Loading branch information
Showing
6 changed files
with
2,181 additions
and
1,841 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
package parser_test | ||
|
||
import ( | ||
"github.com/bytesparadise/libasciidoc/pkg/types" | ||
. "github.com/bytesparadise/libasciidoc/testsupport" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("concealed index terms", func() { | ||
|
||
Context("draft document", func() { | ||
|
||
It("index term in existing paragraph line", func() { | ||
source := `a paragraph with an index term (((index, term, here))).` | ||
expected := types.DraftDocument{ | ||
Blocks: []interface{}{ | ||
types.Paragraph{ | ||
Attributes: types.ElementAttributes{}, | ||
Lines: [][]interface{}{ | ||
{ | ||
types.StringElement{ | ||
Content: "a paragraph with an index term ", | ||
}, | ||
types.ConceleadIndexTerm{ | ||
Term1: "index", | ||
Term2: "term", | ||
Term3: "here", | ||
}, | ||
types.StringElement{ | ||
Content: ".", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
Expect(source).To(BecomeDraftDocument(expected)) | ||
}) | ||
|
||
It("index term in single paragraph line", func() { | ||
source := `(((index, term))) | ||
a paragraph with an index term.` | ||
expected := types.DraftDocument{ | ||
Blocks: []interface{}{ | ||
types.Paragraph{ | ||
Attributes: types.ElementAttributes{}, | ||
Lines: [][]interface{}{ | ||
{ | ||
types.ConceleadIndexTerm{ | ||
Term1: "index", | ||
Term2: "term", | ||
}, | ||
}, | ||
{ | ||
types.StringElement{ | ||
Content: "a paragraph with an index term.", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
Expect(source).To(BecomeDraftDocument(expected)) | ||
}) | ||
}) | ||
|
||
Context("final document", func() { | ||
|
||
It("index term in existing paragraph line", func() { | ||
source := `a paragraph with an index term (((index, term, here))).` | ||
expected := types.Document{ | ||
Attributes: types.DocumentAttributes{}, | ||
ElementReferences: types.ElementReferences{}, | ||
Footnotes: types.Footnotes{}, | ||
FootnoteReferences: types.FootnoteReferences{}, | ||
Elements: []interface{}{ | ||
types.Paragraph{ | ||
Attributes: types.ElementAttributes{}, | ||
Lines: [][]interface{}{ | ||
{ | ||
types.StringElement{ | ||
Content: "a paragraph with an index term ", | ||
}, | ||
types.StringElement{ | ||
Content: ".", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
Expect(source).To(BecomeDocument(expected)) | ||
}) | ||
|
||
It("index term in single paragraph line", func() { | ||
source := `(((index, term))) | ||
a paragraph with an index term.` | ||
expected := types.Document{ | ||
Attributes: types.DocumentAttributes{}, | ||
ElementReferences: types.ElementReferences{}, | ||
Footnotes: types.Footnotes{}, | ||
FootnoteReferences: types.FootnoteReferences{}, | ||
Elements: []interface{}{ | ||
types.Paragraph{ | ||
Attributes: types.ElementAttributes{}, | ||
Lines: [][]interface{}{ | ||
{ | ||
types.StringElement{ | ||
Content: "a paragraph with an index term.", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
Expect(source).To(BecomeDocument(expected)) | ||
}) | ||
}) | ||
}) |
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
Oops, something went wrong.