-
Notifications
You must be signed in to change notification settings - Fork 23
/
literal_blocks.go
39 lines (35 loc) · 995 Bytes
/
literal_blocks.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package sgml
import (
"strings"
"github.com/bytesparadise/libasciidoc/pkg/types"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
)
func (r *sgmlRenderer) renderLiteralBlock(ctx *context, b *types.DelimitedBlock) (string, error) {
log.Debugf("rendering literal block")
content, err := r.renderElements(ctx, b.Elements)
if err != nil {
return "", errors.Wrap(err, "unable to render literal block content")
}
roles, err := r.renderElementRoles(ctx, b.Attributes)
if err != nil {
return "", errors.Wrap(err, "unable to render literal block roles")
}
title, err := r.renderElementTitle(ctx, b.Attributes)
if err != nil {
return "", errors.Wrap(err, "unable to render literal block title")
}
return r.execute(r.literalBlock, struct {
Context *context
ID string
Title string
Roles string
Content string
}{
Context: ctx,
ID: r.renderElementID(b.Attributes),
Title: title,
Roles: roles,
Content: strings.Trim(content, "\n"),
})
}