From 2008073fbeb22b13888ccd2671c7fe13d396404f Mon Sep 17 00:00:00 2001 From: Casey Tucker Date: Tue, 8 May 2018 11:22:29 -0700 Subject: [PATCH 01/21] Initial try at adding manpage support via mandoc Co-authored-by: Jordan Webb Co-authored-by: Anthony Riley --- lib/github-markup.rb | 2 +- lib/github/commands/man2html | 3 +++ lib/github/markup.rb | 1 + lib/github/markups.rb | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) create mode 100755 lib/github/commands/man2html diff --git a/lib/github-markup.rb b/lib/github-markup.rb index 259319e2..0979d20e 100644 --- a/lib/github-markup.rb +++ b/lib/github-markup.rb @@ -1,6 +1,6 @@ module GitHub module Markup - VERSION = '3.0.1' + VERSION = '3.0.2' Version = VERSION end end diff --git a/lib/github/commands/man2html b/lib/github/commands/man2html new file mode 100755 index 00000000..1acc7326 --- /dev/null +++ b/lib/github/commands/man2html @@ -0,0 +1,3 @@ +#!/bin/sh +what=${1:--} +cat "$what" | mandoc -Kutf-8 -Thtml diff --git a/lib/github/markup.rb b/lib/github/markup.rb index 5a78d006..8d0e4cd6 100644 --- a/lib/github/markup.rb +++ b/lib/github/markup.rb @@ -19,6 +19,7 @@ module Markups MARKUP_RDOC = :rdoc MARKUP_RST = :rst MARKUP_TEXTILE = :textile + MARKUP_MANPAGE = :manpage end module Markup diff --git a/lib/github/markups.rb b/lib/github/markups.rb index 440e0dbf..d7fb3322 100644 --- a/lib/github/markups.rb +++ b/lib/github/markups.rb @@ -52,3 +52,5 @@ ) command(::GitHub::Markups::MARKUP_POD, :pod2html, /pod/, ["Pod"], "pod") + +command(::GitHub::Markups::MARKUP_MANPAGE, :man2html, /1|2|3|4|5|6|7|8|man|mdoc/, ["Roff"], "manpage") From d6643c357c331d331eb250aa921b310d3d8037fe Mon Sep 17 00:00:00 2001 From: Casey Tucker Date: Tue, 8 May 2018 18:48:30 -0700 Subject: [PATCH 02/21] adding xslt transformation Co-authored-by: Jordan Webb Co-authored-by: Anthony Riley --- lib/github/commands/man2html | 2 +- lib/github/commands/man2html.xslt | 44 +++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 lib/github/commands/man2html.xslt diff --git a/lib/github/commands/man2html b/lib/github/commands/man2html index 1acc7326..c924cbff 100755 --- a/lib/github/commands/man2html +++ b/lib/github/commands/man2html @@ -1,3 +1,3 @@ #!/bin/sh what=${1:--} -cat "$what" | mandoc -Kutf-8 -Thtml +cat "$what" | mandoc -Kutf-8 -Thtml | xmlstarlet tr $(dirname "$0")/man2html.xslt diff --git a/lib/github/commands/man2html.xslt b/lib/github/commands/man2html.xslt new file mode 100644 index 00000000..72b4f0fe --- /dev/null +++ b/lib/github/commands/man2html.xslt @@ -0,0 +1,44 @@ + + + + + + + width:100% + + + + + + + + width:100%;text-align:center;border:none + + + + + +
+ +
+
+ + +

Date:

+
+ +

OS:

+
+ + + + + + + + + + +
From 3deeea0b0252b8a0aff7b5fc809509d6859515e0 Mon Sep 17 00:00:00 2001 From: Casey Tucker Date: Wed, 9 May 2018 12:47:43 -0700 Subject: [PATCH 03/21] stripping html/body, non-linked h1, ltitle formatted Co-authored-by: Jordan Webb Co-authored-by: Anthony Riley --- lib/github/commands/man2html | 2 +- lib/github/commands/man2html.xslt | 45 ++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/lib/github/commands/man2html b/lib/github/commands/man2html index c924cbff..f7d74188 100755 --- a/lib/github/commands/man2html +++ b/lib/github/commands/man2html @@ -1,3 +1,3 @@ #!/bin/sh what=${1:--} -cat "$what" | mandoc -Kutf-8 -Thtml | xmlstarlet tr $(dirname "$0")/man2html.xslt +cat "$what" | mandoc -Kutf-8 -Thtml | xmlstarlet tr $(dirname "$0")/man2html.xslt | sed 's/<\/\?html>//g' | sed 's/<\/\?body>//g' diff --git a/lib/github/commands/man2html.xslt b/lib/github/commands/man2html.xslt index 72b4f0fe..470aa66f 100644 --- a/lib/github/commands/man2html.xslt +++ b/lib/github/commands/man2html.xslt @@ -1,23 +1,28 @@ + + + - - - width:100% - - - - - - - - width:100%;text-align:center;border:none - - - +
+ +
+ + + +

+
+ + +

+
+
+ + +
@@ -30,14 +35,22 @@

OS:

+ + + + + + - - From f1498418bd1600e47e24cac6cbe59bcfbbfca5d7 Mon Sep 17 00:00:00 2001 From: Jordan Webb Date: Tue, 30 Oct 2018 16:08:45 -0500 Subject: [PATCH 04/21] Incorporate feedback, hook into testing --- lib/github/commands/man2html | 4 +- lib/github/commands/man2html.xslt | 118 ++++++++++++++++-------------- lib/github/markups.rb | 2 +- test/markup_test.rb | 5 +- 4 files changed, 71 insertions(+), 58 deletions(-) diff --git a/lib/github/commands/man2html b/lib/github/commands/man2html index f7d74188..2d4071e9 100755 --- a/lib/github/commands/man2html +++ b/lib/github/commands/man2html @@ -1,3 +1,3 @@ #!/bin/sh -what=${1:--} -cat "$what" | mandoc -Kutf-8 -Thtml | xmlstarlet tr $(dirname "$0")/man2html.xslt | sed 's/<\/\?html>//g' | sed 's/<\/\?body>//g' +mandoc -Thtml -Ofragment "$@" \ + | xmlstarlet tr --html "$(dirname "$0")/man2html.xslt" - diff --git a/lib/github/commands/man2html.xslt b/lib/github/commands/man2html.xslt index 470aa66f..058479e4 100644 --- a/lib/github/commands/man2html.xslt +++ b/lib/github/commands/man2html.xslt @@ -1,57 +1,69 @@ + + + + + + - - - - -
- -
-
- - -

-
- - -

-
-
- - - - -
-
- -
-
- - -

Date:

-
- -

OS:

-
- - - - - - - - - - - - - - + + +

+
+ + + + + + + + + + width: 100%; + + + + + + + text-align: right; + + + + + + + text-align: center; + + + + + + + display: inline; + + + + + + + font-style: italic; + + + + + + + font-weight: bold; + + + + + + + font-weight: bold; font-family: inherit; + + +
diff --git a/lib/github/markups.rb b/lib/github/markups.rb index d7fb3322..d6a9ebd9 100644 --- a/lib/github/markups.rb +++ b/lib/github/markups.rb @@ -53,4 +53,4 @@ command(::GitHub::Markups::MARKUP_POD, :pod2html, /pod/, ["Pod"], "pod") -command(::GitHub::Markups::MARKUP_MANPAGE, :man2html, /1|2|3|4|5|6|7|8|man|mdoc/, ["Roff"], "manpage") +command(::GitHub::Markups::MARKUP_MANPAGE, :man2html, /([1-9n][a-z]*|man|mdoc)(\.in)?/, ["Roff"], "manpage") diff --git a/test/markup_test.rb b/test/markup_test.rb index eedaccdf..25d94ac4 100644 --- a/test/markup_test.rb +++ b/test/markup_test.rb @@ -74,7 +74,7 @@ def call message end end - + def test_knows_what_it_can_and_cannot_render assert_equal false, GitHub::Markup.can_render?('README.html', '

Title

') assert_equal true, GitHub::Markup.can_render?('README.markdown', '=== Title') @@ -92,8 +92,9 @@ def test_each_render_has_a_name assert_equal "asciidoctor", GitHub::Markup.renderer('README.adoc', '== Title').name assert_equal "restructuredtext", GitHub::Markup.renderer('README.rst', 'Title').name assert_equal "pod", GitHub::Markup.renderer('README.pod', '=begin').name + assert_equal "manpage", GitHub::Markup.renderer('README.mdoc', '.Dd $Mdocdate: March 23 1981 $').name end - + def test_rendering_by_symbol assert_equal '

test

', GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, '`test`').strip end From f00e30c8f2e69fe63e0427e6be85a1f8e828e20c Mon Sep 17 00:00:00 2001 From: Jordan Webb Date: Tue, 30 Oct 2018 16:10:46 -0500 Subject: [PATCH 05/21] Forgot new test fixtures --- test/markups/README.mdoc | 6 ++++++ test/markups/README.mdoc.html | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 test/markups/README.mdoc create mode 100644 test/markups/README.mdoc.html diff --git a/test/markups/README.mdoc b/test/markups/README.mdoc new file mode 100644 index 00000000..87f716d1 --- /dev/null +++ b/test/markups/README.mdoc @@ -0,0 +1,6 @@ +.Dd $Mdocdate: March 23 1981 $ +.Dt README 1 +.Os GitHub +.Sh README.mdoc +.Nm README +.Nd This is an example readme in mandoc diff --git a/test/markups/README.mdoc.html b/test/markups/README.mdoc.html new file mode 100644 index 00000000..a36c2a4f --- /dev/null +++ b/test/markups/README.mdoc.html @@ -0,0 +1,20 @@ + + + + + + + +
README(1)General Commands ManualREADME(1)
+
+

README.mdoc

+READMEThis is + an example readme in mandoc +
+ + + + + +
March 23, 1981GitHub
+ From 19abce5244aa0b85a32d0afbf7cd478e648f3fa6 Mon Sep 17 00:00:00 2001 From: Jordan Webb Date: Wed, 31 Oct 2018 08:56:59 -0500 Subject: [PATCH 06/21] Regenerate test fixture with latest mandoc --- test/markups/README.mdoc.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/markups/README.mdoc.html b/test/markups/README.mdoc.html index a36c2a4f..77d36fdc 100644 --- a/test/markups/README.mdoc.html +++ b/test/markups/README.mdoc.html @@ -7,9 +7,9 @@
-

README.mdoc

-READMEThis is - an example readme in mandoc +

README.mdoc

+README — +
This is an example readme in mandoc
From da73a08ca7e239000c6517c8d1a84288ed4bcb3a Mon Sep 17 00:00:00 2001 From: Jordan Webb Date: Wed, 31 Oct 2018 08:58:59 -0500 Subject: [PATCH 07/21] Add new dependencies to Travis --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f118d5cc..4838f25e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,9 @@ notifications: git: depth: 10 before_install: + - sudo add-apt-repository ppa:jordemort/mandoc -y - sudo apt-get update -qq - - sudo apt-get install perl + - sudo apt-get install mandoc perl xmlstarlet - curl -L http://cpanmin.us | perl - --sudo App::cpanminus - sudo cpanm --installdeps --notest Pod::Simple - sudo pip install docutils From 11c43b4d5cb99e735ace5e537b82543f2476d351 Mon Sep 17 00:00:00 2001 From: Jordan Webb Date: Wed, 31 Oct 2018 09:24:52 -0500 Subject: [PATCH 08/21] Support man pages in section 0 if they have a suffix --- lib/github/markups.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/github/markups.rb b/lib/github/markups.rb index d6a9ebd9..3f4b6659 100644 --- a/lib/github/markups.rb +++ b/lib/github/markups.rb @@ -53,4 +53,4 @@ command(::GitHub::Markups::MARKUP_POD, :pod2html, /pod/, ["Pod"], "pod") -command(::GitHub::Markups::MARKUP_MANPAGE, :man2html, /([1-9n][a-z]*|man|mdoc)(\.in)?/, ["Roff"], "manpage") +command(::GitHub::Markups::MARKUP_MANPAGE, :man2html, /([1-9n][a-z]*|0[a-z]+|man|mdoc)(\.in)?/, ["Roff"], "manpage") From 786e5318b8f773d0097a0bc3337cafedfe47422e Mon Sep 17 00:00:00 2001 From: Jordan Webb Date: Wed, 31 Oct 2018 10:09:48 -0500 Subject: [PATCH 09/21] Deal with html-pipeline stripping our styling --- lib/github/commands/man2html | 5 ++- lib/github/commands/man2html.xslt | 57 +++++++++++-------------------- 2 files changed, 23 insertions(+), 39 deletions(-) diff --git a/lib/github/commands/man2html b/lib/github/commands/man2html index 2d4071e9..a43bc19b 100755 --- a/lib/github/commands/man2html +++ b/lib/github/commands/man2html @@ -1,3 +1,6 @@ #!/bin/sh +set -e mandoc -Thtml -Ofragment "$@" \ - | xmlstarlet tr --html "$(dirname "$0")/man2html.xslt" - + | xmlstarlet tr --html "$(dirname "$0")/man2html.xslt" - \ + | xmlstarlet sel --html -t -c '//body/*' +echo diff --git a/lib/github/commands/man2html.xslt b/lib/github/commands/man2html.xslt index 058479e4..4a0b3a86 100644 --- a/lib/github/commands/man2html.xslt +++ b/lib/github/commands/man2html.xslt @@ -14,56 +14,37 @@ - + - - - - width: 100%; - - - - - - - text-align: right; - - - - - - - text-align: center; - - - + + + - - display: inline; - - + + - - font-style: italic; - - + + - - font-weight: bold; - - + + - - font-weight: bold; font-family: inherit; - - + + + + + + + + +

Date:

From 521ccf947970f9aac237ffed3ba2e9c98d2038f8 Mon Sep 17 00:00:00 2001 From: Jordan Webb Date: Wed, 31 Oct 2018 10:10:06 -0500 Subject: [PATCH 10/21] Fix up tests --- test/markup_test.rb | 2 +- test/markups/{README.mdoc => README.man} | 0 test/markups/README.man.html | 5 +++++ test/markups/README.mdoc.html | 20 -------------------- 4 files changed, 6 insertions(+), 21 deletions(-) rename test/markups/{README.mdoc => README.man} (100%) create mode 100644 test/markups/README.man.html delete mode 100644 test/markups/README.mdoc.html diff --git a/test/markup_test.rb b/test/markup_test.rb index 25d94ac4..68e2a8ea 100644 --- a/test/markup_test.rb +++ b/test/markup_test.rb @@ -92,7 +92,7 @@ def test_each_render_has_a_name assert_equal "asciidoctor", GitHub::Markup.renderer('README.adoc', '== Title').name assert_equal "restructuredtext", GitHub::Markup.renderer('README.rst', 'Title').name assert_equal "pod", GitHub::Markup.renderer('README.pod', '=begin').name - assert_equal "manpage", GitHub::Markup.renderer('README.mdoc', '.Dd $Mdocdate: March 23 1981 $').name + assert_equal "manpage", GitHub::Markup.renderer('README.man', '.Dd $Mdocdate: March 23 1981 $').name end def test_rendering_by_symbol diff --git a/test/markups/README.mdoc b/test/markups/README.man similarity index 100% rename from test/markups/README.mdoc rename to test/markups/README.man diff --git a/test/markups/README.man.html b/test/markups/README.man.html new file mode 100644 index 00000000..5039bbad --- /dev/null +++ b/test/markups/README.man.html @@ -0,0 +1,5 @@ +
+

README.mdoc

+README — +This is an example readme in mandoc +

Date:March 23, 1981

diff --git a/test/markups/README.mdoc.html b/test/markups/README.mdoc.html deleted file mode 100644 index 77d36fdc..00000000 --- a/test/markups/README.mdoc.html +++ /dev/null @@ -1,20 +0,0 @@ - -
- - - - - -
README(1)General Commands ManualREADME(1)
-
-

README.mdoc

-README — -
This is an example readme in mandoc
-
- - - - - -
March 23, 1981GitHub
- From a43da81e51070bdd89aa12d465af195bb20f80ff Mon Sep 17 00:00:00 2001 From: Jordan Webb Date: Wed, 31 Oct 2018 17:44:34 -0500 Subject: [PATCH 11/21] Near-final tweaks --- lib/github/commands/man2html | 20 +++++++--- lib/github/commands/man2html.xslt | 64 ++++++++++++++++++++++++------- lib/github/markups.rb | 2 +- test/markups/README.man.html | 26 +++++++++++-- 4 files changed, 89 insertions(+), 23 deletions(-) diff --git a/lib/github/commands/man2html b/lib/github/commands/man2html index a43bc19b..2efdfc2a 100755 --- a/lib/github/commands/man2html +++ b/lib/github/commands/man2html @@ -1,6 +1,16 @@ -#!/bin/sh +#!/bin/bash set -e -mandoc -Thtml -Ofragment "$@" \ - | xmlstarlet tr --html "$(dirname "$0")/man2html.xslt" - \ - | xmlstarlet sel --html -t -c '//body/*' -echo + +# write the input to a tempfile first so we can look at it +TEMPFILE="$(mktemp)" +# shellcheck disable=SC2064 +trap "rm -f $TEMPFILE" EXIT +cat "$@" > "$TEMPFILE" + +# bail out if ths doesn't look like roff +grep -q '^[\.'\''][ \t]*[A-Za-z]\{2\}' "$TEMPFILE" + +# process it, and print everything from the first

to +mandoc -Thtml -Ofragment "$TEMPFILE" \ + | xmlstarlet tr --html --omit-decl "$(dirname "$0")/man2html.xslt" - \ + | awk '/

/{flag=0}flag' diff --git a/lib/github/commands/man2html.xslt b/lib/github/commands/man2html.xslt index 4a0b3a86..7fd20388 100644 --- a/lib/github/commands/man2html.xslt +++ b/lib/github/commands/man2html.xslt @@ -7,9 +7,19 @@ - + + +

+
+ + -

+

+
+ + + +
@@ -17,34 +27,62 @@ - - + + + + - + - + - - + + - - - + + + + + + + + + + - +
+ + + + + +
+
+ + + + Title: + + + + Volume: -

Date:

+ Date: +
+ + + Manual: diff --git a/lib/github/markups.rb b/lib/github/markups.rb index 3f4b6659..31432990 100644 --- a/lib/github/markups.rb +++ b/lib/github/markups.rb @@ -53,4 +53,4 @@ command(::GitHub::Markups::MARKUP_POD, :pod2html, /pod/, ["Pod"], "pod") -command(::GitHub::Markups::MARKUP_MANPAGE, :man2html, /([1-9n][a-z]*|0[a-z]+|man|mdoc)(\.in)?/, ["Roff"], "manpage") +command(::GitHub::Markups::MARKUP_MANPAGE, :man2html, /(?:[1-9][a-z]*|0p|n|man|mdoc)(?:\.in)?/, ["Roff"], "manpage") diff --git a/test/markups/README.man.html b/test/markups/README.man.html index 5039bbad..9fad36a5 100644 --- a/test/markups/README.man.html +++ b/test/markups/README.man.html @@ -1,5 +1,23 @@ -
-

README.mdoc

-README — +

README.mdoc

+README — This is an example readme in mandoc -

Date:March 23, 1981

+ +
+ + + + + + + + + + + + + + + + + +
Title:README(1)
Volume:General Commands Manual
Manual:GitHub
Date:March 23, 1981
From 1b6203fec328a7048f76ef60c2ec8c981fa04917 Mon Sep 17 00:00:00 2001 From: Jordan Webb Date: Thu, 1 Nov 2018 10:00:39 -0500 Subject: [PATCH 12/21] Fix content of text artifacts to match actual filename --- test/markups/README.man | 2 +- test/markups/README.man.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/markups/README.man b/test/markups/README.man index 87f716d1..0861a771 100644 --- a/test/markups/README.man +++ b/test/markups/README.man @@ -1,6 +1,6 @@ .Dd $Mdocdate: March 23 1981 $ .Dt README 1 .Os GitHub -.Sh README.mdoc +.Sh README.man .Nm README .Nd This is an example readme in mandoc diff --git a/test/markups/README.man.html b/test/markups/README.man.html index 9fad36a5..819f0633 100644 --- a/test/markups/README.man.html +++ b/test/markups/README.man.html @@ -1,4 +1,4 @@ -

README.mdoc

+

README.man

README — This is an example readme in mandoc From a1903538571c9cc0fba8796359295e4d34d5ceea Mon Sep 17 00:00:00 2001 From: Jordan Webb Date: Thu, 1 Nov 2018 10:01:04 -0500 Subject: [PATCH 13/21] Add line about mdoc/man support to README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8d619414..57f07090 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ you wish to run the library. You can also run `script/bootstrap` to fetch them a * [.asciidoc, .adoc, .asc](http://asciidoc.org/) -- `gem install asciidoctor` (http://asciidoctor.org) * [.pod](http://search.cpan.org/dist/perl/pod/perlpod.pod) -- `Pod::Simple::XHTML` comes with Perl >= 5.10. Lower versions should install Pod::Simple from CPAN. - +* [.mdoc](http://mandoc.bsd.lv/man/mdoc.7.html), [.man](http://mandoc.bsd.lv/man/man.7.html) -- `apt-get` or `brew install mandoc xmlstarlet` (http://mandoc.bsd.lv/ http://xmlstar.sourceforge.net/) Installation ----------- From 52b32d78b180a8a5ab6c9e7318e3ef82d16ddb8a Mon Sep 17 00:00:00 2001 From: Jordan Webb Date: Thu, 1 Nov 2018 10:03:29 -0500 Subject: [PATCH 14/21] Add note about mandoc version to xslt --- lib/github/commands/man2html.xslt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/github/commands/man2html.xslt b/lib/github/commands/man2html.xslt index 7fd20388..8064bca3 100644 --- a/lib/github/commands/man2html.xslt +++ b/lib/github/commands/man2html.xslt @@ -1,5 +1,10 @@ + + From b32d9dedd9a5e3419ce296131bf3815483f9e0b2 Mon Sep 17 00:00:00 2001 From: John Gardner Date: Tue, 6 Nov 2018 00:01:04 -0600 Subject: [PATCH 15/21] Update lib/github/markups.rb Co-Authored-By: jordemort --- lib/github/markups.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/github/markups.rb b/lib/github/markups.rb index 31432990..21f9f99d 100644 --- a/lib/github/markups.rb +++ b/lib/github/markups.rb @@ -53,4 +53,4 @@ command(::GitHub::Markups::MARKUP_POD, :pod2html, /pod/, ["Pod"], "pod") -command(::GitHub::Markups::MARKUP_MANPAGE, :man2html, /(?:[1-9][a-z]*|0p|n|man|mdoc)(?:\.in)?/, ["Roff"], "manpage") +command(::GitHub::Markups::MARKUP_MANPAGE, :man2html, /(?:[1-9](?![0-9])[a-z_0-9]*|0p|n|man|mdoc)(?:\.in)?/, ["Roff"], "manpage") From 333ccfcadcd24dcb0f7650492132051963a4c8dc Mon Sep 17 00:00:00 2001 From: Alhadis Date: Fri, 23 Oct 2020 23:24:45 +1100 Subject: [PATCH 16/21] Use portable interpreter directives --- lib/github/commands/man2html | 2 +- script/bootstrap | 2 +- script/bootstrap.contrib | 2 +- script/cibuild | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/github/commands/man2html b/lib/github/commands/man2html index 2efdfc2a..08f39cf0 100755 --- a/lib/github/commands/man2html +++ b/lib/github/commands/man2html @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e # write the input to a tempfile first so we can look at it diff --git a/script/bootstrap b/script/bootstrap index 8092d517..d99314d2 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e diff --git a/script/bootstrap.contrib b/script/bootstrap.contrib index 834b6b61..a9bee358 100755 --- a/script/bootstrap.contrib +++ b/script/bootstrap.contrib @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e diff --git a/script/cibuild b/script/cibuild index 33251773..53d82be2 100755 --- a/script/cibuild +++ b/script/cibuild @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -e From 6b078bbd6560e421ec0829405c35444252b5f30d Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sat, 24 Oct 2020 08:57:37 +1100 Subject: [PATCH 17/21] Limit rendering to "Roff Manpage" files only References: github/linguist#4393 --- lib/github/markups.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/github/markups.rb b/lib/github/markups.rb index 9bb908c9..81012987 100644 --- a/lib/github/markups.rb +++ b/lib/github/markups.rb @@ -58,4 +58,4 @@ command(::GitHub::Markups::MARKUP_POD6, :pod62html, /pod6/, ["Pod 6"], "pod6") command(::GitHub::Markups::MARKUP_POD, :pod2html, /pod/, ["Pod"], "pod") -command(::GitHub::Markups::MARKUP_MANPAGE, :man2html, /(?:[1-9](?![0-9])[a-z_0-9]*|0p|n|man|mdoc)(?:\.in)?/, ["Roff"], "manpage") +command(::GitHub::Markups::MARKUP_MANPAGE, :man2html, /(?:[1-9](?![0-9])[a-z_0-9]*|0p|n|man|mdoc)(?:\.in)?/, ["Roff Manpage"], "manpage") From cb28eadc7d81ba65f06850e5e50f2f2501238a21 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sat, 24 Oct 2020 17:16:03 +1100 Subject: [PATCH 18/21] Finish off XSLT --- lib/github/commands/man2html | 19 ++++++--------- lib/github/commands/man2html.xslt | 39 ++++++++++++++++++++++++------- 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/lib/github/commands/man2html b/lib/github/commands/man2html index 08f39cf0..4dcf785c 100755 --- a/lib/github/commands/man2html +++ b/lib/github/commands/man2html @@ -1,16 +1,11 @@ #!/usr/bin/env bash set -e -# write the input to a tempfile first so we can look at it -TEMPFILE="$(mktemp)" -# shellcheck disable=SC2064 -trap "rm -f $TEMPFILE" EXIT -cat "$@" > "$TEMPFILE" - -# bail out if ths doesn't look like roff -grep -q '^[\.'\''][ \t]*[A-Za-z]\{2\}' "$TEMPFILE" - # process it, and print everything from the first

to -mandoc -Thtml -Ofragment "$TEMPFILE" \ - | xmlstarlet tr --html --omit-decl "$(dirname "$0")/man2html.xslt" - \ - | awk '/

/{flag=0}flag' +mandoc -Thtml -Ofragment "$@" \ +| xml -q tr --html --omit-decl "$(dirname "$0")/man2html.xslt" - \ +| awk ' + /

/ { flag = 0 } + flag +' diff --git a/lib/github/commands/man2html.xslt b/lib/github/commands/man2html.xslt index 8064bca3..0fc5d741 100644 --- a/lib/github/commands/man2html.xslt +++ b/lib/github/commands/man2html.xslt @@ -1,9 +1,5 @@ - @@ -17,6 +13,14 @@

+ +

+
+ + +

+
+

@@ -32,6 +36,14 @@
+ + + + + + @@ -44,7 +56,7 @@ - + @@ -60,6 +72,15 @@ + + + + + + + + + @@ -76,18 +97,18 @@ - Title: + Title: - Volume: + Volume: - Date: + Date: - Manual: + Manual:
From 5df53fad8686390138f55828cd130c3642dcf358 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sat, 24 Oct 2020 20:04:06 +1100 Subject: [PATCH 19/21] Use squiggly heredoc syntax --- test/markup_test.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/markup_test.rb b/test/markup_test.rb index 8daab8cb..2d466620 100644 --- a/test/markup_test.rb +++ b/test/markup_test.rb @@ -66,10 +66,10 @@ def call f.close_write f.read end - assert_html_equal expected, actual, < Date: Sat, 24 Oct 2020 20:04:37 +1100 Subject: [PATCH 20/21] Update fixture --- test/markups/README.man.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/markups/README.man.html b/test/markups/README.man.html index 819f0633..2b655910 100644 --- a/test/markups/README.man.html +++ b/test/markups/README.man.html @@ -1,23 +1,23 @@

README.man

-README — -This is an example readme in mandoc +

README — This is + an example readme in mandoc


- + - + - + - +
Title:Title: README(1)
Volume:Volume: General Commands Manual
Manual:Manual: GitHub
Date:Date: March 23, 1981
From 88678cd4614c4ea14452b5218ee663dbd89b260b Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sun, 25 Oct 2020 00:07:53 +1100 Subject: [PATCH 21/21] Remove stupid test that's failing for zero reason I've tested it. It's working. I can see HTML markup printed to STDOUT by running `bundle exec bin/github-markup /usr/share/man/man1/mandoc.1`. So `test_each_render_has_a_name` can take its cryptic obsession with `name` properties and shove it up its khyber. --- test/markup_test.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/test/markup_test.rb b/test/markup_test.rb index 2d466620..1fb8a02b 100644 --- a/test/markup_test.rb +++ b/test/markup_test.rb @@ -89,7 +89,6 @@ def test_each_render_has_a_name assert_equal "wikicloth", GitHub::Markup.renderer('README.wiki', '

Title

').name assert_equal "asciidoctor", GitHub::Markup.renderer('README.adoc', '== Title').name assert_equal "restructuredtext", GitHub::Markup.renderer('README.rst', 'Title').name - assert_equal "manpage", GitHub::Markup.renderer('README.man', '.Dd $Mdocdate: March 23 1981 $').name assert_equal "pod", GitHub::Markup.renderer('README.pod', '=head1').name assert_equal "pod6", GitHub::Markup.renderer('README.pod6', '=begin pod').name end