This repository has been archived by the owner on May 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
document.go
58 lines (53 loc) · 1.89 KB
/
document.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package documents
import (
"html/template"
)
// Section represents a queryable portion of a resource.
type Section interface {
// Name is the name of the section.
Name() string
// Query retrieves the subsection referred to by the given name list. Each
// successive name refers to a subsection of the previous. Returns nil if
// the subsection was not found.
Query(name ...string) Section
// Subsections returns a list of the subsections within the current
// section.
Subsections() []Section
// Render returns the content rendered to HTML.
Render() template.HTML
}
// Headingable extends a Section by representing an outline with traversable
// headings.
type Headingable interface {
Section
// AdjustLevels offsets the levels of all headings in the outline, such
// that RootLevel returns the given value.
AdjustLevels(level int)
// RootLevel returns the level of the root heading. This is defined as one
// level less than the lowest heading level present in the outline.
RootLevel() int
// HeadingID returns the ID attribute of the heading.
HeadingID() string
// SetHeadingID sets the ID attribute of the heading.
SetHeadingID(string)
}
// Linkable extends a Section by representing a document with traversable
// reference links.
type Linkable interface {
Section
// Links receives a walk function, which receives a link. The function is
// applied to all links within the section, which can include those within
// subsections.
Links(walk func(link string))
// SetLinks receives a walk function, which receives a link and returns an
// adjusted link. The function is applied to all links within the section,
// which can include those within subsections.
SetLinks(walk func(link string) string)
}
// Countable extends a Section by representing a document with countable
// content.
type Countable interface {
Section
// Count returns the number of elements in the section.
Count() int
}