diff options
Diffstat (limited to 'hswg/main.go')
-rw-r--r-- | hswg/main.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/hswg/main.go b/hswg/main.go index 0a92797..b8e6e40 100644 --- a/hswg/main.go +++ b/hswg/main.go @@ -80,6 +80,10 @@ type Metadata struct { Attributes types.Attributes } +// IsDraft returns whether the document is marked as a draft, and should not +// be linked anywhere else. +func (m *Metadata) IsDraft() bool { return m.Attributes.Has("draft") } + // Render converts an io.Reader with an AsciiDoc document to HTML. So long as // the file could be read at all, it will always return a non-empty document. func Render(r io.Reader, config configuration.Configuration) ( @@ -154,7 +158,8 @@ var linkWordRE = regexp.MustCompile(`\b\p{Lu}\p{L}*\b`) func expand(m *map[string]*entry, name string, chunk []byte) []byte { return linkWordRE.ReplaceAllFunc(chunk, func(match []byte) []byte { - if link, ok := (*m)[string(match)]; ok && string(match) != name { + if link, ok := (*m)[string(match)]; ok && string(match) != name && + !link.metadata.IsDraft() { link.backlinks = append(link.backlinks, name) return []byte(makeLink(m, string(match))) } |