mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
build(deps): bump github.com/urfave/cli from 1.22.14 to 1.22.16
Bumps [github.com/urfave/cli](https://github.com/urfave/cli) from 1.22.14 to 1.22.16. - [Release notes](https://github.com/urfave/cli/releases) - [Changelog](https://github.com/urfave/cli/blob/main/docs/CHANGELOG.md) - [Commits](https://github.com/urfave/cli/compare/v1.22.14...v1.22.16) --- updated-dependencies: - dependency-name: github.com/urfave/cli dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
@@ -24,7 +24,7 @@ require (
|
|||||||
github.com/seccomp/libseccomp-golang v0.10.0
|
github.com/seccomp/libseccomp-golang v0.10.0
|
||||||
github.com/sirupsen/logrus v1.9.3
|
github.com/sirupsen/logrus v1.9.3
|
||||||
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
|
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
|
||||||
github.com/urfave/cli v1.22.14
|
github.com/urfave/cli v1.22.16
|
||||||
github.com/vishvananda/netlink v1.1.0
|
github.com/vishvananda/netlink v1.1.0
|
||||||
golang.org/x/net v0.24.0
|
golang.org/x/net v0.24.0
|
||||||
golang.org/x/sys v0.22.0
|
golang.org/x/sys v0.22.0
|
||||||
@@ -32,7 +32,7 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
|
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
|
||||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||||
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df // indirect
|
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df // indirect
|
||||||
golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2 // indirect
|
golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2 // indirect
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||||
github.com/checkpoint-restore/go-criu/v6 v6.3.0 h1:mIdrSO2cPNWQY1truPg6uHLXyKHk3Z5Odx4wjKOASzA=
|
github.com/checkpoint-restore/go-criu/v6 v6.3.0 h1:mIdrSO2cPNWQY1truPg6uHLXyKHk3Z5Odx4wjKOASzA=
|
||||||
github.com/checkpoint-restore/go-criu/v6 v6.3.0/go.mod h1:rrRTN/uSwY2X+BPRl/gkulo9gsKOSAeVp9/K2tv7xZI=
|
github.com/checkpoint-restore/go-criu/v6 v6.3.0/go.mod h1:rrRTN/uSwY2X+BPRl/gkulo9gsKOSAeVp9/K2tv7xZI=
|
||||||
github.com/cilium/ebpf v0.16.0 h1:+BiEnHL6Z7lXnlGUsXQPPAE7+kenAd4ES8MQ5min0Ok=
|
github.com/cilium/ebpf v0.16.0 h1:+BiEnHL6Z7lXnlGUsXQPPAE7+kenAd4ES8MQ5min0Ok=
|
||||||
@@ -7,8 +7,9 @@ github.com/containerd/console v1.0.4 h1:F2g4+oChYvBTsASRTz8NP6iIAi97J3TtSAsLbIFn
|
|||||||
github.com/containerd/console v1.0.4/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk=
|
github.com/containerd/console v1.0.4/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk=
|
||||||
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
|
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
|
||||||
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
|
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||||
|
github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc=
|
||||||
|
github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||||
github.com/cyphar/filepath-securejoin v0.3.4 h1:VBWugsJh2ZxJmLFSM06/0qzQyiQX2Qs0ViKrUAcqdZ8=
|
github.com/cyphar/filepath-securejoin v0.3.4 h1:VBWugsJh2ZxJmLFSM06/0qzQyiQX2Qs0ViKrUAcqdZ8=
|
||||||
github.com/cyphar/filepath-securejoin v0.3.4/go.mod h1:8s/MCNJREmFK0H02MF6Ihv1nakJe4L/w3WZLHNkvlYM=
|
github.com/cyphar/filepath-securejoin v0.3.4/go.mod h1:8s/MCNJREmFK0H02MF6Ihv1nakJe4L/w3WZLHNkvlYM=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
@@ -65,6 +66,7 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
|
|||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
|
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
@@ -73,8 +75,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
|
|||||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 h1:kdXcSzyDtseVEc4yCz2qF8ZrQvIDBJLl4S1c3GCXmoI=
|
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 h1:kdXcSzyDtseVEc4yCz2qF8ZrQvIDBJLl4S1c3GCXmoI=
|
||||||
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
|
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
|
||||||
github.com/urfave/cli v1.22.14 h1:ebbhrRiGK2i4naQJr+1Xj92HXZCrK7MsyTS/ob3HnAk=
|
github.com/urfave/cli v1.22.16 h1:MH0k6uJxdwdeWQTwhSO42Pwr4YLrNLwBtg1MRgTqPdQ=
|
||||||
github.com/urfave/cli v1.22.14/go.mod h1:X0eDS6pD6Exaclxm99NJ3FiCDRED7vIHpx2mDOHLvkA=
|
github.com/urfave/cli v1.22.16/go.mod h1:EeJR6BKodywf4zciqrdw6hpCPk68JO9z5LazXZMn5Po=
|
||||||
github.com/vishvananda/netlink v1.1.0 h1:1iyaYNBLmP6L0220aDnYQpo1QEV4t4hJ+xEEhhJH8j0=
|
github.com/vishvananda/netlink v1.1.0 h1:1iyaYNBLmP6L0220aDnYQpo1QEV4t4hJ+xEEhhJH8j0=
|
||||||
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
|
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
|
||||||
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df h1:OviZH7qLw/7ZovXvuNyL3XQl8UFofeikI1NW1Gypu7k=
|
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df h1:OviZH7qLw/7ZovXvuNyL3XQl8UFofeikI1NW1Gypu7k=
|
||||||
|
|||||||
+62
@@ -0,0 +1,62 @@
|
|||||||
|
package md2man
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/russross/blackfriday/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
func fmtListFlags(flags blackfriday.ListType) string {
|
||||||
|
knownFlags := []struct {
|
||||||
|
name string
|
||||||
|
flag blackfriday.ListType
|
||||||
|
}{
|
||||||
|
{"ListTypeOrdered", blackfriday.ListTypeOrdered},
|
||||||
|
{"ListTypeDefinition", blackfriday.ListTypeDefinition},
|
||||||
|
{"ListTypeTerm", blackfriday.ListTypeTerm},
|
||||||
|
{"ListItemContainsBlock", blackfriday.ListItemContainsBlock},
|
||||||
|
{"ListItemBeginningOfList", blackfriday.ListItemBeginningOfList},
|
||||||
|
{"ListItemEndOfList", blackfriday.ListItemEndOfList},
|
||||||
|
}
|
||||||
|
|
||||||
|
var f []string
|
||||||
|
for _, kf := range knownFlags {
|
||||||
|
if flags&kf.flag != 0 {
|
||||||
|
f = append(f, kf.name)
|
||||||
|
flags &^= kf.flag
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if flags != 0 {
|
||||||
|
f = append(f, fmt.Sprintf("Unknown(%#x)", flags))
|
||||||
|
}
|
||||||
|
return strings.Join(f, "|")
|
||||||
|
}
|
||||||
|
|
||||||
|
type debugDecorator struct {
|
||||||
|
blackfriday.Renderer
|
||||||
|
}
|
||||||
|
|
||||||
|
func depth(node *blackfriday.Node) int {
|
||||||
|
d := 0
|
||||||
|
for n := node.Parent; n != nil; n = n.Parent {
|
||||||
|
d++
|
||||||
|
}
|
||||||
|
return d
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *debugDecorator) RenderNode(w io.Writer, node *blackfriday.Node, entering bool) blackfriday.WalkStatus {
|
||||||
|
fmt.Fprintf(os.Stderr, "%s%s %v %v\n",
|
||||||
|
strings.Repeat(" ", depth(node)),
|
||||||
|
map[bool]string{true: "+", false: "-"}[entering],
|
||||||
|
node,
|
||||||
|
fmtListFlags(node.ListFlags))
|
||||||
|
var b strings.Builder
|
||||||
|
status := d.Renderer.RenderNode(io.MultiWriter(&b, w), node, entering)
|
||||||
|
if b.Len() > 0 {
|
||||||
|
fmt.Fprintf(os.Stderr, ">> %q\n", b.String())
|
||||||
|
}
|
||||||
|
return status
|
||||||
|
}
|
||||||
+11
-2
@@ -1,14 +1,23 @@
|
|||||||
package md2man
|
package md2man
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/russross/blackfriday/v2"
|
"github.com/russross/blackfriday/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Render converts a markdown document into a roff formatted document.
|
// Render converts a markdown document into a roff formatted document.
|
||||||
func Render(doc []byte) []byte {
|
func Render(doc []byte) []byte {
|
||||||
renderer := NewRoffRenderer()
|
renderer := NewRoffRenderer()
|
||||||
|
var r blackfriday.Renderer = renderer
|
||||||
|
if v, _ := strconv.ParseBool(os.Getenv("MD2MAN_DEBUG")); v {
|
||||||
|
r = &debugDecorator{Renderer: r}
|
||||||
|
}
|
||||||
|
|
||||||
return blackfriday.Run(doc,
|
return blackfriday.Run(doc,
|
||||||
[]blackfriday.Option{blackfriday.WithRenderer(renderer),
|
[]blackfriday.Option{
|
||||||
blackfriday.WithExtensions(renderer.GetExtensions())}...)
|
blackfriday.WithRenderer(r),
|
||||||
|
blackfriday.WithExtensions(renderer.GetExtensions()),
|
||||||
|
}...)
|
||||||
}
|
}
|
||||||
|
|||||||
+136
-64
@@ -1,6 +1,8 @@
|
|||||||
package md2man
|
package md2man
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
@@ -12,68 +14,72 @@ import (
|
|||||||
// roffRenderer implements the blackfriday.Renderer interface for creating
|
// roffRenderer implements the blackfriday.Renderer interface for creating
|
||||||
// roff format (manpages) from markdown text
|
// roff format (manpages) from markdown text
|
||||||
type roffRenderer struct {
|
type roffRenderer struct {
|
||||||
extensions blackfriday.Extensions
|
|
||||||
listCounters []int
|
listCounters []int
|
||||||
firstHeader bool
|
firstHeader bool
|
||||||
firstDD bool
|
|
||||||
listDepth int
|
listDepth int
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
titleHeader = ".TH "
|
titleHeader = ".TH "
|
||||||
topLevelHeader = "\n\n.SH "
|
topLevelHeader = "\n\n.SH "
|
||||||
secondLevelHdr = "\n.SH "
|
secondLevelHdr = "\n.SH "
|
||||||
otherHeader = "\n.SS "
|
otherHeader = "\n.SS "
|
||||||
crTag = "\n"
|
crTag = "\n"
|
||||||
emphTag = "\\fI"
|
emphTag = "\\fI"
|
||||||
emphCloseTag = "\\fP"
|
emphCloseTag = "\\fP"
|
||||||
strongTag = "\\fB"
|
strongTag = "\\fB"
|
||||||
strongCloseTag = "\\fP"
|
strongCloseTag = "\\fP"
|
||||||
breakTag = "\n.br\n"
|
breakTag = "\n.br\n"
|
||||||
paraTag = "\n.PP\n"
|
paraTag = "\n.PP\n"
|
||||||
hruleTag = "\n.ti 0\n\\l'\\n(.lu'\n"
|
hruleTag = "\n.ti 0\n\\l'\\n(.lu'\n"
|
||||||
linkTag = "\n\\[la]"
|
linkTag = "\n\\[la]"
|
||||||
linkCloseTag = "\\[ra]"
|
linkCloseTag = "\\[ra]"
|
||||||
codespanTag = "\\fB\\fC"
|
codespanTag = "\\fB"
|
||||||
codespanCloseTag = "\\fR"
|
codespanCloseTag = "\\fR"
|
||||||
codeTag = "\n.PP\n.RS\n\n.nf\n"
|
codeTag = "\n.EX\n"
|
||||||
codeCloseTag = "\n.fi\n.RE\n"
|
codeCloseTag = ".EE\n" // Do not prepend a newline character since code blocks, by definition, include a newline already (or at least as how blackfriday gives us on).
|
||||||
quoteTag = "\n.PP\n.RS\n"
|
quoteTag = "\n.PP\n.RS\n"
|
||||||
quoteCloseTag = "\n.RE\n"
|
quoteCloseTag = "\n.RE\n"
|
||||||
listTag = "\n.RS\n"
|
listTag = "\n.RS\n"
|
||||||
listCloseTag = "\n.RE\n"
|
listCloseTag = ".RE\n"
|
||||||
dtTag = "\n.TP\n"
|
dtTag = "\n.TP\n"
|
||||||
dd2Tag = "\n"
|
dd2Tag = "\n"
|
||||||
tableStart = "\n.TS\nallbox;\n"
|
tableStart = "\n.TS\nallbox;\n"
|
||||||
tableEnd = ".TE\n"
|
tableEnd = ".TE\n"
|
||||||
tableCellStart = "T{\n"
|
tableCellStart = "T{\n"
|
||||||
tableCellEnd = "\nT}\n"
|
tableCellEnd = "\nT}\n"
|
||||||
|
tablePreprocessor = `'\" t`
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewRoffRenderer creates a new blackfriday Renderer for generating roff documents
|
// NewRoffRenderer creates a new blackfriday Renderer for generating roff documents
|
||||||
// from markdown
|
// from markdown
|
||||||
func NewRoffRenderer() *roffRenderer { // nolint: golint
|
func NewRoffRenderer() *roffRenderer { // nolint: golint
|
||||||
var extensions blackfriday.Extensions
|
return &roffRenderer{}
|
||||||
|
|
||||||
extensions |= blackfriday.NoIntraEmphasis
|
|
||||||
extensions |= blackfriday.Tables
|
|
||||||
extensions |= blackfriday.FencedCode
|
|
||||||
extensions |= blackfriday.SpaceHeadings
|
|
||||||
extensions |= blackfriday.Footnotes
|
|
||||||
extensions |= blackfriday.Titleblock
|
|
||||||
extensions |= blackfriday.DefinitionLists
|
|
||||||
return &roffRenderer{
|
|
||||||
extensions: extensions,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetExtensions returns the list of extensions used by this renderer implementation
|
// GetExtensions returns the list of extensions used by this renderer implementation
|
||||||
func (r *roffRenderer) GetExtensions() blackfriday.Extensions {
|
func (*roffRenderer) GetExtensions() blackfriday.Extensions {
|
||||||
return r.extensions
|
return blackfriday.NoIntraEmphasis |
|
||||||
|
blackfriday.Tables |
|
||||||
|
blackfriday.FencedCode |
|
||||||
|
blackfriday.SpaceHeadings |
|
||||||
|
blackfriday.Footnotes |
|
||||||
|
blackfriday.Titleblock |
|
||||||
|
blackfriday.DefinitionLists
|
||||||
}
|
}
|
||||||
|
|
||||||
// RenderHeader handles outputting the header at document start
|
// RenderHeader handles outputting the header at document start
|
||||||
func (r *roffRenderer) RenderHeader(w io.Writer, ast *blackfriday.Node) {
|
func (r *roffRenderer) RenderHeader(w io.Writer, ast *blackfriday.Node) {
|
||||||
|
// We need to walk the tree to check if there are any tables.
|
||||||
|
// If there are, we need to enable the roff table preprocessor.
|
||||||
|
ast.Walk(func(node *blackfriday.Node, entering bool) blackfriday.WalkStatus {
|
||||||
|
if node.Type == blackfriday.Table {
|
||||||
|
out(w, tablePreprocessor+"\n")
|
||||||
|
return blackfriday.Terminate
|
||||||
|
}
|
||||||
|
return blackfriday.GoToNext
|
||||||
|
})
|
||||||
|
|
||||||
// disable hyphenation
|
// disable hyphenation
|
||||||
out(w, ".nh\n")
|
out(w, ".nh\n")
|
||||||
}
|
}
|
||||||
@@ -86,12 +92,27 @@ func (r *roffRenderer) RenderFooter(w io.Writer, ast *blackfriday.Node) {
|
|||||||
// RenderNode is called for each node in a markdown document; based on the node
|
// RenderNode is called for each node in a markdown document; based on the node
|
||||||
// type the equivalent roff output is sent to the writer
|
// type the equivalent roff output is sent to the writer
|
||||||
func (r *roffRenderer) RenderNode(w io.Writer, node *blackfriday.Node, entering bool) blackfriday.WalkStatus {
|
func (r *roffRenderer) RenderNode(w io.Writer, node *blackfriday.Node, entering bool) blackfriday.WalkStatus {
|
||||||
|
walkAction := blackfriday.GoToNext
|
||||||
var walkAction = blackfriday.GoToNext
|
|
||||||
|
|
||||||
switch node.Type {
|
switch node.Type {
|
||||||
case blackfriday.Text:
|
case blackfriday.Text:
|
||||||
escapeSpecialChars(w, node.Literal)
|
// Special case: format the NAME section as required for proper whatis parsing.
|
||||||
|
// Refer to the lexgrog(1) and groff_man(7) manual pages for details.
|
||||||
|
if node.Parent != nil &&
|
||||||
|
node.Parent.Type == blackfriday.Paragraph &&
|
||||||
|
node.Parent.Prev != nil &&
|
||||||
|
node.Parent.Prev.Type == blackfriday.Heading &&
|
||||||
|
node.Parent.Prev.FirstChild != nil &&
|
||||||
|
bytes.EqualFold(node.Parent.Prev.FirstChild.Literal, []byte("NAME")) {
|
||||||
|
before, after, found := bytes.Cut(node.Literal, []byte(" - "))
|
||||||
|
escapeSpecialChars(w, before)
|
||||||
|
if found {
|
||||||
|
out(w, ` \- `)
|
||||||
|
escapeSpecialChars(w, after)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
escapeSpecialChars(w, node.Literal)
|
||||||
|
}
|
||||||
case blackfriday.Softbreak:
|
case blackfriday.Softbreak:
|
||||||
out(w, crTag)
|
out(w, crTag)
|
||||||
case blackfriday.Hardbreak:
|
case blackfriday.Hardbreak:
|
||||||
@@ -109,9 +130,16 @@ func (r *roffRenderer) RenderNode(w io.Writer, node *blackfriday.Node, entering
|
|||||||
out(w, strongCloseTag)
|
out(w, strongCloseTag)
|
||||||
}
|
}
|
||||||
case blackfriday.Link:
|
case blackfriday.Link:
|
||||||
if !entering {
|
// Don't render the link text for automatic links, because this
|
||||||
out(w, linkTag+string(node.LinkData.Destination)+linkCloseTag)
|
// will only duplicate the URL in the roff output.
|
||||||
|
// See https://daringfireball.net/projects/markdown/syntax#autolink
|
||||||
|
if !bytes.Equal(node.LinkData.Destination, node.FirstChild.Literal) {
|
||||||
|
out(w, string(node.FirstChild.Literal))
|
||||||
}
|
}
|
||||||
|
// Hyphens in a link must be escaped to avoid word-wrap in the rendered man page.
|
||||||
|
escapedLink := strings.ReplaceAll(string(node.LinkData.Destination), "-", "\\-")
|
||||||
|
out(w, linkTag+escapedLink+linkCloseTag)
|
||||||
|
walkAction = blackfriday.SkipChildren
|
||||||
case blackfriday.Image:
|
case blackfriday.Image:
|
||||||
// ignore images
|
// ignore images
|
||||||
walkAction = blackfriday.SkipChildren
|
walkAction = blackfriday.SkipChildren
|
||||||
@@ -122,14 +150,25 @@ func (r *roffRenderer) RenderNode(w io.Writer, node *blackfriday.Node, entering
|
|||||||
case blackfriday.Document:
|
case blackfriday.Document:
|
||||||
break
|
break
|
||||||
case blackfriday.Paragraph:
|
case blackfriday.Paragraph:
|
||||||
// roff .PP markers break lists
|
|
||||||
if r.listDepth > 0 {
|
|
||||||
return blackfriday.GoToNext
|
|
||||||
}
|
|
||||||
if entering {
|
if entering {
|
||||||
out(w, paraTag)
|
if r.listDepth > 0 {
|
||||||
|
// roff .PP markers break lists
|
||||||
|
if node.Prev != nil { // continued paragraph
|
||||||
|
if node.Prev.Type == blackfriday.List && node.Prev.ListFlags&blackfriday.ListTypeDefinition == 0 {
|
||||||
|
out(w, ".IP\n")
|
||||||
|
} else {
|
||||||
|
out(w, crTag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if node.Prev != nil && node.Prev.Type == blackfriday.Heading {
|
||||||
|
out(w, crTag)
|
||||||
|
} else {
|
||||||
|
out(w, paraTag)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
out(w, crTag)
|
if node.Next == nil || node.Next.Type != blackfriday.List {
|
||||||
|
out(w, crTag)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case blackfriday.BlockQuote:
|
case blackfriday.BlockQuote:
|
||||||
if entering {
|
if entering {
|
||||||
@@ -160,6 +199,11 @@ func (r *roffRenderer) RenderNode(w io.Writer, node *blackfriday.Node, entering
|
|||||||
r.handleTableCell(w, node, entering)
|
r.handleTableCell(w, node, entering)
|
||||||
case blackfriday.HTMLSpan:
|
case blackfriday.HTMLSpan:
|
||||||
// ignore other HTML tags
|
// ignore other HTML tags
|
||||||
|
case blackfriday.HTMLBlock:
|
||||||
|
if bytes.HasPrefix(node.Literal, []byte("<!--")) {
|
||||||
|
break // ignore comments, no warning
|
||||||
|
}
|
||||||
|
fmt.Fprintln(os.Stderr, "WARNING: go-md2man does not handle node type "+node.Type.String())
|
||||||
default:
|
default:
|
||||||
fmt.Fprintln(os.Stderr, "WARNING: go-md2man does not handle node type "+node.Type.String())
|
fmt.Fprintln(os.Stderr, "WARNING: go-md2man does not handle node type "+node.Type.String())
|
||||||
}
|
}
|
||||||
@@ -187,6 +231,10 @@ func (r *roffRenderer) handleHeading(w io.Writer, node *blackfriday.Node, enteri
|
|||||||
func (r *roffRenderer) handleList(w io.Writer, node *blackfriday.Node, entering bool) {
|
func (r *roffRenderer) handleList(w io.Writer, node *blackfriday.Node, entering bool) {
|
||||||
openTag := listTag
|
openTag := listTag
|
||||||
closeTag := listCloseTag
|
closeTag := listCloseTag
|
||||||
|
if (entering && r.listDepth == 0) || (!entering && r.listDepth == 1) {
|
||||||
|
openTag = crTag
|
||||||
|
closeTag = ""
|
||||||
|
}
|
||||||
if node.ListFlags&blackfriday.ListTypeDefinition != 0 {
|
if node.ListFlags&blackfriday.ListTypeDefinition != 0 {
|
||||||
// tags for definition lists handled within Item node
|
// tags for definition lists handled within Item node
|
||||||
openTag = ""
|
openTag = ""
|
||||||
@@ -215,23 +263,25 @@ func (r *roffRenderer) handleItem(w io.Writer, node *blackfriday.Node, entering
|
|||||||
} else if node.ListFlags&blackfriday.ListTypeTerm != 0 {
|
} else if node.ListFlags&blackfriday.ListTypeTerm != 0 {
|
||||||
// DT (definition term): line just before DD (see below).
|
// DT (definition term): line just before DD (see below).
|
||||||
out(w, dtTag)
|
out(w, dtTag)
|
||||||
r.firstDD = true
|
|
||||||
} else if node.ListFlags&blackfriday.ListTypeDefinition != 0 {
|
} else if node.ListFlags&blackfriday.ListTypeDefinition != 0 {
|
||||||
// DD (definition description): line that starts with ": ".
|
// DD (definition description): line that starts with ": ".
|
||||||
//
|
//
|
||||||
// We have to distinguish between the first DD and the
|
// We have to distinguish between the first DD and the
|
||||||
// subsequent ones, as there should be no vertical
|
// subsequent ones, as there should be no vertical
|
||||||
// whitespace between the DT and the first DD.
|
// whitespace between the DT and the first DD.
|
||||||
if r.firstDD {
|
if node.Prev != nil && node.Prev.ListFlags&(blackfriday.ListTypeTerm|blackfriday.ListTypeDefinition) == blackfriday.ListTypeDefinition {
|
||||||
r.firstDD = false
|
if node.Prev.Type == blackfriday.Item &&
|
||||||
} else {
|
node.Prev.LastChild != nil &&
|
||||||
out(w, dd2Tag)
|
node.Prev.LastChild.Type == blackfriday.List &&
|
||||||
|
node.Prev.LastChild.ListFlags&blackfriday.ListTypeDefinition == 0 {
|
||||||
|
out(w, ".IP\n")
|
||||||
|
} else {
|
||||||
|
out(w, dd2Tag)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
out(w, ".IP \\(bu 2\n")
|
out(w, ".IP \\(bu 2\n")
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
out(w, "\n")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,7 +304,7 @@ func (r *roffRenderer) handleTableCell(w io.Writer, node *blackfriday.Node, ente
|
|||||||
start = "\t"
|
start = "\t"
|
||||||
}
|
}
|
||||||
if node.IsHeader {
|
if node.IsHeader {
|
||||||
start += codespanTag
|
start += strongTag
|
||||||
} else if nodeLiteralSize(node) > 30 {
|
} else if nodeLiteralSize(node) > 30 {
|
||||||
start += tableCellStart
|
start += tableCellStart
|
||||||
}
|
}
|
||||||
@@ -262,7 +312,7 @@ func (r *roffRenderer) handleTableCell(w io.Writer, node *blackfriday.Node, ente
|
|||||||
} else {
|
} else {
|
||||||
var end string
|
var end string
|
||||||
if node.IsHeader {
|
if node.IsHeader {
|
||||||
end = codespanCloseTag
|
end = strongCloseTag
|
||||||
} else if nodeLiteralSize(node) > 30 {
|
} else if nodeLiteralSize(node) > 30 {
|
||||||
end = tableCellEnd
|
end = tableCellEnd
|
||||||
}
|
}
|
||||||
@@ -310,6 +360,28 @@ func out(w io.Writer, output string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func escapeSpecialChars(w io.Writer, text []byte) {
|
func escapeSpecialChars(w io.Writer, text []byte) {
|
||||||
|
scanner := bufio.NewScanner(bytes.NewReader(text))
|
||||||
|
|
||||||
|
// count the number of lines in the text
|
||||||
|
// we need to know this to avoid adding a newline after the last line
|
||||||
|
n := bytes.Count(text, []byte{'\n'})
|
||||||
|
idx := 0
|
||||||
|
|
||||||
|
for scanner.Scan() {
|
||||||
|
dt := scanner.Bytes()
|
||||||
|
if idx < n {
|
||||||
|
idx++
|
||||||
|
dt = append(dt, '\n')
|
||||||
|
}
|
||||||
|
escapeSpecialCharsLine(w, dt)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := scanner.Err(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func escapeSpecialCharsLine(w io.Writer, text []byte) {
|
||||||
for i := 0; i < len(text); i++ {
|
for i := 0; i < len(text); i++ {
|
||||||
// escape initial apostrophe or period
|
// escape initial apostrophe or period
|
||||||
if len(text) >= 1 && (text[0] == '\'' || text[0] == '.') {
|
if len(text) >= 1 && (text[0] == '\'' || text[0] == '.') {
|
||||||
|
|||||||
Vendored
+2
-2
@@ -22,7 +22,7 @@ github.com/containerd/console
|
|||||||
## explicit; go 1.12
|
## explicit; go 1.12
|
||||||
github.com/coreos/go-systemd/v22/activation
|
github.com/coreos/go-systemd/v22/activation
|
||||||
github.com/coreos/go-systemd/v22/dbus
|
github.com/coreos/go-systemd/v22/dbus
|
||||||
# github.com/cpuguy83/go-md2man/v2 v2.0.2
|
# github.com/cpuguy83/go-md2man/v2 v2.0.5
|
||||||
## explicit; go 1.11
|
## explicit; go 1.11
|
||||||
github.com/cpuguy83/go-md2man/v2/md2man
|
github.com/cpuguy83/go-md2man/v2/md2man
|
||||||
# github.com/cyphar/filepath-securejoin v0.3.4
|
# github.com/cyphar/filepath-securejoin v0.3.4
|
||||||
@@ -68,7 +68,7 @@ github.com/sirupsen/logrus/hooks/test
|
|||||||
# github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
|
# github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
|
||||||
## explicit
|
## explicit
|
||||||
github.com/syndtr/gocapability/capability
|
github.com/syndtr/gocapability/capability
|
||||||
# github.com/urfave/cli v1.22.14
|
# github.com/urfave/cli v1.22.16
|
||||||
## explicit; go 1.11
|
## explicit; go 1.11
|
||||||
github.com/urfave/cli
|
github.com/urfave/cli
|
||||||
# github.com/vishvananda/netlink v1.1.0
|
# github.com/vishvananda/netlink v1.1.0
|
||||||
|
|||||||
Reference in New Issue
Block a user