未验证 提交 9e8314f6 编写于 作者: M Mislav Marohnić 提交者: GitHub

Merge pull request #2046 from github/man-whatis-fix

Make man pages parseable with `whatis`
......@@ -7,7 +7,7 @@ body {
margin: 0;
font: 15px/1.4 -apple-system,Segoe UI,Helvetica,Arial,sans-serif;
}
pre, code, var, dt, .man-head {
pre, code, var, dt, .man-head, [id="synopsis"] + p {
font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace;
}
header, footer {
......@@ -56,10 +56,14 @@ dt {
dd {
margin-bottom: 1em;
}
pre {
pre, [id="synopsis"] + p {
background: #eee;
padding: 1em 1.5em;
}
[id="synopsis"] + p {
white-space: nowrap;
overflow-x: auto;
}
pre code {
color: inherit;
font-weight: inherit;
......
......@@ -65,6 +65,7 @@ func generateFromFile(mdFile string) error {
Flags: blackfriday.HTMLFlagsNone,
})
roff := &md2roff.RoffRenderer{
Manual: flagManual,
Version: flagVersion,
Date: flagDate,
}
......
......@@ -37,6 +37,7 @@ func escape(src []byte, re *regexp.Regexp) []byte {
}
type RoffRenderer struct {
Manual string
Version string
Date string
Title string
......@@ -171,10 +172,15 @@ func (r *RoffRenderer) renderHeading(buf io.Writer, node *blackfriday.Node) {
num,
escape([]byte(r.Date), headingEscape),
escape([]byte(r.Version), headingEscape),
escape(text, headingEscape),
escape([]byte(r.Manual), headingEscape),
)
io.WriteString(buf, ".nh\n") // disable hyphenation
io.WriteString(buf, ".ad l\n") // disable justification
io.WriteString(buf, ".SH \"NAME\"\n")
fmt.Fprintf(buf, "%s \\- %s\n",
escape(name, roffEscape),
escape(text, roffEscape),
)
case 2:
fmt.Fprintf(buf, ".SH \"%s\"\n", strings.ToUpper(string(escape(text, headingEscape))))
case 3:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册