go.talks/pkg/present: export Style function
This is required for go.blog's Atom feed.
I think it makes sense generally, too.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7759051
diff --git a/pkg/present/style.go b/pkg/present/style.go
index af1a58e..a6639bf 100644
--- a/pkg/present/style.go
+++ b/pkg/present/style.go
@@ -27,10 +27,12 @@
*/
func init() {
- funcs["style"] = style
+ funcs["style"] = Style
}
-func style(s string) template.HTML {
+// Style returns s with HTML entities escaped and font indicators turned into
+// HTML font tags.
+func Style(s string) template.HTML {
return template.HTML(font(html.EscapeString(s)))
}
diff --git a/pkg/present/style_test.go b/pkg/present/style_test.go
index 21c5067..363b174 100644
--- a/pkg/present/style_test.go
+++ b/pkg/present/style_test.go
@@ -5,6 +5,7 @@
package present
import (
+ "fmt"
"reflect"
"testing"
)
@@ -97,9 +98,15 @@
{"(_a)", "(_a)"},
}
for _, test := range tests {
- out := string(style(test.in))
+ out := string(Style(test.in))
if out != test.out {
t.Errorf("style(%q):\ngot\t%q\nwant\t%q", test.in, out, test.out)
}
}
}
+
+func ExampleStyle() {
+ const s = "*Gophers* are _clearly_ > *cats*!"
+ fmt.Println(Style(s))
+ // Output: <b>Gophers</b> are <i>clearly</i> > <b>cats</b>!
+}