<b>*</b> ' &
+diff --git a/pkg/parser/special_character_test.go b/pkg/parser/special_character_test.go new file mode 100644 index 00000000..c1496f4a --- /dev/null +++ b/pkg/parser/special_character_test.go @@ -0,0 +1,117 @@ +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 golint +) + +var _ = Describe("special characters", func() { + + It("should parse in paragraph", func() { + source := "* ' &" + expected := types.DraftDocument{ + Blocks: []interface{}{ + types.Paragraph{ + Lines: []interface{}{ + []interface{}{ + types.SpecialCharacter{ + Name: "<", + }, + types.StringElement{ + Content: "b", + }, + types.SpecialCharacter{ + Name: ">", + }, + types.StringElement{ + Content: "*", + }, + types.SpecialCharacter{ + Name: "<", + }, + types.StringElement{ + Content: "/b", + }, + types.SpecialCharacter{ + Name: ">", + }, + types.StringElement{ + Content: " ", + }, + types.SpecialCharacter{ + Name: "&", + }, + types.StringElement{ + Content: "apos; ", + }, + types.SpecialCharacter{ + Name: "&", + }, + types.StringElement{ + Content: "amp;", + }, + }, + }, + }, + }, + } + Expect(ParseDraftDocument(source)).To(MatchDraftDocument(expected)) + }) + + It("should parse in delimited block", func() { + source := "```" + "\n" + + "* ' &" + "\n" + + "```" + expected := types.DraftDocument{ + Blocks: []interface{}{ + types.DelimitedBlock{ + Kind: types.Fenced, + Elements: []interface{}{ + []interface{}{ + types.SpecialCharacter{ + Name: "<", + }, + types.StringElement{ + Content: "b", + }, + types.SpecialCharacter{ + Name: ">", + }, + types.StringElement{ + Content: "*", + }, + types.SpecialCharacter{ + Name: "<", + }, + types.StringElement{ + Content: "/b", + }, + types.SpecialCharacter{ + Name: ">", + }, + types.StringElement{ + Content: " ", + }, + types.SpecialCharacter{ + Name: "&", + }, + types.StringElement{ + Content: "apos; ", + }, + types.SpecialCharacter{ + Name: "&", + }, + types.StringElement{ + Content: "amp;", + }, + }, + }, + }, + }, + } + Expect(ParseDraftDocument(source)).To(MatchDraftDocument(expected)) + }) +}) diff --git a/pkg/renderer/sgml/html5/special_character_test.go b/pkg/renderer/sgml/html5/special_character_test.go new file mode 100644 index 00000000..36682180 --- /dev/null +++ b/pkg/renderer/sgml/html5/special_character_test.go @@ -0,0 +1,50 @@ +package html5_test + +import ( + . "github.com/bytesparadise/libasciidoc/testsupport" + + . "github.com/onsi/ginkgo" //nolint golint + . "github.com/onsi/gomega" //nolint golint +) + +var _ = Describe("special characters", func() { + + It("should parse in paragraph", func() { + source := "* ' &" + expected := `
<b>*</b> ' &
+<b>*</b> ' &
+<b>*</b> ' &
+<b>*</b> ' &
+