Skip to content

Commit

Permalink
fix(parser): symbols in footnotes (#981)
Browse files Browse the repository at this point in the history
Fixes #980

Signed-off-by: Xavier Coulon <[email protected]>
  • Loading branch information
xcoulon authored Mar 17, 2022
1 parent 2123d11 commit 9f856f2
Show file tree
Hide file tree
Showing 5 changed files with 8,472 additions and 8,303 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ require (
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.13.0
github.com/pkg/errors v0.9.1
github.com/sergi/go-diff v1.0.0
github.com/sirupsen/logrus v1.7.0
github.com/sozorogami/gover v0.0.0-20171022184752-b58185e213c5
github.com/spf13/cobra v1.1.1
Expand Down
132 changes: 132 additions & 0 deletions pkg/parser/footnote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,138 @@ long paragraph.`
Expect(ParseDocument(source)).To(MatchDocument(expected)) // need to get the whole document here
})

It("footnote with single quoted strings", func() {
source := "Afootnote:['`a`']Bfootnote:[b] `C`"
footnoteA := types.Footnote{
Elements: []interface{}{
&types.Symbol{
Name: "'`",
},
&types.StringElement{
Content: "a",
},
&types.Symbol{
Name: "`'",
},
},
}
footnoteB := types.Footnote{
Elements: []interface{}{
&types.StringElement{
Content: "b",
},
},
}
expected := &types.Document{
Footnotes: []*types.Footnote{
{
ID: 1,
Elements: footnoteA.Elements,
},
{
ID: 2,
Elements: footnoteB.Elements,
},
},
Elements: []interface{}{
&types.Paragraph{
Elements: []interface{}{
&types.StringElement{
Content: "A",
},
&types.FootnoteReference{
ID: 1,
},
&types.StringElement{
Content: "B",
},
&types.FootnoteReference{
ID: 2,
},
&types.StringElement{
Content: " ",
},
&types.QuotedText{
Kind: types.SingleQuoteMonospace,
Elements: []interface{}{
&types.StringElement{
Content: "C",
},
},
},
},
},
},
}
Expect(ParseDocument(source)).To(MatchDocument(expected)) // need to get the whole document here
})

It("footnote with double quoted strings", func() {
source := "Afootnote:[\"`a`\"]Bfootnote:[b] `C`"
footnoteA := types.Footnote{
Elements: []interface{}{
&types.Symbol{
Name: "\"`",
},
&types.StringElement{
Content: "a",
},
&types.Symbol{
Name: "`\"",
},
},
}
footnoteB := types.Footnote{
Elements: []interface{}{
&types.StringElement{
Content: "b",
},
},
}
expected := &types.Document{
Footnotes: []*types.Footnote{
{
ID: 1,
Elements: footnoteA.Elements,
},
{
ID: 2,
Elements: footnoteB.Elements,
},
},
Elements: []interface{}{
&types.Paragraph{
Elements: []interface{}{
&types.StringElement{
Content: "A",
},
&types.FootnoteReference{
ID: 1,
},
&types.StringElement{
Content: "B",
},
&types.FootnoteReference{
ID: 2,
},
&types.StringElement{
Content: " ",
},
&types.QuotedText{
Kind: types.SingleQuoteMonospace,
Elements: []interface{}{
&types.StringElement{
Content: "C",
},
},
},
},
},
},
}
Expect(ParseDocument(source)).To(MatchDocument(expected)) // need to get the whole document here
})

It("footnote in a paragraph", func() {
source := `This is another paragraph.footnote:[I am footnote text and will be displayed at the bottom of the article.]`
expected := &types.Document{
Expand Down
Loading

0 comments on commit 9f856f2

Please sign in to comment.