hswg: don't link to drafts
This commit is contained in:
parent
750f2139f5
commit
ea8c59961c
|
@ -80,6 +80,10 @@ type Metadata struct {
|
||||||
Attributes types.Attributes
|
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
|
// 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.
|
// the file could be read at all, it will always return a non-empty document.
|
||||||
func Render(r io.Reader, config configuration.Configuration) (
|
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 {
|
func expand(m *map[string]*entry, name string, chunk []byte) []byte {
|
||||||
return linkWordRE.ReplaceAllFunc(chunk, func(match []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)
|
link.backlinks = append(link.backlinks, name)
|
||||||
return []byte(makeLink(m, string(match)))
|
return []byte(makeLink(m, string(match)))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue