diff --git a/pkg/parser/list_test.go b/pkg/parser/list_test.go index 207cc056..0217a29c 100644 --- a/pkg/parser/list_test.go +++ b/pkg/parser/list_test.go @@ -554,6 +554,54 @@ another fenced block } verify(GinkgoT(), expectedResult, actualContent, parser.Entrypoint("DocumentBlock")) }) + + It("labeled list with title", func() { + actualContent := `.Labeled, single-line +first term:: definition of the first term +second term:: definition of the second term` + expectedResult := types.LabeledList{ + Attributes: types.ElementAttributes{ + types.AttrTitle: "Labeled, single-line", + }, + Items: []types.LabeledListItem{ + { + Attributes: types.ElementAttributes{}, + Level: 1, + Term: "first term", + Elements: []interface{}{ + types.Paragraph{ + Attributes: types.ElementAttributes{}, + Lines: []types.InlineElements{ + { + types.StringElement{ + Content: "definition of the first term", + }, + }, + }, + }, + }, + }, + { + Attributes: types.ElementAttributes{}, + Level: 1, + Term: "second term", + Elements: []interface{}{ + types.Paragraph{ + Attributes: types.ElementAttributes{}, + Lines: []types.InlineElements{ + { + types.StringElement{ + Content: "definition of the second term", + }, + }, + }, + }, + }, + }, + }, + } + verify(GinkgoT(), expectedResult, actualContent, parser.Entrypoint("DocumentBlock")) + }) }) Context("unordered list", func() { diff --git a/pkg/renderer/html5/labeled_list.go b/pkg/renderer/html5/labeled_list.go index 2d5faa2f..1b2afa46 100644 --- a/pkg/renderer/html5/labeled_list.go +++ b/pkg/renderer/html5/labeled_list.go @@ -17,7 +17,8 @@ var horizontalLabeledListTmpl texttemplate.Template func init() { defaultLabeledListTmpl = newTextTemplate("labeled list with default layout", `{{ $ctx := .Context }}{{ with .Data }} -
+{{ if .Title }}
{{ .Title }}
+{{ end }}
{{ $items := .Items }}{{ range $itemIndex, $item := $items }}
{{ $item.Term }}
{{ if $item.Elements }}
{{ renderElements $ctx $item.Elements | printf "%s" }} diff --git a/pkg/renderer/html5/labeled_list_test.go b/pkg/renderer/html5/labeled_list_test.go index 287c4d1b..899f2080 100644 --- a/pkg/renderer/html5/labeled_list_test.go +++ b/pkg/renderer/html5/labeled_list_test.go @@ -18,6 +18,7 @@ on 2 lines. item 3:: description 3 on 2 lines, too.` expectedResult := `
+
mytitle
item 1
@@ -144,6 +145,26 @@ item 2:: something simple`

something simple

+
` + verify(GinkgoT(), expectedResult, actualContent) + }) + + It("labeled list with title", func() { + actualContent := `.Labeled, single-line +first term:: definition of the first term +second term:: definition of the second term` + expectedResult := `
+
Labeled, single-line
+
+
first term
+
+

definition of the first term

+
+
second term
+
+

definition of the second term

+
+
` verify(GinkgoT(), expectedResult, actualContent) })