Hello community,
here is the log from the commit of package golang-github-cpuguy83-go-md2man for
openSUSE:Factory checked in at 2016-01-21 23:44:31
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/golang-github-cpuguy83-go-md2man (Old)
and /work/SRC/openSUSE:Factory/.golang-github-cpuguy83-go-md2man.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "golang-github-cpuguy83-go-md2man"
Changes:
--------
---
/work/SRC/openSUSE:Factory/golang-github-cpuguy83-go-md2man/golang-github-cpuguy83-go-md2man.changes
2015-08-01 14:17:08.000000000 +0200
+++
/work/SRC/openSUSE:Factory/.golang-github-cpuguy83-go-md2man.new/golang-github-cpuguy83-go-md2man.changes
2016-01-22 01:10:09.000000000 +0100
@@ -1,0 +2,7 @@
+Sun Jan 17 09:56:53 UTC 2016 - [email protected]
+
+- Update to version 1.0.5+git20160104.2724a9c:
+ + md2man usable as a library (again)
+ + Improve man page rendering
+
+-------------------------------------------------------------------
Old:
----
go-md2man-1.0.2+git20150617.e69ac41.tar.xz
New:
----
_servicedata
go-md2man-1.0.5+git20160104.2724a9c.tar.xz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ golang-github-cpuguy83-go-md2man.spec ++++++
--- /var/tmp/diff_new_pack.uUkqsJ/_old 2016-01-22 01:10:11.000000000 +0100
+++ /var/tmp/diff_new_pack.uUkqsJ/_new 2016-01-22 01:10:11.000000000 +0100
@@ -1,7 +1,7 @@
#
# spec file for package golang-github-cpuguy83-go-md2man
#
-# Copyright (c) 2015 SUSE LLC
+# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -17,47 +17,41 @@
Name: golang-github-cpuguy83-go-md2man
-Version: 1.0.2+git20150617.e69ac41
+Version: 1.0.5+git20160104.2724a9c
Release: 0
Summary: Convert markdown into man pages
License: MIT
-Group: Development/Languages/Other
-URL: https://github.com/cpuguy83/go-md2man
+Group: Development/Languages/Golang
+Url: https://github.com/cpuguy83/go-md2man
Source0: go-md2man-%{version}.tar.xz
-BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: golang-packaging
-BuildRequires: golang(golang.org/x/net)
+BuildRequires: xz
BuildRequires: golang(github.com/russross/blackfriday)
+BuildRequires: golang(golang.org/x/net)
Provides: go-go-md2man = %{version}
Obsoletes: go-go-md2man < %{version}
+BuildRoot: %{_tmppath}/%{name}-%{version}-build
%{go_provides}
%description
Tool to converts markdown into man pages
-%gosrc_package
-
%prep
%setup -q -n go-md2man-%{version}
%build
-%goprep github.com/cpuguy83/go-md2man
-%gobuild ...
+%{goprep} github.com/cpuguy83/go-md2man
+%{gobuild} ...
%install
-%goinstall
-%gosrc
+%{goinstall}
+%{go_filelist}
%check
-%gotest github.com/cpuguy83/go-md2man
+%{gotest} github.com/cpuguy83/go-md2man
-%files
+%files -f file.lst
%defattr(-,root,root,-)
%doc README.md LICENSE.md
-%{_bindir}/go-md2man
-
-%files source
-%defattr(-,root,root,-)
-%{go_contribsrcdir}/*
%changelog
++++++ _service ++++++
--- /var/tmp/diff_new_pack.uUkqsJ/_old 2016-01-22 01:10:11.000000000 +0100
+++ /var/tmp/diff_new_pack.uUkqsJ/_new 2016-01-22 01:10:11.000000000 +0100
@@ -1,16 +1,17 @@
<services>
- <service name="tar_scm" mode="localonly">
- <param name="url">http://github.com/cpuguy83/go-md2man</param>
+ <service name="tar_scm" mode="disabled">
+ <param name="url">https://github.com/cpuguy83/go-md2man</param>
<param name="scm">git</param>
<param name="exclude">.git</param>
- <param name="versionformat">1.0.2+git%cd.%h</param>
+ <param name="versionformat">1.0.5+git%cd.%h</param>
<param name="revision">master</param>
+ <param name="changesgenerate">enable</param>
</service>
- <service name="recompress" mode="localonly">
+ <service name="recompress" mode="disabled">
<param name="file">go-md2man-*.tar</param>
<param name="compression">xz</param>
</service>
- <service name="set_version" mode="localonly">
+ <service name="set_version" mode="disabled">
<param name="basename">go-md2man</param>
</service>
</services>
++++++ _servicedata ++++++
<servicedata>
<service name="tar_scm">
<param name="url">https://github.com/cpuguy83/go-md2man</param>
<param
name="changesrevision">2724a9c9051aa62e9cca11304e7dd518e9e41599</param></service></servicedata>++++++
go-md2man-1.0.2+git20150617.e69ac41.tar.xz ->
go-md2man-1.0.5+git20160104.2724a9c.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/go-md2man-1.0.2+git20150617.e69ac41/md2man/md2man.go
new/go-md2man-1.0.5+git20160104.2724a9c/md2man/md2man.go
--- old/go-md2man-1.0.2+git20150617.e69ac41/md2man/md2man.go 1970-01-01
01:00:00.000000000 +0100
+++ new/go-md2man-1.0.5+git20160104.2724a9c/md2man/md2man.go 2016-01-17
10:56:53.000000000 +0100
@@ -0,0 +1,19 @@
+package md2man
+
+import (
+ "github.com/russross/blackfriday"
+)
+
+func Render(doc []byte) []byte {
+ renderer := RoffRenderer(0)
+ extensions := 0
+ extensions |= blackfriday.EXTENSION_NO_INTRA_EMPHASIS
+ extensions |= blackfriday.EXTENSION_TABLES
+ extensions |= blackfriday.EXTENSION_FENCED_CODE
+ extensions |= blackfriday.EXTENSION_AUTOLINK
+ extensions |= blackfriday.EXTENSION_SPACE_HEADERS
+ extensions |= blackfriday.EXTENSION_FOOTNOTES
+ extensions |= blackfriday.EXTENSION_TITLEBLOCK
+
+ return blackfriday.Markdown(doc, renderer, extensions)
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/go-md2man-1.0.2+git20150617.e69ac41/md2man/roff.go
new/go-md2man-1.0.5+git20160104.2724a9c/md2man/roff.go
--- old/go-md2man-1.0.2+git20150617.e69ac41/md2man/roff.go 1970-01-01
01:00:00.000000000 +0100
+++ new/go-md2man-1.0.5+git20160104.2724a9c/md2man/roff.go 2016-01-17
10:56:53.000000000 +0100
@@ -0,0 +1,281 @@
+package md2man
+
+import (
+ "bytes"
+ "fmt"
+ "html"
+ "strings"
+
+ "github.com/russross/blackfriday"
+)
+
+type roffRenderer struct{}
+
+var listCounter int
+
+func RoffRenderer(flags int) blackfriday.Renderer {
+ return &roffRenderer{}
+}
+
+func (r *roffRenderer) GetFlags() int {
+ return 0
+}
+
+func (r *roffRenderer) TitleBlock(out *bytes.Buffer, text []byte) {
+ out.WriteString(".TH ")
+
+ splitText := bytes.Split(text, []byte("\n"))
+ for i, line := range splitText {
+ line = bytes.TrimPrefix(line, []byte("% "))
+ if i == 0 {
+ line = bytes.Replace(line, []byte("("), []byte("\"
\""), 1)
+ line = bytes.Replace(line, []byte(")"), []byte("\"
\""), 1)
+ }
+ line = append([]byte("\""), line...)
+ line = append(line, []byte("\" ")...)
+ out.Write(line)
+ }
+ out.WriteString("\n")
+
+ // disable hyphenation
+ out.WriteString(".nh\n")
+ // disable justification (adjust text to left margin only)
+ out.WriteString(".ad l\n")
+}
+
+func (r *roffRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string) {
+ out.WriteString("\n.PP\n.RS\n\n.nf\n")
+ escapeSpecialChars(out, text)
+ out.WriteString("\n.fi\n.RE\n")
+}
+
+func (r *roffRenderer) BlockQuote(out *bytes.Buffer, text []byte) {
+ out.WriteString("\n.PP\n.RS\n")
+ out.Write(text)
+ out.WriteString("\n.RE\n")
+}
+
+func (r *roffRenderer) BlockHtml(out *bytes.Buffer, text []byte) {
+ out.Write(text)
+}
+
+func (r *roffRenderer) Header(out *bytes.Buffer, text func() bool, level int,
id string) {
+ marker := out.Len()
+
+ switch {
+ case marker == 0:
+ // This is the doc header
+ out.WriteString(".TH ")
+ case level == 1:
+ out.WriteString("\n\n.SH ")
+ case level == 2:
+ out.WriteString("\n.SH ")
+ default:
+ out.WriteString("\n.SS ")
+ }
+
+ if !text() {
+ out.Truncate(marker)
+ return
+ }
+}
+
+func (r *roffRenderer) HRule(out *bytes.Buffer) {
+ out.WriteString("\n.ti 0\n\\l'\\n(.lu'\n")
+}
+
+func (r *roffRenderer) List(out *bytes.Buffer, text func() bool, flags int) {
+ marker := out.Len()
+ if flags&blackfriday.LIST_TYPE_ORDERED != 0 {
+ listCounter = 1
+ }
+ if !text() {
+ out.Truncate(marker)
+ return
+ }
+}
+
+func (r *roffRenderer) ListItem(out *bytes.Buffer, text []byte, flags int) {
+ if flags&blackfriday.LIST_TYPE_ORDERED != 0 {
+ out.WriteString(fmt.Sprintf(".IP \"%3d.\" 5\n", listCounter))
+ listCounter += 1
+ } else {
+ out.WriteString(".IP \\(bu 2\n")
+ }
+ out.Write(text)
+ out.WriteString("\n")
+}
+
+func (r *roffRenderer) Paragraph(out *bytes.Buffer, text func() bool) {
+ marker := out.Len()
+ out.WriteString("\n.PP\n")
+ if !text() {
+ out.Truncate(marker)
+ return
+ }
+ if marker != 0 {
+ out.WriteString("\n")
+ }
+}
+
+// TODO: This might now work
+func (r *roffRenderer) Table(out *bytes.Buffer, header []byte, body []byte,
columnData []int) {
+ out.WriteString(".TS\nallbox;\n")
+
+ out.Write(header)
+ out.Write(body)
+ out.WriteString("\n.TE\n")
+}
+
+func (r *roffRenderer) TableRow(out *bytes.Buffer, text []byte) {
+ if out.Len() > 0 {
+ out.WriteString("\n")
+ }
+ out.Write(text)
+ out.WriteString("\n")
+}
+
+func (r *roffRenderer) TableHeaderCell(out *bytes.Buffer, text []byte, align
int) {
+ if out.Len() > 0 {
+ out.WriteString(" ")
+ }
+ out.Write(text)
+ out.WriteString(" ")
+}
+
+// TODO: This is probably broken
+func (r *roffRenderer) TableCell(out *bytes.Buffer, text []byte, align int) {
+ if out.Len() > 0 {
+ out.WriteString("\t")
+ }
+ out.Write(text)
+ out.WriteString("\t")
+}
+
+func (r *roffRenderer) Footnotes(out *bytes.Buffer, text func() bool) {
+
+}
+
+func (r *roffRenderer) FootnoteItem(out *bytes.Buffer, name, text []byte,
flags int) {
+
+}
+
+func (r *roffRenderer) AutoLink(out *bytes.Buffer, link []byte, kind int) {
+ out.WriteString("\n\\[la]")
+ out.Write(link)
+ out.WriteString("\\[ra]")
+}
+
+func (r *roffRenderer) CodeSpan(out *bytes.Buffer, text []byte) {
+ out.WriteString("\\fB\\fC")
+ escapeSpecialChars(out, text)
+ out.WriteString("\\fR")
+}
+
+func (r *roffRenderer) DoubleEmphasis(out *bytes.Buffer, text []byte) {
+ out.WriteString("\\fB")
+ out.Write(text)
+ out.WriteString("\\fP")
+}
+
+func (r *roffRenderer) Emphasis(out *bytes.Buffer, text []byte) {
+ out.WriteString("\\fI")
+ out.Write(text)
+ out.WriteString("\\fP")
+}
+
+func (r *roffRenderer) Image(out *bytes.Buffer, link []byte, title []byte, alt
[]byte) {
+}
+
+func (r *roffRenderer) LineBreak(out *bytes.Buffer) {
+ out.WriteString("\n.br\n")
+}
+
+func (r *roffRenderer) Link(out *bytes.Buffer, link []byte, title []byte,
content []byte) {
+ r.AutoLink(out, link, 0)
+}
+
+func (r *roffRenderer) RawHtmlTag(out *bytes.Buffer, tag []byte) {
+ out.Write(tag)
+}
+
+func (r *roffRenderer) TripleEmphasis(out *bytes.Buffer, text []byte) {
+ out.WriteString("\\s+2")
+ out.Write(text)
+ out.WriteString("\\s-2")
+}
+
+func (r *roffRenderer) StrikeThrough(out *bytes.Buffer, text []byte) {
+}
+
+func (r *roffRenderer) FootnoteRef(out *bytes.Buffer, ref []byte, id int) {
+
+}
+
+func (r *roffRenderer) Entity(out *bytes.Buffer, entity []byte) {
+ out.WriteString(html.UnescapeString(string(entity)))
+}
+
+func processFooterText(text []byte) []byte {
+ text = bytes.TrimPrefix(text, []byte("% "))
+ newText := []byte{}
+ textArr := strings.Split(string(text), ") ")
+
+ for i, w := range textArr {
+ if i == 0 {
+ w = strings.Replace(w, "(", "\" \"", 1)
+ w = fmt.Sprintf("\"%s\"", w)
+ } else {
+ w = fmt.Sprintf(" \"%s\"", w)
+ }
+ newText = append(newText, []byte(w)...)
+ }
+ newText = append(newText, []byte(" \"\"")...)
+
+ return newText
+}
+
+func (r *roffRenderer) NormalText(out *bytes.Buffer, text []byte) {
+ escapeSpecialChars(out, text)
+}
+
+func (r *roffRenderer) DocumentHeader(out *bytes.Buffer) {
+}
+
+func (r *roffRenderer) DocumentFooter(out *bytes.Buffer) {
+}
+
+func needsBackslash(c byte) bool {
+ for _, r := range []byte("-_&\\~") {
+ if c == r {
+ return true
+ }
+ }
+ return false
+}
+
+func escapeSpecialChars(out *bytes.Buffer, text []byte) {
+ for i := 0; i < len(text); i++ {
+ // escape initial apostrophe or period
+ if len(text) >= 1 && (text[0] == '\'' || text[0] == '.') {
+ out.WriteString("\\&")
+ }
+
+ // directly copy normal characters
+ org := i
+
+ for i < len(text) && !needsBackslash(text[i]) {
+ i++
+ }
+ if i > org {
+ out.Write(text[org:i])
+ }
+
+ // escape a character
+ if i >= len(text) {
+ break
+ }
+ out.WriteByte('\\')
+ out.WriteByte(text[i])
+ }
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/go-md2man-1.0.2+git20150617.e69ac41/md2man.go
new/go-md2man-1.0.5+git20160104.2724a9c/md2man.go
--- old/go-md2man-1.0.2+git20150617.e69ac41/md2man.go 2015-07-28
14:32:58.000000000 +0200
+++ new/go-md2man-1.0.5+git20160104.2724a9c/md2man.go 2016-01-17
10:56:53.000000000 +0100
@@ -6,7 +6,7 @@
"io/ioutil"
"os"
- "github.com/russross/blackfriday"
+ "github.com/cpuguy83/go-md2man/md2man"
)
var inFilePath = flag.String("in", "", "Path to file to be processed")
@@ -28,17 +28,7 @@
os.Exit(1)
}
- renderer := RoffRenderer(0)
- extensions := 0
- extensions |= blackfriday.EXTENSION_NO_INTRA_EMPHASIS
- extensions |= blackfriday.EXTENSION_TABLES
- extensions |= blackfriday.EXTENSION_FENCED_CODE
- extensions |= blackfriday.EXTENSION_AUTOLINK
- extensions |= blackfriday.EXTENSION_SPACE_HEADERS
- extensions |= blackfriday.EXTENSION_FOOTNOTES
- extensions |= blackfriday.EXTENSION_TITLEBLOCK
-
- out := blackfriday.Markdown(doc, renderer, extensions)
+ out := md2man.Render(doc)
outFile, err := os.Create(*outFilePath)
if err != nil {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/go-md2man-1.0.2+git20150617.e69ac41/roff.go
new/go-md2man-1.0.5+git20160104.2724a9c/roff.go
--- old/go-md2man-1.0.2+git20150617.e69ac41/roff.go 2015-07-28
14:32:58.000000000 +0200
+++ new/go-md2man-1.0.5+git20160104.2724a9c/roff.go 1970-01-01
01:00:00.000000000 +0100
@@ -1,269 +0,0 @@
-package main
-
-import (
- "bytes"
- "fmt"
- "html"
- "strings"
-
- "github.com/russross/blackfriday"
-)
-
-type roffRenderer struct{}
-
-func RoffRenderer(flags int) blackfriday.Renderer {
- return &roffRenderer{}
-}
-
-func (r *roffRenderer) GetFlags() int {
- return 0
-}
-
-func (r *roffRenderer) TitleBlock(out *bytes.Buffer, text []byte) {
- out.WriteString(".TH ")
-
- splitText := bytes.Split(text, []byte("\n"))
- for i, line := range splitText {
- line = bytes.TrimPrefix(line, []byte("% "))
- if i == 0 {
- line = bytes.Replace(line, []byte("("), []byte("\"
\""), 1)
- line = bytes.Replace(line, []byte(")"), []byte("\"
\""), 1)
- }
- line = append([]byte("\""), line...)
- line = append(line, []byte("\" ")...)
- out.Write(line)
- }
-
- out.WriteString(" \"\"\n")
-}
-
-func (r *roffRenderer) BlockCode(out *bytes.Buffer, text []byte, lang string) {
- out.WriteString("\n.PP\n.RS\n\n.nf\n")
- escapeSpecialChars(out, text)
- out.WriteString("\n.fi\n.RE\n")
-}
-
-func (r *roffRenderer) BlockQuote(out *bytes.Buffer, text []byte) {
- out.WriteString("\n.PP\n.RS\n")
- out.Write(text)
- out.WriteString("\n.RE\n")
-}
-
-func (r *roffRenderer) BlockHtml(out *bytes.Buffer, text []byte) {
- out.Write(text)
-}
-
-func (r *roffRenderer) Header(out *bytes.Buffer, text func() bool, level int,
id string) {
- marker := out.Len()
-
- switch {
- case marker == 0:
- // This is the doc header
- out.WriteString(".TH ")
- case level == 1:
- out.WriteString("\n\n.SH ")
- case level == 2:
- out.WriteString("\n.SH ")
- default:
- out.WriteString("\n.SS ")
- }
-
- if !text() {
- out.Truncate(marker)
- return
- }
-}
-
-func (r *roffRenderer) HRule(out *bytes.Buffer) {
- out.WriteString("\n.ti 0\n\\l'\\n(.lu'\n")
-}
-
-func (r *roffRenderer) List(out *bytes.Buffer, text func() bool, flags int) {
- marker := out.Len()
- out.WriteString(".IP ")
- if flags&blackfriday.LIST_TYPE_ORDERED != 0 {
- out.WriteString("\\(bu 2")
- } else {
- out.WriteString("\\n+[step" + string(flags) + "]")
- }
- out.WriteString("\n")
- if !text() {
- out.Truncate(marker)
- return
- }
-
-}
-
-func (r *roffRenderer) ListItem(out *bytes.Buffer, text []byte, flags int) {
- out.WriteString("\n\\item ")
- out.Write(text)
-}
-
-func (r *roffRenderer) Paragraph(out *bytes.Buffer, text func() bool) {
- marker := out.Len()
- out.WriteString("\n.PP\n")
- if !text() {
- out.Truncate(marker)
- return
- }
- if marker != 0 {
- out.WriteString("\n")
- }
-}
-
-// TODO: This might now work
-func (r *roffRenderer) Table(out *bytes.Buffer, header []byte, body []byte,
columnData []int) {
- out.WriteString(".TS\nallbox;\n")
-
- out.Write(header)
- out.Write(body)
- out.WriteString("\n.TE\n")
-}
-
-func (r *roffRenderer) TableRow(out *bytes.Buffer, text []byte) {
- if out.Len() > 0 {
- out.WriteString("\n")
- }
- out.Write(text)
- out.WriteString("\n")
-}
-
-func (r *roffRenderer) TableHeaderCell(out *bytes.Buffer, text []byte, align
int) {
- if out.Len() > 0 {
- out.WriteString(" ")
- }
- out.Write(text)
- out.WriteString(" ")
-}
-
-// TODO: This is probably broken
-func (r *roffRenderer) TableCell(out *bytes.Buffer, text []byte, align int) {
- if out.Len() > 0 {
- out.WriteString("\t")
- }
- out.Write(text)
- out.WriteString("\t")
-}
-
-func (r *roffRenderer) Footnotes(out *bytes.Buffer, text func() bool) {
-
-}
-
-func (r *roffRenderer) FootnoteItem(out *bytes.Buffer, name, text []byte,
flags int) {
-
-}
-
-func (r *roffRenderer) AutoLink(out *bytes.Buffer, link []byte, kind int) {
- out.WriteString("\n\\[la]")
- out.Write(link)
- out.WriteString("\\[ra]")
-}
-
-func (r *roffRenderer) CodeSpan(out *bytes.Buffer, text []byte) {
- out.WriteString("\\fB\\fC")
- escapeSpecialChars(out, text)
- out.WriteString("\\fR")
-}
-
-func (r *roffRenderer) DoubleEmphasis(out *bytes.Buffer, text []byte) {
- out.WriteString("\\fB")
- out.Write(text)
- out.WriteString("\\fP")
-}
-
-func (r *roffRenderer) Emphasis(out *bytes.Buffer, text []byte) {
- out.WriteString("\\fI")
- out.Write(text)
- out.WriteString("\\fP")
-}
-
-func (r *roffRenderer) Image(out *bytes.Buffer, link []byte, title []byte, alt
[]byte) {
-}
-
-func (r *roffRenderer) LineBreak(out *bytes.Buffer) {
- out.WriteString("\n.br\n")
-}
-
-func (r *roffRenderer) Link(out *bytes.Buffer, link []byte, title []byte,
content []byte) {
- r.AutoLink(out, link, 0)
-}
-
-func (r *roffRenderer) RawHtmlTag(out *bytes.Buffer, tag []byte) {
- out.Write(tag)
-}
-
-func (r *roffRenderer) TripleEmphasis(out *bytes.Buffer, text []byte) {
- out.WriteString("\\s+2")
- out.Write(text)
- out.WriteString("\\s-2")
-}
-
-func (r *roffRenderer) StrikeThrough(out *bytes.Buffer, text []byte) {
-}
-
-func (r *roffRenderer) FootnoteRef(out *bytes.Buffer, ref []byte, id int) {
-
-}
-
-func (r *roffRenderer) Entity(out *bytes.Buffer, entity []byte) {
- out.WriteString(html.UnescapeString(string(entity)))
-}
-
-func processFooterText(text []byte) []byte {
- text = bytes.TrimPrefix(text, []byte("% "))
- newText := []byte{}
- textArr := strings.Split(string(text), ") ")
-
- for i, w := range textArr {
- if i == 0 {
- w = strings.Replace(w, "(", "\" \"", 1)
- w = fmt.Sprintf("\"%s\"", w)
- } else {
- w = fmt.Sprintf(" \"%s\"", w)
- }
- newText = append(newText, []byte(w)...)
- }
- newText = append(newText, []byte(" \"\"")...)
-
- return newText
-}
-
-func (r *roffRenderer) NormalText(out *bytes.Buffer, text []byte) {
- escapeSpecialChars(out, text)
-}
-
-func (r *roffRenderer) DocumentHeader(out *bytes.Buffer) {
-}
-
-func (r *roffRenderer) DocumentFooter(out *bytes.Buffer) {
-}
-
-func needsBackslash(c byte) bool {
- for _, r := range []byte("-_&\\~") {
- if c == r {
- return true
- }
- }
- return false
-}
-
-func escapeSpecialChars(out *bytes.Buffer, text []byte) {
- for i := 0; i < len(text); i++ {
- // directly copy normal characters
- org := i
-
- for i < len(text) && !needsBackslash(text[i]) {
- i++
- }
- if i > org {
- out.Write(text[org:i])
- }
-
- // escape a character
- if i >= len(text) {
- break
- }
- out.WriteByte('\\')
- out.WriteByte(text[i])
- }
-}