github-markup 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.md +6 -1
- data/bin/github-markup +10 -0
- data/lib/github/markup.rb +15 -2
- data/lib/github/markup/version.rb +1 -1
- data/lib/github/markups.rb +23 -0
- data/test/markups/README.1 +138 -0
- data/test/markups/README.1.html +184 -0
- metadata +8 -5
data/HISTORY.md
CHANGED
data/bin/github-markup
ADDED
data/lib/github/markup.rb
CHANGED
@@ -9,7 +9,9 @@ module GitHub
|
|
9
9
|
extend self
|
10
10
|
@@markups = {}
|
11
11
|
|
12
|
-
def render(filename, content)
|
12
|
+
def render(filename, content = nil)
|
13
|
+
content ||= File.read(filename)
|
14
|
+
|
13
15
|
if proc = renderer(filename)
|
14
16
|
proc[content]
|
15
17
|
else
|
@@ -34,7 +36,18 @@ module GitHub
|
|
34
36
|
add_markup(regexp) do |content|
|
35
37
|
rendered = execute(command, content)
|
36
38
|
rendered = rendered.to_s.empty? ? content : rendered
|
37
|
-
|
39
|
+
|
40
|
+
if block && block.arity == 2
|
41
|
+
# If the block takes two arguments, pass new content and old
|
42
|
+
# content.
|
43
|
+
block.call(rendered, content)
|
44
|
+
elsif block
|
45
|
+
# One argument is just the new content.
|
46
|
+
block.call(rendered)
|
47
|
+
else
|
48
|
+
# No block? No problem!
|
49
|
+
rendered
|
50
|
+
end
|
38
51
|
end
|
39
52
|
end
|
40
53
|
|
data/lib/github/markups.rb
CHANGED
@@ -28,3 +28,26 @@ command("/usr/bin/env perl -MPod::Simple::HTML -e Pod::Simple::HTML::go", /pod/)
|
|
28
28
|
$1
|
29
29
|
end
|
30
30
|
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# man pages!
|
34
|
+
#
|
35
|
+
command('groff -t -e -mandoc -Thtml -P -l -P -r -', /\d/) do |rendered, original|
|
36
|
+
# Try to grab the name and section.
|
37
|
+
if original =~ /^.TH (\S+).*?(\d).*$/
|
38
|
+
# Clear out the gunk, "MUSTACHE" => MUSTACHE
|
39
|
+
name, section = $1, $2
|
40
|
+
name.gsub!(/"|'/, '')
|
41
|
+
|
42
|
+
# make MUSTACHE(1)
|
43
|
+
title = "#{name}(#{section})"
|
44
|
+
|
45
|
+
# Classy divs.
|
46
|
+
left = "<div style='float:left'>#{title}</div>"
|
47
|
+
right = "<div style='float:right'>#{title}</div>"
|
48
|
+
end
|
49
|
+
|
50
|
+
if rendered =~ /<body>\s*(.+)\s*<\/body>/mi
|
51
|
+
$1.gsub(/<hr>/, '').gsub(/(<h1.+?h1>)/, "#{left}#{right}\\1")
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
.\" generated with Ron/v0.3
|
2
|
+
.\" http://github.com/rtomayko/ron/
|
3
|
+
.
|
4
|
+
.TH "MUSTACHE" "1" "March 2010" "DEFUNKT" "Mustache Manual"
|
5
|
+
.
|
6
|
+
.SH "NAME"
|
7
|
+
\fBmustache\fR \-\- Mustache processor
|
8
|
+
.
|
9
|
+
.SH "SYNOPSIS"
|
10
|
+
\fBcat data.yml template.mustache | mustache\fR
|
11
|
+
.
|
12
|
+
.SH "DESCRIPTION"
|
13
|
+
Mustache is a logic\-less templating system for HTML, config files,
|
14
|
+
anything.
|
15
|
+
.
|
16
|
+
.P
|
17
|
+
The \fBmustache\fR command processes a Mustache template preceded by YAML
|
18
|
+
frontmatter from standard input and prints one or more documents to
|
19
|
+
standard output.
|
20
|
+
.
|
21
|
+
.P
|
22
|
+
YAML frontmatter beings with \fB---\fR on a single line, followed by YAML,
|
23
|
+
ending with another \fB---\fR on a single line, e.g.
|
24
|
+
.
|
25
|
+
.IP "" 4
|
26
|
+
.
|
27
|
+
.nf
|
28
|
+
|
29
|
+
\fB---
|
30
|
+
names: [ {name: chris}, {name: mark}, {name: scott} ]
|
31
|
+
--- \fR
|
32
|
+
.
|
33
|
+
.fi
|
34
|
+
.
|
35
|
+
.IP "" 0
|
36
|
+
.
|
37
|
+
.P
|
38
|
+
If you are unfamiliar with YAML, it is a superset of JSON. Valid JSON
|
39
|
+
should work fine.
|
40
|
+
.
|
41
|
+
.P
|
42
|
+
After the frontmatter should come any valid Mustache template. See
|
43
|
+
mustache(5) for an overview of Mustache templates.
|
44
|
+
.
|
45
|
+
.P
|
46
|
+
For example:
|
47
|
+
.
|
48
|
+
.IP "" 4
|
49
|
+
.
|
50
|
+
.nf
|
51
|
+
|
52
|
+
\fB{{#names}}
|
53
|
+
Hi {{name}}!
|
54
|
+
{{/names}} \fR
|
55
|
+
.
|
56
|
+
.fi
|
57
|
+
.
|
58
|
+
.IP "" 0
|
59
|
+
.
|
60
|
+
.P
|
61
|
+
Now let's combine them.
|
62
|
+
.
|
63
|
+
.IP "" 4
|
64
|
+
.
|
65
|
+
.nf
|
66
|
+
|
67
|
+
\fB$ cat data.yml
|
68
|
+
---
|
69
|
+
names: [ {name: chris}, {name: mark}, {name: scott} ]
|
70
|
+
---
|
71
|
+
$ cat template.mustache
|
72
|
+
{{#names}}
|
73
|
+
Hi {{name}}!
|
74
|
+
{{/names}}
|
75
|
+
|
76
|
+
$ cat data.yml template.mustache | mustache
|
77
|
+
Hi chris!
|
78
|
+
Hi mark!
|
79
|
+
Hi scott!
|
80
|
+
\fR
|
81
|
+
.
|
82
|
+
.fi
|
83
|
+
.
|
84
|
+
.IP "" 0
|
85
|
+
.
|
86
|
+
.P
|
87
|
+
If you provide multiple YAML documents (as delimited by \fB---\fR), your
|
88
|
+
template will be rendered multiple times. Like a mail merge.
|
89
|
+
.
|
90
|
+
.P
|
91
|
+
For example:
|
92
|
+
.
|
93
|
+
.IP "" 4
|
94
|
+
.
|
95
|
+
.nf
|
96
|
+
|
97
|
+
\fB$ cat data.yml
|
98
|
+
---
|
99
|
+
name: chris
|
100
|
+
---
|
101
|
+
name: mark
|
102
|
+
---
|
103
|
+
name: scott
|
104
|
+
---
|
105
|
+
$ cat template.mustache
|
106
|
+
Hi {{name}}!
|
107
|
+
|
108
|
+
$ cat data.yml template.mustache | mustache
|
109
|
+
Hi chris!
|
110
|
+
Hi mark!
|
111
|
+
Hi scott!
|
112
|
+
\fR
|
113
|
+
.
|
114
|
+
.fi
|
115
|
+
.
|
116
|
+
.IP "" 0
|
117
|
+
.
|
118
|
+
.SH "INSTALLATION"
|
119
|
+
If you have RubyGems installed:
|
120
|
+
.
|
121
|
+
.IP "" 4
|
122
|
+
.
|
123
|
+
.nf
|
124
|
+
|
125
|
+
\fBgem install mustache \fR
|
126
|
+
.
|
127
|
+
.fi
|
128
|
+
.
|
129
|
+
.IP "" 0
|
130
|
+
.
|
131
|
+
.SH "COPYRIGHT"
|
132
|
+
Mustache is Copyright (C) 2009 Chris Wanstrath
|
133
|
+
.
|
134
|
+
.P
|
135
|
+
Original CTemplate by Google
|
136
|
+
.
|
137
|
+
.SH "SEE ALSO"
|
138
|
+
mustache(5), mustache(7), gem(1),\fIhttp://defunkt.github.com/mustache/\fR
|
@@ -0,0 +1,184 @@
|
|
1
|
+
<div style='float:left'>MUSTACHE(1)</div><div style='float:right'>MUSTACHE(1)</div><h1 align=center>MUSTACHE</h1>
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
<a name="NAME"></a>
|
6
|
+
<h2>NAME</h2>
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
<p style="margin-left:11%; margin-top: 1em"><b>mustache</b>
|
11
|
+
−− Mustache processor</p>
|
12
|
+
|
13
|
+
<a name="SYNOPSIS"></a>
|
14
|
+
<h2>SYNOPSIS</h2>
|
15
|
+
|
16
|
+
|
17
|
+
<p style="margin-left:11%; margin-top: 1em"><b>cat data.yml
|
18
|
+
template.mustache | mustache</b></p>
|
19
|
+
|
20
|
+
<a name="DESCRIPTION"></a>
|
21
|
+
<h2>DESCRIPTION</h2>
|
22
|
+
|
23
|
+
|
24
|
+
<p style="margin-left:11%; margin-top: 1em">Mustache is a
|
25
|
+
logic−less templating system for HTML, config files,
|
26
|
+
anything.</p>
|
27
|
+
|
28
|
+
<p style="margin-left:11%; margin-top: 1em">The
|
29
|
+
<b>mustache</b> command processes a Mustache template
|
30
|
+
preceded by YAML frontmatter from standard input and prints
|
31
|
+
one or more documents to standard output.</p>
|
32
|
+
|
33
|
+
<p style="margin-left:11%; margin-top: 1em">YAML
|
34
|
+
frontmatter beings with <b>---</b> on a single line,
|
35
|
+
followed by YAML, ending with another <b>---</b> on a single
|
36
|
+
line, e.g.</p>
|
37
|
+
|
38
|
+
<table width="100%" border=0 rules="none" frame="void"
|
39
|
+
cellspacing="0" cellpadding="0">
|
40
|
+
<tr valign="top" align="left">
|
41
|
+
<td width="17%"></td>
|
42
|
+
<td width="5%">
|
43
|
+
|
44
|
+
|
45
|
+
<p style="margin-top: 1em" valign="top"><b>---</b></p></td>
|
46
|
+
<td width="78%">
|
47
|
+
</td>
|
48
|
+
</table>
|
49
|
+
|
50
|
+
<p style="margin-left:17%;"><b>names: [ {name: chris},
|
51
|
+
{name: mark}, {name: scott} ] <br>
|
52
|
+
---</b></p>
|
53
|
+
|
54
|
+
<p style="margin-left:11%; margin-top: 1em">If you are
|
55
|
+
unfamiliar with YAML, it is a superset of JSON. Valid JSON
|
56
|
+
should work fine.</p>
|
57
|
+
|
58
|
+
<p style="margin-left:11%; margin-top: 1em">After the
|
59
|
+
frontmatter should come any valid Mustache template. See
|
60
|
+
mustache(5) for an overview of Mustache templates.</p>
|
61
|
+
|
62
|
+
<p style="margin-left:11%; margin-top: 1em">For
|
63
|
+
example:</p>
|
64
|
+
|
65
|
+
<table width="100%" border=0 rules="none" frame="void"
|
66
|
+
cellspacing="0" cellpadding="0">
|
67
|
+
<tr valign="top" align="left">
|
68
|
+
<td width="17%"></td>
|
69
|
+
<td width="15%">
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
<p style="margin-top: 1em" valign="top"><b>{{#names}}</b></p> </td>
|
74
|
+
<td width="68%">
|
75
|
+
</td>
|
76
|
+
</table>
|
77
|
+
|
78
|
+
<p style="margin-left:17%;"><b>Hi {{name}}! <br>
|
79
|
+
{{/names}}</b></p>
|
80
|
+
|
81
|
+
<p style="margin-left:11%; margin-top: 1em">Now let’s
|
82
|
+
combine them.</p>
|
83
|
+
|
84
|
+
<table width="100%" border=0 rules="none" frame="void"
|
85
|
+
cellspacing="0" cellpadding="0">
|
86
|
+
<tr valign="top" align="left">
|
87
|
+
<td width="17%"></td>
|
88
|
+
<td width="21%">
|
89
|
+
|
90
|
+
|
91
|
+
<p style="margin-top: 1em" valign="top"><b>$ cat
|
92
|
+
data.yml</b></p> </td>
|
93
|
+
<td width="62%">
|
94
|
+
</td>
|
95
|
+
</table>
|
96
|
+
|
97
|
+
<p style="margin-left:17%;"><b>--- <br>
|
98
|
+
names: [ {name: chris}, {name: mark}, {name: scott} ] <br>
|
99
|
+
--- <br>
|
100
|
+
$ cat template.mustache <br>
|
101
|
+
{{#names}} <br>
|
102
|
+
Hi {{name}}! <br>
|
103
|
+
{{/names}}</b></p>
|
104
|
+
|
105
|
+
<p style="margin-left:17%; margin-top: 1em"><b>$ cat
|
106
|
+
data.yml template.mustache | mustache <br>
|
107
|
+
Hi chris! <br>
|
108
|
+
Hi mark! <br>
|
109
|
+
Hi scott!</b></p>
|
110
|
+
|
111
|
+
<p style="margin-left:11%; margin-top: 1em">If you provide
|
112
|
+
multiple YAML documents (as delimited by <b>---</b>), your
|
113
|
+
template will be rendered multiple times. Like a mail
|
114
|
+
merge.</p>
|
115
|
+
|
116
|
+
<p style="margin-left:11%; margin-top: 1em">For
|
117
|
+
example:</p>
|
118
|
+
|
119
|
+
<table width="100%" border=0 rules="none" frame="void"
|
120
|
+
cellspacing="0" cellpadding="0">
|
121
|
+
<tr valign="top" align="left">
|
122
|
+
<td width="17%"></td>
|
123
|
+
<td width="21%">
|
124
|
+
|
125
|
+
|
126
|
+
<p style="margin-top: 1em" valign="top"><b>$ cat
|
127
|
+
data.yml</b></p> </td>
|
128
|
+
<td width="62%">
|
129
|
+
</td>
|
130
|
+
</table>
|
131
|
+
|
132
|
+
<p style="margin-left:17%;"><b>--- <br>
|
133
|
+
name: chris <br>
|
134
|
+
--- <br>
|
135
|
+
name: mark <br>
|
136
|
+
--- <br>
|
137
|
+
name: scott <br>
|
138
|
+
--- <br>
|
139
|
+
$ cat template.mustache <br>
|
140
|
+
Hi {{name}}!</b></p>
|
141
|
+
|
142
|
+
<p style="margin-left:17%; margin-top: 1em"><b>$ cat
|
143
|
+
data.yml template.mustache | mustache <br>
|
144
|
+
Hi chris! <br>
|
145
|
+
Hi mark! <br>
|
146
|
+
Hi scott!</b></p>
|
147
|
+
|
148
|
+
<a name="INSTALLATION"></a>
|
149
|
+
<h2>INSTALLATION</h2>
|
150
|
+
|
151
|
+
|
152
|
+
<p style="margin-left:11%; margin-top: 1em">If you have
|
153
|
+
RubyGems installed:</p>
|
154
|
+
|
155
|
+
<table width="100%" border=0 rules="none" frame="void"
|
156
|
+
cellspacing="0" cellpadding="0">
|
157
|
+
<tr valign="top" align="left">
|
158
|
+
<td width="17%"></td>
|
159
|
+
<td width="31%">
|
160
|
+
|
161
|
+
|
162
|
+
<p style="margin-top: 1em" valign="top"><b>gem install
|
163
|
+
mustache</b></p> </td>
|
164
|
+
<td width="52%">
|
165
|
+
</td>
|
166
|
+
</table>
|
167
|
+
|
168
|
+
<a name="COPYRIGHT"></a>
|
169
|
+
<h2>COPYRIGHT</h2>
|
170
|
+
|
171
|
+
|
172
|
+
<p style="margin-left:11%; margin-top: 1em">Mustache is
|
173
|
+
Copyright (C) 2009 Chris Wanstrath</p>
|
174
|
+
|
175
|
+
<p style="margin-left:11%; margin-top: 1em">Original
|
176
|
+
CTemplate by Google</p>
|
177
|
+
|
178
|
+
<a name="SEE ALSO"></a>
|
179
|
+
<h2>SEE ALSO</h2>
|
180
|
+
|
181
|
+
|
182
|
+
<p style="margin-left:11%; margin-top: 1em">mustache(5),
|
183
|
+
mustache(7),
|
184
|
+
gem(1),<i>http://defunkt.github.com/mustache/</i></p>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github-markup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Wanstrath
|
@@ -9,14 +9,14 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
13
|
-
default_executable:
|
12
|
+
date: 2010-03-17 00:00:00 -07:00
|
13
|
+
default_executable: github-markup
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description: The code we use to render README.your_favorite_markup
|
17
17
|
email: chris@ozmm.org
|
18
|
-
executables:
|
19
|
-
|
18
|
+
executables:
|
19
|
+
- github-markup
|
20
20
|
extensions: []
|
21
21
|
|
22
22
|
extra_rdoc_files:
|
@@ -29,6 +29,7 @@ files:
|
|
29
29
|
- LICENSE
|
30
30
|
- README.md
|
31
31
|
- Rakefile
|
32
|
+
- bin/github-markup
|
32
33
|
- lib/github/commands/asciidoc2html
|
33
34
|
- lib/github/commands/asciidocapi.py
|
34
35
|
- lib/github/commands/rest2html
|
@@ -37,6 +38,8 @@ files:
|
|
37
38
|
- lib/github/markup/version.rb
|
38
39
|
- lib/github/markups.rb
|
39
40
|
- test/markup_test.rb
|
41
|
+
- test/markups/README.1
|
42
|
+
- test/markups/README.1.html
|
40
43
|
- test/markups/README.asciidoc
|
41
44
|
- test/markups/README.asciidoc.html
|
42
45
|
- test/markups/README.markdown
|