func (t *AbsURL) absUrlify(tr *htmltran.Transformer, selectors ...elattr) (err error) { var baseURL, inURL *url.URL if baseURL, err = url.Parse(t.BaseURL); err != nil { return } replace := func(in string) string { if inURL, err = url.Parse(in); err != nil { return in + "?" } if fragmentOnly(inURL) { return in } return baseURL.ResolveReference(inURL).String() } for _, el := range selectors { if err = tr.Apply(htmltran.TransformAttrib(el.attr, replace), el.tag); err != nil { return } } return }
func (n *NavActive) Apply(w io.Writer, r io.Reader) (err error) { var tr *htmltran.Transformer if n.Section == "" { _, err = io.Copy(w, r) return } if tr, err = htmltran.NewFromReader(r); err != nil { return } if n.AttrName == "" { n.AttrName = "hugo-nav" } err = tr.Apply(htmltran.ModifyAttrib("class", "active"), fmt.Sprintf("li[%s=%s]", n.AttrName, n.Section)) if err != nil { return } return tr.Render(w) }