diff --git a/README.md b/README.md new file mode 100644 index 0000000..98b5d5f --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# man-to-html + +Opinionated man page (roff) to html converter. + +### Usage +Here's how [my man page](https://man.eddie.sh) is created: +```bash +./man-to-html edward-shen.man index.html edward-shen "Edward Shen Manual" +``` + +You can also specify version number, page number, and date: +```bash +./man-to-html edward-shen.man index.html edward-shen "Edward Shen Manual" 4.2.0 1 "January 1st, 1970" + +### Prereqs + +- `pandoc` + + + diff --git a/index.html b/index.html index b9181a3..c204b61 100644 --- a/index.html +++ b/index.html @@ -15,12 +15,21 @@ body, p, h1 { } body { margin: 1rem } p { margin-left: 7ch; margin-bottom: 1rem } -.formatted { margin-left: 0; white-space: pre } +.formatted { + width: 80ch; + max-width: 80ch; + display: flex; + justify-content: space-between; +} +.formatted p { margin-left: 0; width:max-content } -

EDWARD-SHEN(7) Edward Shen Manual EDWARD-SHEN(7)

- +
+

EDWARD-SHEN(7)

+

Edward Shen Manual

+

EDWARD-SHEN(7)

+

NAME

edward-shen - some random software developer

SYNOPSIS

@@ -54,7 +63,10 @@ Team TBD.

We would also like to thank all contributors and friends who had helped develop Edward Shen.

COPYRIGHT

This man page is under GPLv3 or later. To use Edward Shen for any purpose, please contact Edward Shen <code@eddie.sh> to request a license.

- -

3.2.4 2019-04-10 EDWARD-SHEN(7)

+
+

3.2.4

+

2019-04-11

+

EDWARD-SHEN(7)

+
diff --git a/man-template.html b/man-template.html index a794161..959009c 100644 --- a/man-template.html +++ b/man-template.html @@ -15,14 +15,26 @@ body, p, h1 { } body { margin: 1rem } p { margin-left: 7ch; margin-bottom: 1rem } -.formatted { margin-left: 0; white-space: pre } +.formatted { + width: 80ch; + max-width: 80ch; + display: flex; + justify-content: space-between; +} +.formatted p { margin-left: 0; width:max-content } -

EDWARD-SHEN(7) Edward Shen Manual EDWARD-SHEN(7)

-$header$ +
+

$cmd$

+

$title$

+

$cmd$

+
$body$ -$footer$ -

3.2.4 2019-04-10 EDWARD-SHEN(7)

+
+

$version$

+

$date$

+

$cmd$

+
diff --git a/man-to-html b/man-to-html index 0bec28b..25abf68 100755 --- a/man-to-html +++ b/man-to-html @@ -1,8 +1,18 @@ #!/usr/bin/env bash -title="Edward Shen Manual" +if [[ $# -ne 4 ]]; then + echo "USAGE: ./man-to-html INPUT OUTPUT COMMAND TITLE [ VERSION PAGE DATE ]" + exit 1 +fi + +set -euo pipefail + +version=${5:-"3.2.4"} +page=${6:-"7"} +date=${7:-"$(date +"%Y-%m-%d")"} pandoc -f man -t html \ --template man-template \ - -M title="$title" \ + -M title="$4" -M date="$date" \ + -M version="$version" -M cmd="${3^^}($page)" \ "$1" > "$2"