Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use .EX/.EE to typeset code blocks #95

Merged
merged 3 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 16 additions & 11 deletions go-md2man.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,27 @@ go-md2man 1 "January 2015" go-md2man "User Manual"
==================================================

# NAME
go-md2man - Convert markdown files into manpages
go-md2man - Convert markdown files into manpages

# SYNOPSIS
go-md2man -in=[/path/to/md/file] -out=[/path/to/output]
**go-md2man** [**-in**=*/path/to/md/file*] [**-out**=*/path/to/output*]

# Description
go-md2man converts standard markdown formatted documents into manpages. It is
written purely in Go so as to reduce dependencies on 3rd party libs.
# DESCRIPTION
**go-md2man** converts standard markdown formatted documents into manpages. It is
written purely in Go so as to reduce dependencies on 3rd party libs.

By default, the input is stdin and the output is stdout.
By default, the input is stdin and the output is stdout.

# Example
Convert the markdown file "go-md2man.1.md" into a manpage.
# EXAMPLES
Convert the markdown file *go-md2man.1.md* into a manpage:
```
go-md2man < go-md2man.1.md > go-md2man.1
```

go-md2man -in=go-md2man.1.md -out=go-md2man.1.out
Same, but using command line arguments instead of shell redirection:
```
go-md2man -in=go-md2man.1.md -out=go-md2man.1
```

# HISTORY
January 2015, Originally compiled by Brian Goff( cpuguy83@gmail.com )

January 2015, Originally compiled by Brian Goff (cpuguy83@gmail.com).
4 changes: 2 additions & 2 deletions md2man/roff.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
"os"
"strings"

"github.com/russross/blackfriday/v2"

Check failure on line 10 in md2man/roff.go

View workflow job for this annotation

GitHub Actions / lint

"github.com/russross/blackfriday/v2" imported but not used (typecheck)
)

// roffRenderer implements the blackfriday.Renderer interface for creating
// roff format (manpages) from markdown text
type roffRenderer struct {
extensions blackfriday.Extensions

Check failure on line 16 in md2man/roff.go

View workflow job for this annotation

GitHub Actions / lint

undeclared name: `blackfriday` (typecheck)
listCounters []int
firstHeader bool
firstDD bool
Expand All @@ -37,8 +37,8 @@
linkCloseTag = "\\[ra]"
codespanTag = "\\fB\\fC"
codespanCloseTag = "\\fR"
codeTag = "\n.PP\n.RS\n\n.nf\n"
codeCloseTag = "\n.fi\n.RE\n"
codeTag = "\n.EX\n"
codeCloseTag = "\n.EE\n"
quoteTag = "\n.PP\n.RS\n"
quoteCloseTag = "\n.RE\n"
listTag = "\n.RS\n"
Expand Down Expand Up @@ -69,12 +69,12 @@
}

// GetExtensions returns the list of extensions used by this renderer implementation
func (r *roffRenderer) GetExtensions() blackfriday.Extensions {

Check failure on line 72 in md2man/roff.go

View workflow job for this annotation

GitHub Actions / lint

undeclared name: `blackfriday` (typecheck)
return r.extensions
}

// RenderHeader handles outputting the header at document start
func (r *roffRenderer) RenderHeader(w io.Writer, ast *blackfriday.Node) {

Check failure on line 77 in md2man/roff.go

View workflow job for this annotation

GitHub Actions / lint

undeclared name: `blackfriday` (typecheck)
// disable hyphenation
out(w, ".nh\n")
}
Expand Down
11 changes: 11 additions & 0 deletions md2man/roff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@
import (
"testing"

"github.com/russross/blackfriday/v2"

Check failure on line 6 in md2man/roff_test.go

View workflow job for this annotation

GitHub Actions / lint

"github.com/russross/blackfriday/v2" imported but not used (typecheck)
)

type TestParams struct {
extensions blackfriday.Extensions
}

func TestCodeBlocks(t *testing.T) {
tests := []string{
"```\nsome code\n```\n",
".nh\n\n.EX\nsome code\n\n.EE\n",

"```bash\necho foo\n```\n",
".nh\n\n.EX\necho foo\n\n.EE\n",
}
doTestsParam(t, tests, TestParams{blackfriday.FencedCode})
}

func TestEmphasis(t *testing.T) {
var tests = []string{
"nothing inline\n",
Expand Down