summaryrefslogtreecommitdiff
path: root/gemtext/types.go
diff options
context:
space:
mode:
Diffstat (limited to 'gemtext/types.go')
-rw-r--r--gemtext/types.go65
1 files changed, 34 insertions, 31 deletions
diff --git a/gemtext/types.go b/gemtext/types.go
index fb9352a..fefbece 100644
--- a/gemtext/types.go
+++ b/gemtext/types.go
@@ -91,39 +91,39 @@ func (tl TextLine) Raw() []byte { return tl.raw }
// LinkLine is a line of LineTypeLink.
type LinkLine struct {
raw []byte
-
- // URL is the original bytes of the url portion of the line.
- //
- // It is not guaranteed to be a valid URL.
- URL []byte
-
- // Label is the label portion of the line.
- //
- // If there was no label it will always be nil, never []byte{}.
- Label []byte
+ url []byte
+ label []byte
}
func (ll LinkLine) Type() LineType { return LineTypeLink }
func (ll LinkLine) Raw() []byte { return ll.raw }
+// URL returns the original url portion of the line.
+//
+// It is not guaranteed to be a valid URL.
+func (ll LinkLine) URL() string { return string(ll.url) }
+
+// Label returns the label portion of the line.
+func (ll LinkLine) Label() string { return string(ll.label) }
+
// PreformatToggleLine is a preformatted text toggle line.
type PreformatToggleLine struct {
raw []byte
-
- // AltText contains the alt-text portion of the line.
- //
- // It will either have len() > 0 or be nil.
- //
- // If the line was parsed as part of a full document by Parse(),
- // and this is a *closing* toggle, any alt-text present will be
- // stripped and this will be nil. If the line was parsed by
- // ParseLine() no such correction is performed.
- AltText []byte
+ altText []byte
}
func (tl PreformatToggleLine) Type() LineType { return LineTypePreformatToggle }
func (tl PreformatToggleLine) Raw() []byte { return tl.raw }
-func (tl *PreformatToggleLine) clearAlt() { tl.AltText = nil }
+
+// AltText returns the alt-text portion of the line.
+//
+// If the line was parsed as part of a full document by Parse(),
+// and this is a *closing* toggle, any alt-text present will be
+// stripped and this will be empty. If the line was parsed by
+// ParseLine() no such correction is performed.
+func (tl PreformatToggleLine) AltText() string { return string(tl.altText) }
+
+func (tl *PreformatToggleLine) clearAlt() { tl.altText = nil }
// PreformattedTextLine represents a line between two toggles.
//
@@ -140,32 +140,35 @@ func (tl PreformattedTextLine) Raw() []byte { return tl.raw }
type HeadingLine struct {
raw []byte
lineType LineType
-
- // Body is the portion of the line with the header text.
- Body []byte
+ body []byte
}
func (hl HeadingLine) Type() LineType { return hl.lineType }
func (hl HeadingLine) Raw() []byte { return hl.raw }
+// Body returns the portion of the line with the header text.
+func (hl HeadingLine) Body() string { return string(hl.body) }
+
// ListItemLine is a line of LineTypeListItem.
type ListItemLine struct {
raw []byte
-
- // Body is the text of the list item.
- Body []byte
+ body []byte
}
func (li ListItemLine) Type() LineType { return LineTypeListItem }
func (li ListItemLine) Raw() []byte { return li.raw }
+// Body returns the text of the list item.
+func (li ListItemLine) Body() string { return string(li.body) }
+
// QuoteLine is a line of LineTypeQuote.
type QuoteLine struct {
- raw []byte
-
- // Body is the text of the quote.
- Body []byte
+ raw []byte
+ body []byte
}
func (ql QuoteLine) Type() LineType { return LineTypeQuote }
func (ql QuoteLine) Raw() []byte { return ql.raw }
+
+// Body returns the text of the quote.
+func (ql QuoteLine) Body() string { return string(ql.body) }