shithub: hugo

Download patch

ref: 1cc638693713d7f4ce564b91302af72e3d8531e2
parent: e5be592ee0d0a24c9bfcf4938cbda4f77e07f3d2
author: bep <[email protected]>
date: Wed Jan 21 09:35:33 EST 2015

Make ref and relref respect plainIdAnchors

Fixes #813

--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -78,8 +78,8 @@
 }
 
 type Position struct {
-	Prev *Page
-	Next *Page
+	Prev          *Page
+	Next          *Page
 	PrevInSection *Page
 	NextInSection *Page
 }
@@ -202,6 +202,10 @@
 	}
 
 	return flags
+}
+
+func (p *Page) isRenderingFlagEnabled(flag string) bool {
+	return p.getRenderingConfigFlags()[flag]
 }
 
 func newPage(filename string) *Page {
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -186,9 +186,9 @@
 	if refUrl.Fragment != "" {
 		link = link + "#" + refUrl.Fragment
 
-		if refUrl.Path != "" && target != nil {
+		if refUrl.Path != "" && target != nil && !target.isRenderingFlagEnabled("plainIdAnchors") {
 			link = link + ":" + target.UniqueId()
-		} else if page != nil {
+		} else if page != nil && !page.isRenderingFlagEnabled("plainIdAnchors") {
 			link = link + ":" + page.UniqueId()
 		}
 	}