forked from bytesparadise/libasciidoc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(parser): verify configuration attributes (bytesparadise#513)
include all document attributes, including overrides in the returned "parsed document" after processing the draft document returned by the parser. Those attributes can then be consumed by the renderer, when applicable, also: refactor predefined attributes (moved to pkg/types) Fixes bytesparadise#509 Signed-off-by: Xavier Coulon <[email protected]>
- Loading branch information
Showing
17 changed files
with
281 additions
and
57 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
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
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,51 @@ | ||
package parser_test | ||
|
||
import ( | ||
"github.com/bytesparadise/libasciidoc/pkg/configuration" | ||
"github.com/bytesparadise/libasciidoc/pkg/types" | ||
. "github.com/bytesparadise/libasciidoc/testsupport" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("document processing", func() { | ||
|
||
It("should retain attributes passed in configuration", func() { | ||
source := `[source] | ||
---- | ||
foo | ||
----` | ||
expected := types.Document{ | ||
Attributes: types.DocumentAttributes{ | ||
types.AttrSyntaxHighlighter: "pygments", | ||
}, | ||
ElementReferences: types.ElementReferences{}, | ||
Footnotes: types.Footnotes{}, | ||
FootnoteReferences: types.FootnoteReferences{}, | ||
Elements: []interface{}{ | ||
types.DelimitedBlock{ | ||
Attributes: types.ElementAttributes{ | ||
types.AttrKind: types.Source, | ||
}, | ||
Kind: types.Source, | ||
Elements: []interface{}{ | ||
types.Paragraph{ | ||
Attributes: types.ElementAttributes{}, | ||
Lines: [][]interface{}{ | ||
{ | ||
types.StringElement{ | ||
Content: "foo", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
Expect(ParseDocument(source, configuration.WithAttributes(map[string]string{ | ||
types.AttrSyntaxHighlighter: "pygments", | ||
}))).To(Equal(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
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
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.