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
Add support for manpages via mandoc #1196
Changes from 5 commits
2008073
d6643c3
3deeea0
f149841
f00e30c
19abce5
da73a08
11c43b4
786e531
521ccf9
a43da81
1b6203f
a190353
52b32d7
b32d9de
fb06417
333ccfc
6b078bb
cb28ead
5df53fa
2bde37d
88678cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module GitHub | ||
module Markup | ||
VERSION = '3.0.1' | ||
VERSION = '3.0.2' | ||
Version = VERSION | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
mandoc -Thtml -Ofragment "$@" \ | ||
| xmlstarlet tr --html "$(dirname "$0")/man2html.xslt" - |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
<!-- Default: match anything and apply templates to it --> | ||
<xsl:template match="node()|@*"> | ||
<xsl:copy> | ||
<xsl:apply-templates select="node()|@*"/> | ||
</xsl:copy> | ||
</xsl:template> | ||
|
||
<!-- Turn these into breaks --> | ||
<xsl:template match="div[@class='Pp']"> | ||
<br/><br/> | ||
</xsl:template> | ||
|
||
<!-- Headers don't need to be linking to themselves --> | ||
<xsl:template match="a[@class='permalink']"> | ||
<xsl:copy-of select="text()"></xsl:copy-of> | ||
</xsl:template> | ||
|
||
<!-- The rest is ported styles from mandoc default CSS --> | ||
<xsl:template match="table[@class='head']|table[@class='foot']"> | ||
<xsl:copy> | ||
<xsl:attribute name="style">width: 100%;</xsl:attribute> | ||
<xsl:apply-templates /> | ||
</xsl:copy> | ||
</xsl:template> | ||
|
||
<xsl:template match="td[@class='head-rtitle']|td[@class='foot-os']"> | ||
<xsl:copy> | ||
<xsl:attribute name="style">text-align: right;</xsl:attribute> | ||
<xsl:apply-templates /> | ||
</xsl:copy> | ||
</xsl:template> | ||
|
||
<xsl:template match="td[@class='head-vol']"> | ||
<xsl:copy> | ||
<xsl:attribute name="style">text-align: center;</xsl:attribute> | ||
<xsl:apply-templates /> | ||
</xsl:copy> | ||
</xsl:template> | ||
|
||
<xsl:template match="div[@class='Nd']|div[@class='Bf']|div[@class='Op']"> | ||
<xsl:copy> | ||
<xsl:attribute name="style">display: inline;</xsl:attribute> | ||
<xsl:apply-templates /> | ||
</xsl:copy> | ||
</xsl:template> | ||
|
||
<xsl:template match="span[@class='Pa']|span[@class='Ad']"> | ||
<xsl:copy> | ||
<xsl:attribute name="style">font-style: italic;</xsl:attribute> | ||
<xsl:apply-templates /> | ||
</xsl:copy> | ||
</xsl:template> | ||
|
||
<xsl:template match="span[@class='Ms']|dl[@class='BL-diag']/dt"> | ||
<xsl:copy> | ||
<xsl:attribute name="style">font-weight: bold;</xsl:attribute> | ||
<xsl:apply-templates /> | ||
</xsl:copy> | ||
</xsl:template> | ||
|
||
<xsl:template match="code[@class='Nm']|code[@class='Fl']|code[@class='Cm']|code[@class='Ic']|code[@class='In']|code[@class='Fd']|code[@class='Fn']|code[@class='Cd']"> | ||
<xsl:copy> | ||
<xsl:attribute name="style">font-weight: bold; font-family: inherit;</xsl:attribute> | ||
<xsl:apply-templates /> | ||
</xsl:copy> | ||
</xsl:template> | ||
</xsl:stylesheet> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,3 +52,5 @@ | |
) | ||
|
||
command(::GitHub::Markups::MARKUP_POD, :pod2html, /pod/, ["Pod"], "pod") | ||
|
||
command(::GitHub::Markups::MARKUP_MANPAGE, :man2html, /([1-9n][a-z]*|man|mdoc)(\.in)?/, ["Roff"], "manpage") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If man pages in section 0, e.g. the POSIX string.h(0p), aren't going to be supported then can that please be stated so I can stop pointing out the regexp doesn't permit them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe I misunderstood; I thought that pages in section 0 were plain-text and thus did not require formatting? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Alhadis Is that just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see @ischwarze comment #1196 (comment)
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep. Sometimes called "catman pages", after the The program was really only relevant in the old days when processors were limited in their power, and formatting a man-page was a potentially costly procedure. Nowadays, processors are so powerful we hardly notice the time spent formatting the Roff markup, and having There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps @ischwarze can clarify where they occur when he has the time. I've not noticed a `.0' suffix being used for catman pages. catman(8) here says, regarding the sections to search, ‘The default is "1 n l 8 3 0 2 5 4 9 6 7"’, note the 0, and so man-db, where it's from, doesn't require a letter suffix and treats 0 as just another section for source needing formatting. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Erf, didn't mean to comment twice; I'll leave it as until @ischwarze can weigh in but based on catman(8) I'm leaning towards just treating .0 as a regular section instead of special casing it like it is now |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<html><body> | ||
<table style="width: 100%;"> | ||
<tr> | ||
<td class="head-ltitle">README(1)</td> | ||
<td style="text-align: center;">General Commands Manual</td> | ||
<td style="text-align: right;">README(1)</td> | ||
</tr> | ||
</table> | ||
<div class="manual-text"> | ||
<h1 class="Sh" title="Sh" id="README.mdoc"><a class="selflink" href="#README.mdoc">README.mdoc</a></h1> | ||
jordemort marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<b class="Nm" title="Nm">README</b> — <span class="Nd" title="Nd">This is | ||
an example readme in mandoc</span> | ||
</div> | ||
<table style="width: 100%;"> | ||
<tr> | ||
<td class="foot-date">March 23, 1981</td> | ||
<td style="text-align: right;">GitHub</td> | ||
</tr> | ||
</table> | ||
</body></html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is appropriate to do here or if we want to roll out a release as a separate PR. Might also be worth more than a patch version; maybe 3.1.0? cc @kivikakk @lildude