Skip to content

Commit

Permalink
feat(parser/renderer) Support for thematic breaks (#639)
Browse files Browse the repository at this point in the history
This adds support for all six forms of thematic break supported
by asciidoctor.

Fixes #617
  • Loading branch information
gdamore authored Jun 25, 2020
1 parent fc8a97e commit 2d34c13
Show file tree
Hide file tree
Showing 14 changed files with 3,597 additions and 3,376 deletions.
92 changes: 91 additions & 1 deletion pkg/parser/paragraph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

var _ = Describe("paragraphs", func() {

Context("draf document", func() {
Context("draft document", func() {

Context("default paragraphs", func() {

Expand Down Expand Up @@ -781,6 +781,96 @@ image::foo.png[]`
Expect(ParseDraftDocument(source)).To(Equal(expected))
})
})

Context("thematic breaks", func() {
It("thematic break form1 by itself", func() {
source := "***"
expected := types.DraftDocument{
Blocks: []interface{}{
types.ThematicBreak{},
},
}
Expect(ParseDraftDocument(source)).To(Equal(expected))
})
It("thematic break form2 by itself", func() {
source := "* * *"
expected := types.DraftDocument{
Blocks: []interface{}{
types.ThematicBreak{},
},
}
Expect(ParseDraftDocument(source)).To(Equal(expected))
})
It("thematic break form3 by itself", func() {
source := "---"
expected := types.DraftDocument{
Blocks: []interface{}{
types.ThematicBreak{},
},
}
Expect(ParseDraftDocument(source)).To(Equal(expected))
})
It("thematic break form4 by itself", func() {
source := "- - -"
expected := types.DraftDocument{
Blocks: []interface{}{
types.ThematicBreak{},
},
}
Expect(ParseDraftDocument(source)).To(Equal(expected))
})
It("thematic break form5 by itself", func() {
source := "___"
expected := types.DraftDocument{
Blocks: []interface{}{
types.ThematicBreak{},
},
}
Expect(ParseDraftDocument(source)).To(Equal(expected))
})
It("thematic break form4 by itself", func() {
source := "_ _ _"
expected := types.DraftDocument{
Blocks: []interface{}{
types.ThematicBreak{},
},
}
Expect(ParseDraftDocument(source)).To(Equal(expected))
})
It("thematic break with leading text", func() {
source := "text ***"
expected := types.DraftDocument{
Blocks: []interface{}{
types.Paragraph{
Lines: [][]interface{}{
{
types.StringElement{Content: "text ***"},
},
},
},
},
}
Expect(ParseDraftDocument(source)).To(Equal(expected))
})

// NB: three asterisks gets confused with bullets if with trailing text
It("thematic break with trailing text", func() {
source := "* * * text"
expected := types.DraftDocument{
Blocks: []interface{}{
types.Paragraph{
Lines: [][]interface{}{
{
types.StringElement{Content: "* * * text"},
},
},
},
},
}
Expect(ParseDraftDocument(source)).To(Equal(expected))
})

})
})

Context("final document", func() {
Expand Down
Loading

0 comments on commit 2d34c13

Please sign in to comment.