-
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.
fix(parser): support comment between doc title and author (#486)
support comments (single lines and blocks) before the author and between the author and the revision Fixes #481 Signed-off-by: Xavier Coulon <[email protected]>
- Loading branch information
Showing
3 changed files
with
3,262 additions
and
3,030 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 |
---|---|---|
|
@@ -234,6 +234,120 @@ Chameleon` | |
|
||
It("2 authors only", func() { | ||
source := `= title | ||
Kismet Rainbow Chameleon <[email protected]>; Lazarus het_Draeke <[email protected]>` | ||
title := []interface{}{ | ||
types.StringElement{ | ||
Content: "title", | ||
}, | ||
} | ||
expected := types.Document{ | ||
Attributes: types.DocumentAttributes{}, | ||
ElementReferences: types.ElementReferences{ | ||
"_title": title, | ||
}, | ||
Footnotes: types.Footnotes{}, | ||
FootnoteReferences: types.FootnoteReferences{}, | ||
Elements: []interface{}{ | ||
types.Section{ | ||
Level: 0, | ||
Attributes: types.ElementAttributes{ | ||
types.AttrID: "_title", | ||
types.AttrAuthors: []types.DocumentAuthor{ | ||
{ | ||
FullName: "Kismet Rainbow Chameleon ", | ||
Email: "[email protected]", | ||
}, | ||
{ | ||
FullName: "Lazarus het_Draeke ", | ||
Email: "[email protected]", | ||
}, | ||
}, | ||
}, | ||
Title: title, | ||
Elements: []interface{}{}, | ||
}, | ||
}, | ||
} | ||
Expect(source).To(BecomeDocument(expected)) | ||
}) | ||
}) | ||
|
||
Context("authors and comments", func() { | ||
|
||
It("authors commented out", func() { | ||
source := `= title | ||
// Kismet Rainbow Chameleon <[email protected]>; Lazarus het_Draeke <[email protected]>` | ||
title := []interface{}{ | ||
types.StringElement{ | ||
Content: "title", | ||
}, | ||
} | ||
expected := types.Document{ | ||
Attributes: types.DocumentAttributes{}, | ||
ElementReferences: types.ElementReferences{ | ||
"_title": title, | ||
}, | ||
Footnotes: types.Footnotes{}, | ||
FootnoteReferences: types.FootnoteReferences{}, | ||
Elements: []interface{}{ | ||
types.Section{ | ||
Level: 0, | ||
Attributes: types.ElementAttributes{ | ||
types.AttrID: "_title", | ||
}, | ||
Title: title, | ||
Elements: []interface{}{}, | ||
}, | ||
}, | ||
} | ||
Expect(source).To(BecomeDocument(expected)) | ||
}) | ||
|
||
It("authors after a single comment line", func() { | ||
source := `= title | ||
// a comment | ||
Kismet Rainbow Chameleon <[email protected]>; Lazarus het_Draeke <[email protected]>` | ||
title := []interface{}{ | ||
types.StringElement{ | ||
Content: "title", | ||
}, | ||
} | ||
expected := types.Document{ | ||
Attributes: types.DocumentAttributes{}, | ||
ElementReferences: types.ElementReferences{ | ||
"_title": title, | ||
}, | ||
Footnotes: types.Footnotes{}, | ||
FootnoteReferences: types.FootnoteReferences{}, | ||
Elements: []interface{}{ | ||
types.Section{ | ||
Level: 0, | ||
Attributes: types.ElementAttributes{ | ||
types.AttrID: "_title", | ||
types.AttrAuthors: []types.DocumentAuthor{ | ||
{ | ||
FullName: "Kismet Rainbow Chameleon ", | ||
Email: "[email protected]", | ||
}, | ||
{ | ||
FullName: "Lazarus het_Draeke ", | ||
Email: "[email protected]", | ||
}, | ||
}, | ||
}, | ||
Title: title, | ||
Elements: []interface{}{}, | ||
}, | ||
}, | ||
} | ||
Expect(source).To(BecomeDocument(expected)) | ||
}) | ||
|
||
It("authors after a comment block", func() { | ||
source := `= title | ||
//// | ||
a comment | ||
//// | ||
Kismet Rainbow Chameleon <[email protected]>; Lazarus het_Draeke <[email protected]>` | ||
title := []interface{}{ | ||
types.StringElement{ | ||
|
@@ -316,6 +430,90 @@ Kismet Rainbow Chameleon <[email protected]>; Lazarus het_Draeke <lazarus | |
Expect(source).To(BecomeDocument(expected)) | ||
}) | ||
|
||
It("full document revision with a comment before author", func() { | ||
source := `= title | ||
// a comment | ||
john doe | ||
v1.0, June 19, 2017: First incarnation` | ||
title := []interface{}{ | ||
types.StringElement{ | ||
Content: "title", | ||
}, | ||
} | ||
expected := types.Document{ | ||
Attributes: types.DocumentAttributes{}, | ||
ElementReferences: types.ElementReferences{ | ||
"_title": title, | ||
}, | ||
Footnotes: types.Footnotes{}, | ||
FootnoteReferences: types.FootnoteReferences{}, | ||
Elements: []interface{}{ | ||
types.Section{ | ||
Level: 0, | ||
Attributes: types.ElementAttributes{ | ||
types.AttrID: "_title", | ||
types.AttrAuthors: []types.DocumentAuthor{ | ||
{ | ||
FullName: "john doe", | ||
Email: "", | ||
}, | ||
}, | ||
types.AttrRevision: types.DocumentRevision{ | ||
Revnumber: "1.0", | ||
Revdate: "June 19, 2017", | ||
Revremark: "First incarnation", | ||
}, | ||
}, | ||
Title: title, | ||
Elements: []interface{}{}, | ||
}, | ||
}, | ||
} | ||
Expect(source).To(BecomeDocument(expected)) | ||
}) | ||
|
||
It("full document revision with a comment before revision", func() { | ||
source := `= title | ||
john doe | ||
// a comment | ||
v1.0, June 19, 2017: First incarnation` | ||
title := []interface{}{ | ||
types.StringElement{ | ||
Content: "title", | ||
}, | ||
} | ||
expected := types.Document{ | ||
Attributes: types.DocumentAttributes{}, | ||
ElementReferences: types.ElementReferences{ | ||
"_title": title, | ||
}, | ||
Footnotes: types.Footnotes{}, | ||
FootnoteReferences: types.FootnoteReferences{}, | ||
Elements: []interface{}{ | ||
types.Section{ | ||
Level: 0, | ||
Attributes: types.ElementAttributes{ | ||
types.AttrID: "_title", | ||
types.AttrAuthors: []types.DocumentAuthor{ | ||
{ | ||
FullName: "john doe", | ||
Email: "", | ||
}, | ||
}, | ||
types.AttrRevision: types.DocumentRevision{ | ||
Revnumber: "1.0", | ||
Revdate: "June 19, 2017", | ||
Revremark: "First incarnation", | ||
}, | ||
}, | ||
Title: title, | ||
Elements: []interface{}{}, | ||
}, | ||
}, | ||
} | ||
Expect(source).To(BecomeDocument(expected)) | ||
}) | ||
|
||
It("revision with revnumber and revdate only", func() { | ||
source := `= title | ||
john doe | ||
|
Oops, something went wrong.