diff --git a/pkg/renderer/html5/string.go b/pkg/renderer/html5/string.go index dcc28758..f70038d4 100644 --- a/pkg/renderer/html5/string.go +++ b/pkg/renderer/html5/string.go @@ -21,7 +21,7 @@ func renderStringElement(ctx renderer.Context, str types.StringElement) ([]byte, if err != nil { return []byte{}, errors.Wrapf(err, "unable to render string") } - result := convert(buf.String(), ellipsis, copyright) + result := convert(buf.String(), ellipsis, copyright, trademark, registered) return []byte(result), nil } @@ -33,6 +33,14 @@ func copyright(source string) string { return strings.Replace(source, "(C)", "©", -1) } +func trademark(source string) string { + return strings.Replace(source, "(TM)", "™", -1) +} + +func registered(source string) string { + return strings.Replace(source, "(R)", "®", -1) +} + type converter func(string) string func convert(source string, converters ...converter) string { diff --git a/pkg/renderer/html5/string_test.go b/pkg/renderer/html5/string_test.go index b4aa9e4a..9bca4094 100644 --- a/pkg/renderer/html5/string_test.go +++ b/pkg/renderer/html5/string_test.go @@ -11,8 +11,6 @@ var _ = Describe("strings", func() { It("text with ellipsis", func() { source := `some text...` - // top-level section is not rendered per-say, - // but the section will be used to set the HTML page's element expected := `<div class="paragraph"> <p>some text…​</p> </div>` @@ -21,10 +19,35 @@ var _ = Describe("strings", func() { It("text with copyright", func() { source := `Copyright (C)` - // top-level section is not rendered per-say, - // but the section will be used to set the HTML page's <title> element expected := `<div class="paragraph"> <p>Copyright ©</p> +</div>` + Expect(RenderHTML(source)).To(MatchHTML(expected)) + }) + + It("text with trademark", func() { + source := `TheRightThing(TM)` + expected := `<div class="paragraph"> +<p>TheRightThing™</p> +</div>` + Expect(RenderHTML(source)).To(MatchHTML(expected)) + }) + + It("text with registered", func() { + source := `TheRightThing(R)` + expected := `<div class="paragraph"> +<p>TheRightThing®</p> +</div>` + Expect(RenderHTML(source)).To(MatchHTML(expected)) + }) + + It("title with registered", func() { + // We will often want to use these symbols in headers. + source := `== Registered(R)` + expected := `<div class="sect1"> +<h2 id="_registered_r">Registered®</h2> +<div class="sectionbody"> +</div> </div>` Expect(RenderHTML(source)).To(MatchHTML(expected)) })