redcarpet 1.5.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +312 -20
- data/Rakefile +31 -36
- data/bin/redcarpet +1 -1
- data/ext/redcarpet/autolink.c +260 -0
- data/ext/{xhtml.h → redcarpet/autolink.h} +17 -24
- data/ext/redcarpet/buffer.c +229 -0
- data/ext/redcarpet/buffer.h +88 -0
- data/ext/redcarpet/houdini.h +29 -0
- data/ext/redcarpet/houdini_href_e.c +108 -0
- data/ext/redcarpet/houdini_html_e.c +84 -0
- data/ext/redcarpet/html.c +603 -0
- data/ext/redcarpet/html.h +67 -0
- data/ext/redcarpet/html_blocks.h +206 -0
- data/ext/redcarpet/html_smartypants.c +385 -0
- data/ext/redcarpet/markdown.c +2454 -0
- data/ext/redcarpet/markdown.h +130 -0
- data/ext/redcarpet/rc_markdown.c +137 -0
- data/ext/redcarpet/rc_render.c +434 -0
- data/ext/redcarpet/redcarpet.h +33 -0
- data/ext/redcarpet/stack.c +81 -0
- data/ext/redcarpet/stack.h +21 -0
- data/lib/redcarpet/render_man.rb +65 -0
- data/lib/redcarpet.rb +65 -72
- data/redcarpet.gemspec +29 -20
- data/test/redcarpet_test.rb +232 -88
- metadata +45 -29
- data/ext/array.c +0 -300
- data/ext/array.h +0 -148
- data/ext/buffer.c +0 -319
- data/ext/buffer.h +0 -145
- data/ext/markdown.c +0 -2076
- data/ext/markdown.h +0 -107
- data/ext/redcarpet.c +0 -140
- data/ext/xhtml.c +0 -779
- data/lib/markdown.rb +0 -1
- data/test/benchmark.rb +0 -56
- data/test/benchmark.txt +0 -306
- data/test/markdown_test.rb +0 -186
- /data/ext/{extconf.rb → redcarpet/extconf.rb} +0 -0
data/README.markdown
CHANGED
|
@@ -1,31 +1,322 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
Redcarpet 2 is written with sugar, spice and everything nice
|
|
2
|
+
============================================================
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
Redcarpet is Ruby library for Markdown processing that smells like
|
|
5
|
+
butterflies and popcorn.
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
Redcarpet used to be a drop-in replacement for Redcloth. This is no longer the
|
|
8
|
+
case since version 2 -- it now has its own API, but retains the old name. Yes,
|
|
9
|
+
that does mean that Redcarpet 2 is not backwards-compatible with the 1.X
|
|
10
|
+
versions.
|
|
9
11
|
|
|
10
|
-
Redcarpet is
|
|
11
|
-
Tomayko's RDiscount wrapper, and inspired by Rick Astley wearing a kilt.
|
|
12
|
+
Redcarpet is powered by the Sundown library, which can be found at
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
updated to pass the official Markdown test suite and now has support
|
|
15
|
-
for many additional features: autolinks, smartypants, safe filters,
|
|
16
|
-
and a long etcetera.
|
|
14
|
+
https://www.github.com/tanoku/sundown
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
You might want to find out more about Sundown to see what makes this Ruby
|
|
17
|
+
library so awesome.
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* Redcarpet is (C)2011 Vicent Marti
|
|
23
|
-
|
|
19
|
+
This library is written by people
|
|
20
|
+
-------------------------------------------------------
|
|
24
21
|
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
Redcarpet 2 has been rewritten from scratch by Vicent Martí (@tanoku). Why
|
|
23
|
+
are you not following me on Twitter?
|
|
27
24
|
|
|
28
|
-
|
|
25
|
+
Redcarpet would not be possible without the Sundown library and its authors
|
|
26
|
+
(Natacha Porté, Vicent Martí, and its many awesome contributors).
|
|
27
|
+
|
|
28
|
+
You can totally install it as a Gem
|
|
29
|
+
-----------------------------------
|
|
30
|
+
|
|
31
|
+
Redcarpet is readily available as a Ruby gem. It will build some native
|
|
32
|
+
extensions, but the parser is standalone and requires no installed libraries.
|
|
33
|
+
|
|
34
|
+
$ [sudo] gem install redcarpet
|
|
35
|
+
|
|
36
|
+
The Redcarpet source (including Sundown as a submodule) is available at GitHub:
|
|
37
|
+
|
|
38
|
+
$ git clone git://github.com/tanoku/redcarpet.git
|
|
39
|
+
|
|
40
|
+
And it's like *really* simple to use
|
|
41
|
+
------------------------------------
|
|
42
|
+
|
|
43
|
+
The core of the Redcarpet library is the `Redcarpet::Markdown` class. Each
|
|
44
|
+
instance of the class is attached to a `Renderer` object; the Markdown class
|
|
45
|
+
performs parsing of a document and uses the attached renderer to generate
|
|
46
|
+
output.
|
|
47
|
+
|
|
48
|
+
The `Markdown` object is encouraged to be instantiated once with the required
|
|
49
|
+
settings, and reused between parses.
|
|
50
|
+
|
|
51
|
+
Markdown.new(renderer, extensions={})
|
|
52
|
+
|
|
53
|
+
Initializes a Markdown parser
|
|
54
|
+
|
|
55
|
+
renderer - a renderer object, inheriting from Redcarpet::Render::Base.
|
|
56
|
+
If the given object has not been instantiated, the library
|
|
57
|
+
will do it with default arguments.
|
|
58
|
+
|
|
59
|
+
extensions - a hash containing the Markdown extensions which the parser
|
|
60
|
+
will identify. The following extensions are accepted:
|
|
61
|
+
|
|
62
|
+
:no_intra_emphasis - do not parse emphasis inside of words.
|
|
63
|
+
Strings such as `foo_bar_baz` will not generate `<em>`
|
|
64
|
+
tags.
|
|
65
|
+
|
|
66
|
+
:tables - parse tables, PHP-Markdown style
|
|
67
|
+
|
|
68
|
+
:fenced_code_blocks - parse fenced code blocks, PHP-Markdown
|
|
69
|
+
style .Blocks delimited with 3 or more `~` or backticks
|
|
70
|
+
will be considered as code, without the need to be
|
|
71
|
+
indented. An optional language name may be added at the
|
|
72
|
+
end of the opening fence for the code block
|
|
73
|
+
|
|
74
|
+
:autolink - parse links even when they are not enclosed in
|
|
75
|
+
`<>` characters. Autolinks for the http, https and ftp
|
|
76
|
+
protocols will be automatically detected. Email addresses
|
|
77
|
+
are also handled, and http links without protocol, but
|
|
78
|
+
starting with `www.`
|
|
79
|
+
|
|
80
|
+
:strikethrough - parse strikethrough, PHP-Markdown style
|
|
81
|
+
Two `~` characters mark the start of a strikethrough,
|
|
82
|
+
e.g. `this is ~~good~~ bad`
|
|
83
|
+
|
|
84
|
+
:lax_html_blocks - HTML blocks do not require to be surrounded
|
|
85
|
+
by an empty line as in the Markdown standard.
|
|
86
|
+
|
|
87
|
+
:space_after_headers - A space is always required between the
|
|
88
|
+
hash at the beginning of a header and its name, e.g.
|
|
89
|
+
`#this is my header` would not be a valid header.
|
|
90
|
+
|
|
91
|
+
:superscript - parse superscripts after the `^` character;
|
|
92
|
+
contiguous superscripts are nested together, and complex
|
|
93
|
+
values can be enclosed in parenthesis,
|
|
94
|
+
e.g. `this is the 2^(nd) time`
|
|
95
|
+
|
|
96
|
+
Example:
|
|
97
|
+
|
|
98
|
+
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,
|
|
99
|
+
:autolink => true, :space_after_headers => true)
|
|
100
|
+
|
|
101
|
+
Rendering with the `Markdown` object is done through `Markdown#render`.
|
|
102
|
+
Unlike in the RedCloth API, the text to render is passed as an argument
|
|
103
|
+
and not stored inside the `Markdown` instance, to encourage reusability.
|
|
104
|
+
|
|
105
|
+
Markdown.render(text)
|
|
106
|
+
|
|
107
|
+
Render a Markdown document with the attached renderer
|
|
108
|
+
|
|
109
|
+
text - a Markdown document
|
|
110
|
+
|
|
111
|
+
Example:
|
|
112
|
+
|
|
113
|
+
markdown.render("This is *bongos*, indeed.")
|
|
114
|
+
#=> "<p>This is <em>bongos</em>, indeed</p>"
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
Darling, I packed you a couple renderers for lunch
|
|
118
|
+
--------------------------------------------------
|
|
119
|
+
|
|
120
|
+
Redcarpet comes with two built-in renderers, `Redcarpet::Render::HTML` and
|
|
121
|
+
`Redcarpet::Render::XHTML`, which output HTML and XHTML, respectively. These
|
|
122
|
+
renderers are actually implemented in C, and hence offer a brilliant
|
|
123
|
+
performance, several degrees of magnitude faster than other Ruby Markdown
|
|
124
|
+
solutions.
|
|
125
|
+
|
|
126
|
+
All the rendering flags that previously applied only to HTML output have
|
|
127
|
+
now been moved to the `Render::HTML` class, and may be enabled when
|
|
128
|
+
instantiating the renderer:
|
|
129
|
+
|
|
130
|
+
Render::HTML.new(render_options={})
|
|
131
|
+
|
|
132
|
+
Initializes an HTML renderer. The following flags are available:
|
|
133
|
+
|
|
134
|
+
:filter_html - do not allow any user-inputted HTML in the output
|
|
135
|
+
|
|
136
|
+
:no_images - do not generate any `<img>` tags
|
|
137
|
+
|
|
138
|
+
:no_links - do not generate any `<a>` tags
|
|
139
|
+
|
|
140
|
+
:no_styles - do not generate any `<style>` tags
|
|
141
|
+
|
|
142
|
+
:safe_links_only - only generate links for protocols which are considered safe
|
|
143
|
+
|
|
144
|
+
:with_toc_data - add HTML anchors to each header in the output HTML,
|
|
145
|
+
to allow linking to each section.
|
|
146
|
+
|
|
147
|
+
:hard_wrap - insert HTML `<br>` tags inside on paragraphs where the origin
|
|
148
|
+
Markdown document had newlines (by default, Markdown ignores these
|
|
149
|
+
newlines).
|
|
150
|
+
|
|
151
|
+
:xhtml - output XHTML-conformant tags. This option is always enabled in the
|
|
152
|
+
`Render::XHTML` renderer.
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
Example:
|
|
156
|
+
|
|
157
|
+
rndr = Redcarpet::Render::HTML.new(:no_links => true, :hard_wrap => true)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
The `HTML` renderer has an alternate version, `Redcarpet::Render::HTML_TOC`,
|
|
161
|
+
which will output a table of contents in HTML based on the headers of the
|
|
162
|
+
Markdown document.
|
|
163
|
+
|
|
164
|
+
Furthermore, the abstract base class `Redcarpet::Render::Base` can be used
|
|
165
|
+
to write a custom renderer purely in Ruby, or extending an existing renderer.
|
|
166
|
+
See the following section for more information.
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
And you can even cook your own
|
|
170
|
+
------------------------------
|
|
171
|
+
|
|
172
|
+
Custom renderers are created by inheriting from an existing renderer. The
|
|
173
|
+
built-in renderers, `HTML` and `XHTML` may be extended as such:
|
|
174
|
+
|
|
175
|
+
~~~~~ ruby
|
|
176
|
+
# create a custom renderer that allows highlighting of code blocks
|
|
177
|
+
class HTMLwithAlbino < Redcarpet::Render::HTML
|
|
178
|
+
def block_code(code, language)
|
|
179
|
+
Albino.safe_colorize(code, language)
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
markdown = Redcarpet::Markdown.new(HTMLwithAlbino, :fenced_code_blocks => true)
|
|
184
|
+
~~~~~
|
|
185
|
+
|
|
186
|
+
But new renderers can also be created from scratch (see `lib/render_man.rb` for
|
|
187
|
+
an example implementation of a Manpage renderer)
|
|
188
|
+
|
|
189
|
+
~~~~~~ ruby
|
|
190
|
+
class ManPage < Redcarpet::Render::Base
|
|
191
|
+
# you get the drill -- keep going from here
|
|
192
|
+
end
|
|
193
|
+
~~~~~
|
|
194
|
+
|
|
195
|
+
The following instance methods may be implemented by the renderer:
|
|
196
|
+
|
|
197
|
+
# Block-level calls
|
|
198
|
+
# If the return value of the method is `nil`, the block
|
|
199
|
+
# will be skipped.
|
|
200
|
+
# If the method for a document element is not implemented,
|
|
201
|
+
# the block will be skipped.
|
|
202
|
+
#
|
|
203
|
+
# Example:
|
|
204
|
+
#
|
|
205
|
+
# class RenderWithoutCode < Redcarpet::Render::HTML
|
|
206
|
+
# def block_code(code, language)
|
|
207
|
+
# nil
|
|
208
|
+
# end
|
|
209
|
+
# end
|
|
210
|
+
#
|
|
211
|
+
block_code(code, language)
|
|
212
|
+
block_quote(quote)
|
|
213
|
+
block_html(raw_html)
|
|
214
|
+
header(text, header_level)
|
|
215
|
+
hrule()
|
|
216
|
+
list(contents, list_type)
|
|
217
|
+
list_item(text, list_type)
|
|
218
|
+
paragraph(text)
|
|
219
|
+
table(header, body)
|
|
220
|
+
table_row(content)
|
|
221
|
+
table_cell(content, alignment)
|
|
222
|
+
|
|
223
|
+
# Span-level calls
|
|
224
|
+
# A return value of `nil` will not output any data
|
|
225
|
+
# If the method for a document element is not implemented,
|
|
226
|
+
# the contents of the span will be copied verbatim
|
|
227
|
+
autolink(link, link_type)
|
|
228
|
+
codespan(code)
|
|
229
|
+
double_emphasis(text)
|
|
230
|
+
emphasis(text)
|
|
231
|
+
image(link, title, alt_text)
|
|
232
|
+
linebreak()
|
|
233
|
+
link(link, title, content)
|
|
234
|
+
raw_html(raw_html)
|
|
235
|
+
triple_emphasis(text)
|
|
236
|
+
strikethrough(text)
|
|
237
|
+
superscript(text)
|
|
238
|
+
|
|
239
|
+
# Low level rendering
|
|
240
|
+
entity(text)
|
|
241
|
+
normal_text(text)
|
|
242
|
+
|
|
243
|
+
# Header of the document
|
|
244
|
+
# Rendered before any another elements
|
|
245
|
+
doc_header()
|
|
246
|
+
|
|
247
|
+
# Footer of the document
|
|
248
|
+
# Rendered after all the other elements
|
|
249
|
+
doc_footer()
|
|
250
|
+
|
|
251
|
+
# Pre/post-process
|
|
252
|
+
# Special callback: preprocess or postprocess the whole
|
|
253
|
+
# document before or after the rendering process begins
|
|
254
|
+
preprocess(full_document)
|
|
255
|
+
postprocess(full_document)
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
Also, now our Pants are much smarter
|
|
259
|
+
------------------------------------
|
|
260
|
+
|
|
261
|
+
Redcarpet 2 comes with a standalone [SmartyPants](
|
|
262
|
+
http://daringfireball.net/projects/smartypants/) implementation. It is fully
|
|
263
|
+
compliant with the original implementation. It is the fastest SmartyPants
|
|
264
|
+
parser there is, with a difference of several orders of magnitude.
|
|
265
|
+
|
|
266
|
+
The SmartyPants parser can be found in `Redcarpet::Render::SmartyPants`. It has
|
|
267
|
+
been implemented as a module, so it can be used standalone or as a mixin.
|
|
268
|
+
|
|
269
|
+
When mixed with a Renderer class, it will override the `postprocess` method
|
|
270
|
+
to perform SmartyPants replacements once the rendering is complete
|
|
271
|
+
|
|
272
|
+
~~~~ ruby
|
|
273
|
+
# Mixin
|
|
274
|
+
class HTMLWithPants < Redcarpet::Render::HTML
|
|
275
|
+
include Redcarpet::Render::SmartyPants
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
# Standalone
|
|
279
|
+
Redcarpet::Render::SmartyPants.render("<p>Oh SmartyPants, you're so crazy...</p>")
|
|
280
|
+
~~~~~
|
|
281
|
+
|
|
282
|
+
SmartyPants works on top of already-rendered HTML, and will ignore replacements
|
|
283
|
+
inside the content of HTML tags and inside specific HTML blocks such as
|
|
284
|
+
`<code>` or `<pre>`.
|
|
285
|
+
|
|
286
|
+
What? You really want to mix Markdown renderers?
|
|
287
|
+
------------------------------------------------
|
|
288
|
+
|
|
289
|
+
What a terrible idea! Markdown is already ill-specified enough; if you create
|
|
290
|
+
software that is renderer-independent, the results will be completely unreliable!
|
|
291
|
+
|
|
292
|
+
Each renderer has its own API and its own set of extensions: you should choose one
|
|
293
|
+
(it doesn't have to be Redcarpet, though that would be great!), write your
|
|
294
|
+
software accordingly, and force your users to install it. That's the
|
|
295
|
+
only way to have reliable and predictable Markdown output on your program.
|
|
296
|
+
|
|
297
|
+
Still, if major forces (let's say, tornadoes or other natural disasters) force you
|
|
298
|
+
to keep a Markdown-compatibility later, Redcarpet also supports this:
|
|
299
|
+
|
|
300
|
+
require 'redcarpet/compat'
|
|
301
|
+
|
|
302
|
+
Requiring the compatibility library will declare a `Markdown` class with the
|
|
303
|
+
classical RedCloth API, e.g.
|
|
304
|
+
|
|
305
|
+
Markdown.new('this is my text').to_html
|
|
306
|
+
|
|
307
|
+
This class renders 100% standards compliant Markdown with 0 extensions. Nada.
|
|
308
|
+
Don't even try to enable extensions with a compatibility layer, because
|
|
309
|
+
that's a maintance nightmare and won't work.
|
|
310
|
+
|
|
311
|
+
On a related topic: if your Markdown gem has a `lib/markdown.rb` file that
|
|
312
|
+
monkeypatches the Markdown class, you're a terrible human being. Just saying.
|
|
313
|
+
|
|
314
|
+
Boring legal stuff
|
|
315
|
+
------------------
|
|
316
|
+
|
|
317
|
+
Copyright (c) 2011, Vicent Martí
|
|
318
|
+
|
|
319
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
29
320
|
purpose with or without fee is hereby granted, provided that the above
|
|
30
321
|
copyright notice and this permission notice appear in all copies.
|
|
31
322
|
|
|
@@ -36,3 +327,4 @@ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
36
327
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
37
328
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
38
329
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
330
|
+
|
data/Rakefile
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require 'date'
|
|
2
2
|
require 'rake/clean'
|
|
3
|
+
require 'rake/extensiontask'
|
|
3
4
|
require 'digest/md5'
|
|
4
5
|
|
|
5
6
|
task :default => :test
|
|
@@ -8,31 +9,7 @@ task :default => :test
|
|
|
8
9
|
# Ruby Extension
|
|
9
10
|
# ==========================================================
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
RUBYDIGEST = Digest::MD5.hexdigest(`#{RUBY} --version`)
|
|
13
|
-
|
|
14
|
-
file "ext/ruby-#{RUBYDIGEST}" do |f|
|
|
15
|
-
rm_f FileList["ext/ruby-*"]
|
|
16
|
-
touch f.name
|
|
17
|
-
end
|
|
18
|
-
CLEAN.include "ext/ruby-*"
|
|
19
|
-
|
|
20
|
-
file 'ext/Makefile' => FileList['ext/*.{c,h,rb}', "ext/ruby-#{RUBYDIGEST}"] do
|
|
21
|
-
chdir('ext') { ruby 'extconf.rb' }
|
|
22
|
-
end
|
|
23
|
-
CLEAN.include 'ext/Makefile', 'ext/mkmf.log'
|
|
24
|
-
|
|
25
|
-
file "ext/redcarpet.#{DLEXT}" => FileList["ext/Makefile"] do |f|
|
|
26
|
-
sh 'cd ext && make clean && make && rm -rf conftest.dSYM'
|
|
27
|
-
end
|
|
28
|
-
CLEAN.include 'ext/*.{o,bundle,so,dll}'
|
|
29
|
-
|
|
30
|
-
file "lib/redcarpet.#{DLEXT}" => "ext/redcarpet.#{DLEXT}" do |f|
|
|
31
|
-
cp f.prerequisites, "lib/", :preserve => true
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
desc 'Build the redcarpet extension'
|
|
35
|
-
task :build => "lib/redcarpet.#{DLEXT}"
|
|
12
|
+
Rake::ExtensionTask.new('redcarpet')
|
|
36
13
|
|
|
37
14
|
# ==========================================================
|
|
38
15
|
# Testing
|
|
@@ -43,10 +20,10 @@ Rake::TestTask.new('test:unit') do |t|
|
|
|
43
20
|
t.test_files = FileList['test/*_test.rb']
|
|
44
21
|
t.ruby_opts += ['-rubygems'] if defined? Gem
|
|
45
22
|
end
|
|
46
|
-
task 'test:unit' => [:
|
|
23
|
+
task 'test:unit' => [:compile]
|
|
47
24
|
|
|
48
25
|
desc 'Run conformance tests (MARKDOWN_TEST_VER=1.0)'
|
|
49
|
-
task 'test:conformance' => [:
|
|
26
|
+
task 'test:conformance' => [:compile] do |t|
|
|
50
27
|
script = "#{pwd}/bin/redcarpet"
|
|
51
28
|
test_version = ENV['MARKDOWN_TEST_VER'] || '1.0.3'
|
|
52
29
|
lib_dir = "#{pwd}/lib"
|
|
@@ -56,13 +33,13 @@ task 'test:conformance' => [:build] do |t|
|
|
|
56
33
|
end
|
|
57
34
|
|
|
58
35
|
desc 'Run version 1.0 conformance suite'
|
|
59
|
-
task 'test:conformance:1.0' => [:
|
|
36
|
+
task 'test:conformance:1.0' => [:compile] do |t|
|
|
60
37
|
ENV['MARKDOWN_TEST_VER'] = '1.0'
|
|
61
38
|
Rake::Task['test:conformance'].invoke
|
|
62
39
|
end
|
|
63
40
|
|
|
64
41
|
desc 'Run 1.0.3 conformance suite'
|
|
65
|
-
task 'test:conformance:1.0.3' => [:
|
|
42
|
+
task 'test:conformance:1.0.3' => [:compile] do |t|
|
|
66
43
|
ENV['MARKDOWN_TEST_VER'] = '1.0.3'
|
|
67
44
|
Rake::Task['test:conformance'].invoke
|
|
68
45
|
end
|
|
@@ -93,9 +70,6 @@ task :install => package('.gem') do
|
|
|
93
70
|
sh "gem install #{package('.gem')}"
|
|
94
71
|
end
|
|
95
72
|
|
|
96
|
-
desc 'Update the gemspec'
|
|
97
|
-
task :update_gem => file('redcarpet.gemspec')
|
|
98
|
-
|
|
99
73
|
directory 'pkg/'
|
|
100
74
|
|
|
101
75
|
file package('.gem') => %w[pkg/ redcarpet.gemspec] + $spec.files do |f|
|
|
@@ -114,9 +88,10 @@ def source_version
|
|
|
114
88
|
line.match(/.*VERSION = '(.*)'/)[1]
|
|
115
89
|
end
|
|
116
90
|
|
|
117
|
-
|
|
91
|
+
task :update_gem do
|
|
118
92
|
# read spec file and split out manifest section
|
|
119
|
-
|
|
93
|
+
GEMFILE = 'redcarpet.gemspec'
|
|
94
|
+
spec = File.read(GEMFILE)
|
|
120
95
|
head, manifest, tail = spec.split(" # = MANIFEST =\n")
|
|
121
96
|
head.sub!(/\.version = '.*'/, ".version = '#{source_version}'")
|
|
122
97
|
head.sub!(/\.date = '.*'/, ".date = '#{Date.today.to_s}'")
|
|
@@ -130,6 +105,26 @@ file 'redcarpet.gemspec' => FileList['Rakefile','lib/redcarpet.rb'] do |f|
|
|
|
130
105
|
# piece file back together and write...
|
|
131
106
|
manifest = " s.files = %w[\n#{files}\n ]\n"
|
|
132
107
|
spec = [head,manifest,tail].join(" # = MANIFEST =\n")
|
|
133
|
-
File.open(
|
|
134
|
-
puts "updated #{
|
|
108
|
+
File.open(GEMFILE, 'w') { |io| io.write(spec) }
|
|
109
|
+
puts "updated #{GEMFILE}"
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
desc 'Gather required Sundown sources into extension directory'
|
|
113
|
+
task :gather => 'sundown/src/markdown.h' do |t|
|
|
114
|
+
files =
|
|
115
|
+
FileList[
|
|
116
|
+
'sundown/src/{markdown,buffer,stack,autolink,html_blocks}.h',
|
|
117
|
+
'sundown/src/{markdown,buffer,stack,autolink}.c',
|
|
118
|
+
'sundown/html/{html,html_smartypants,houdini_html_e,houdini_href_e}.c',
|
|
119
|
+
'sundown/html/{html,houdini}.h',
|
|
120
|
+
]
|
|
121
|
+
cp files, 'ext/redcarpet/',
|
|
122
|
+
:preserve => true,
|
|
123
|
+
:verbose => true
|
|
135
124
|
end
|
|
125
|
+
|
|
126
|
+
file 'sundown/src/markdown.h' do |t|
|
|
127
|
+
abort "The Sundown submodule is required."
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
|
data/bin/redcarpet
CHANGED