redcarpet_yt 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/COPYING +20 -0
- data/Gemfile +9 -0
- data/README.markdown +394 -0
- data/Rakefile +60 -0
- data/bin/redcarpet +7 -0
- data/ext/redcarpet/autolink.c +302 -0
- data/ext/redcarpet/autolink.h +55 -0
- data/ext/redcarpet/buffer.c +203 -0
- data/ext/redcarpet/buffer.h +89 -0
- data/ext/redcarpet/extconf.rb +6 -0
- data/ext/redcarpet/houdini.h +51 -0
- data/ext/redcarpet/houdini_href_e.c +124 -0
- data/ext/redcarpet/houdini_html_e.c +105 -0
- data/ext/redcarpet/html.c +825 -0
- data/ext/redcarpet/html.h +84 -0
- data/ext/redcarpet/html_blocks.h +229 -0
- data/ext/redcarpet/html_smartypants.c +457 -0
- data/ext/redcarpet/markdown.c +2917 -0
- data/ext/redcarpet/markdown.h +143 -0
- data/ext/redcarpet/rc_markdown.c +168 -0
- data/ext/redcarpet/rc_render.c +545 -0
- data/ext/redcarpet/redcarpet.h +52 -0
- data/ext/redcarpet/stack.c +84 -0
- data/ext/redcarpet/stack.h +48 -0
- data/lib/redcarpet/cli.rb +86 -0
- data/lib/redcarpet/compat.rb +73 -0
- data/lib/redcarpet/render_man.rb +65 -0
- data/lib/redcarpet/render_strip.rb +60 -0
- data/lib/redcarpet_yt.rb +103 -0
- data/redcarpet_yt.gemspec +71 -0
- data/test/benchmark.rb +24 -0
- data/test/custom_render_test.rb +28 -0
- data/test/fixtures/benchmark.md +232 -0
- data/test/html5_test.rb +69 -0
- data/test/html_render_test.rb +254 -0
- data/test/html_toc_render_test.rb +75 -0
- data/test/markdown_test.rb +371 -0
- data/test/pathological_inputs_test.rb +34 -0
- data/test/redcarpet_bin_test.rb +80 -0
- data/test/redcarpet_compat_test.rb +38 -0
- data/test/safe_render_test.rb +35 -0
- data/test/smarty_html_test.rb +45 -0
- data/test/smarty_pants_test.rb +53 -0
- data/test/stripdown_render_test.rb +61 -0
- data/test/test_helper.rb +39 -0
- metadata +151 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2aa1d776e3b817786c807deca9cbe372593c000e
|
4
|
+
data.tar.gz: 53fba40629bdc564455ef6dca20f898a823a03b5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5f3c5bc9bf424086a6236bd0e7b6b3538245b07067328e6188c068a84c03cdf2cab55cb16b5d253285893a31d1d0b91e058cdeffcf1f351a8386ed30278b6288
|
7
|
+
data.tar.gz: abeb15773b4e7ae4d63b9552a7aecbe6dc34883bc00d0353bfb36d0321c706bcc6b95ab9c4af6ab64826a04e2f1d3ff8ef816024cf0e2e6130b196fc42555bf8
|
data/COPYING
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009, Natacha Porté
|
2
|
+
Copyright (c) 2015, Vicent Marti
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
6
|
+
in the Software without restriction, including without limitation the rights
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
9
|
+
furnished to do so, subject to the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included in
|
12
|
+
all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
THE SOFTWARE.
|
data/Gemfile
ADDED
data/README.markdown
ADDED
@@ -0,0 +1,394 @@
|
|
1
|
+
Redcarpet is written with sugar, spice and everything nice
|
2
|
+
============================================================
|
3
|
+
|
4
|
+
[![Build Status](https://travis-ci.org/vmg/redcarpet.svg?branch=master)](https://travis-ci.org/vmg/redcarpet)
|
5
|
+
[![Dependency Status](https://www.versioneye.com/ruby/redcarpet/badge.svg)](https://www.versioneye.com/ruby/redcarpet)
|
6
|
+
|
7
|
+
Redcarpet is a Ruby library for Markdown processing that smells like
|
8
|
+
butterflies and popcorn.
|
9
|
+
|
10
|
+
This library is written by people
|
11
|
+
---------------------------------
|
12
|
+
|
13
|
+
Redcarpet was written by [Vicent Martí](https://github.com/vmg). It is maintained by
|
14
|
+
[Robin Dupret](https://github.com/robin850) and [Matt Rogers](https://github.com/mattr-).
|
15
|
+
|
16
|
+
Redcarpet would not be possible without the [Sundown](https://www.github.com/vmg/sundown)
|
17
|
+
library and its authors (Natacha Porté, Vicent Martí, and its many awesome contributors).
|
18
|
+
|
19
|
+
You can totally install it as a Gem
|
20
|
+
-----------------------------------
|
21
|
+
|
22
|
+
Redcarpet is readily available as a Ruby gem. It will build some native
|
23
|
+
extensions, but the parser is standalone and requires no installed libraries.
|
24
|
+
Starting with Redcarpet 3.0, the minimum required Ruby version is 1.9.2 (or Rubinius in 1.9 mode).
|
25
|
+
|
26
|
+
$ [sudo] gem install redcarpet
|
27
|
+
|
28
|
+
If you need to use it with Ruby 1.8.7, you will need to stick with 2.3.0:
|
29
|
+
|
30
|
+
$ [sudo] gem install redcarpet -v 2.3.0
|
31
|
+
|
32
|
+
The Redcarpet source is available at GitHub:
|
33
|
+
|
34
|
+
$ git clone git://github.com/vmg/redcarpet.git
|
35
|
+
|
36
|
+
|
37
|
+
And it's like *really* simple to use
|
38
|
+
------------------------------------
|
39
|
+
|
40
|
+
The core of the Redcarpet library is the `Redcarpet::Markdown` class. Each
|
41
|
+
instance of the class is attached to a `Renderer` object; the Markdown class
|
42
|
+
performs parsing of a document and uses the attached renderer to generate
|
43
|
+
output.
|
44
|
+
|
45
|
+
The `Redcarpet::Markdown` object is encouraged to be instantiated once with the
|
46
|
+
required settings, and reused between parses.
|
47
|
+
|
48
|
+
~~~~~ ruby
|
49
|
+
# Initializes a Markdown parser
|
50
|
+
markdown = Redcarpet::Markdown.new(renderer, extensions = {})
|
51
|
+
~~~~~
|
52
|
+
|
53
|
+
Here, the `renderer` variable refers to a renderer object, inheriting
|
54
|
+
from `Redcarpet::Render::Base`. If the given object has not been
|
55
|
+
instantiated, the library will do it with default arguments.
|
56
|
+
|
57
|
+
Rendering with the `Markdown` object is done through `Markdown#render`.
|
58
|
+
Unlike in the RedCloth API, the text to render is passed as an argument
|
59
|
+
and not stored inside the `Markdown` instance, to encourage reusability.
|
60
|
+
Example:
|
61
|
+
|
62
|
+
~~~~~ ruby
|
63
|
+
markdown.render("This is *bongos*, indeed.")
|
64
|
+
# => "<p>This is <em>bongos</em>, indeed.</p>"
|
65
|
+
~~~~~
|
66
|
+
|
67
|
+
You can also specify a hash containing the Markdown extensions which the
|
68
|
+
parser will identify. The following extensions are accepted:
|
69
|
+
|
70
|
+
* `:no_intra_emphasis`: do not parse emphasis inside of words.
|
71
|
+
Strings such as `foo_bar_baz` will not generate `<em>` tags.
|
72
|
+
|
73
|
+
* `:tables`: parse tables, PHP-Markdown style.
|
74
|
+
|
75
|
+
* `:fenced_code_blocks`: parse fenced code blocks, PHP-Markdown
|
76
|
+
style. Blocks delimited with 3 or more `~` or backticks will be considered
|
77
|
+
as code, without the need to be indented. An optional language name may
|
78
|
+
be added at the end of the opening fence for the code block.
|
79
|
+
|
80
|
+
* `:autolink`: parse links even when they are not enclosed in `<>`
|
81
|
+
characters. Autolinks for the http, https and ftp protocols will be
|
82
|
+
automatically detected. Email addresses and http links without protocol,
|
83
|
+
but starting with `www` are also handled.
|
84
|
+
|
85
|
+
* `:disable_indented_code_blocks`: do not parse usual markdown
|
86
|
+
code blocks. Markdown converts text with four spaces at
|
87
|
+
the front of each line to code blocks. This option
|
88
|
+
prevents it from doing so. Recommended to use
|
89
|
+
with `fenced_code_blocks: true`.
|
90
|
+
|
91
|
+
* `:strikethrough`: parse strikethrough, PHP-Markdown style.
|
92
|
+
Two `~` characters mark the start of a strikethrough,
|
93
|
+
e.g. `this is ~~good~~ bad`.
|
94
|
+
|
95
|
+
* `:lax_spacing`: HTML blocks do not require to be surrounded by an
|
96
|
+
empty line as in the Markdown standard.
|
97
|
+
|
98
|
+
* `:space_after_headers`: A space is always required between the hash
|
99
|
+
at the beginning of a header and its name, e.g. `#this is my header`
|
100
|
+
would not be a valid header.
|
101
|
+
|
102
|
+
* `:superscript`: parse superscripts after the `^` character; contiguous superscripts
|
103
|
+
are nested together, and complex values can be enclosed in parenthesis, e.g.
|
104
|
+
`this is the 2^(nd) time`.
|
105
|
+
|
106
|
+
* `:underline`: parse underscored emphasis as underlines.
|
107
|
+
`This is _underlined_ but this is still *italic*`.
|
108
|
+
|
109
|
+
* `:highlight`: parse highlights.
|
110
|
+
`This is ==highlighted==`. It looks like this: `<mark>highlighted</mark>`
|
111
|
+
|
112
|
+
* `:quote`: parse quotes.
|
113
|
+
`This is a "quote"`. It looks like this: `<q>quote</q>`
|
114
|
+
|
115
|
+
* `:footnotes`: parse footnotes, PHP-Markdown style. A footnote works very much
|
116
|
+
like a reference-style link: it consists of a marker next to the text (e.g.
|
117
|
+
`This is a sentence.[^1]`) and a footnote definition on its own line anywhere
|
118
|
+
within the document (e.g. `[^1]: This is a footnote.`).
|
119
|
+
|
120
|
+
Example:
|
121
|
+
|
122
|
+
~~~ruby
|
123
|
+
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, tables: true)
|
124
|
+
~~~~~
|
125
|
+
|
126
|
+
Darling, I packed you a couple renderers for lunch
|
127
|
+
--------------------------------------------------
|
128
|
+
|
129
|
+
Redcarpet comes with two built-in renderers, `Redcarpet::Render::HTML` and
|
130
|
+
`Redcarpet::Render::XHTML`, which output HTML and XHTML, respectively. These
|
131
|
+
renderers are actually implemented in C and hence offer brilliant
|
132
|
+
performance — several degrees of magnitude faster than other Ruby Markdown
|
133
|
+
solutions.
|
134
|
+
|
135
|
+
All the rendering flags that previously applied only to HTML output have
|
136
|
+
now been moved to the `Redcarpet::Render::HTML` class, and may be enabled when
|
137
|
+
instantiating the renderer:
|
138
|
+
|
139
|
+
~~~~~ ruby
|
140
|
+
Redcarpet::Render::HTML.new(render_options = {})
|
141
|
+
~~~~~
|
142
|
+
|
143
|
+
Initializes an HTML renderer. The following flags are available:
|
144
|
+
|
145
|
+
* `:filter_html`: do not allow any user-inputted HTML in the output.
|
146
|
+
|
147
|
+
* `:no_images`: do not generate any `<img>` tags.
|
148
|
+
|
149
|
+
* `:no_links`: do not generate any `<a>` tags.
|
150
|
+
|
151
|
+
* `:no_styles`: do not generate any `<style>` tags.
|
152
|
+
|
153
|
+
* `:escape_html`: escape any HTML tags. This option has precedence over
|
154
|
+
`:no_styles`, `:no_links`, `:no_images` and `:filter_html` which means
|
155
|
+
that any existing tag will be escaped instead of being removed.
|
156
|
+
|
157
|
+
* `:safe_links_only`: only generate links for protocols which are considered
|
158
|
+
safe.
|
159
|
+
|
160
|
+
* `:with_toc_data`: add HTML anchors to each header in the output HTML,
|
161
|
+
to allow linking to each section.
|
162
|
+
|
163
|
+
* `:hard_wrap`: insert HTML `<br>` tags inside paragraphs where the original
|
164
|
+
Markdown document had newlines (by default, Markdown ignores these newlines).
|
165
|
+
|
166
|
+
* `:xhtml`: output XHTML-conformant tags. This option is always enabled in the
|
167
|
+
`Render::XHTML` renderer.
|
168
|
+
|
169
|
+
* `:prettify`: add prettyprint classes to `<code>` tags for google-code-prettify.
|
170
|
+
|
171
|
+
* `:link_attributes`: hash of extra attributes to add to links.
|
172
|
+
|
173
|
+
Example:
|
174
|
+
|
175
|
+
~~~~~ ruby
|
176
|
+
renderer = Redcarpet::Render::HTML.new(no_links: true, hard_wrap: true)
|
177
|
+
~~~~~
|
178
|
+
|
179
|
+
|
180
|
+
The `HTML` renderer has an alternate version, `Redcarpet::Render::HTML_TOC`,
|
181
|
+
which will output a table of contents in HTML based on the headers of the
|
182
|
+
Markdown document.
|
183
|
+
|
184
|
+
When instantiating this render object, you can optionally pass a `nesting_level`
|
185
|
+
option which takes an integer and allows you to make it render only headers
|
186
|
+
until a specific level.
|
187
|
+
|
188
|
+
Furthermore, the abstract base class `Redcarpet::Render::Base` can be used
|
189
|
+
to write a custom renderer purely in Ruby, or extending an existing renderer.
|
190
|
+
See the following section for more information.
|
191
|
+
|
192
|
+
|
193
|
+
And you can even cook your own
|
194
|
+
------------------------------
|
195
|
+
|
196
|
+
Custom renderers are created by inheriting from an existing renderer. The
|
197
|
+
built-in renderers, `HTML` and `XHTML` may be extended as such:
|
198
|
+
|
199
|
+
~~~~~ ruby
|
200
|
+
# create a custom renderer that allows highlighting of code blocks
|
201
|
+
class HTMLwithPygments < Redcarpet::Render::HTML
|
202
|
+
def block_code(code, language)
|
203
|
+
Pygments.highlight(code, lexer: language)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
markdown = Redcarpet::Markdown.new(HTMLwithPygments, fenced_code_blocks: true)
|
208
|
+
~~~~~
|
209
|
+
|
210
|
+
But new renderers can also be created from scratch (see `lib/redcarpet/render_man.rb` for
|
211
|
+
an example implementation of a Manpage renderer)
|
212
|
+
|
213
|
+
~~~~~~ ruby
|
214
|
+
class ManPage < Redcarpet::Render::Base
|
215
|
+
# you get the drill -- keep going from here
|
216
|
+
end
|
217
|
+
~~~~~
|
218
|
+
|
219
|
+
The following instance methods may be implemented by the renderer:
|
220
|
+
|
221
|
+
### Block-level calls
|
222
|
+
|
223
|
+
If the return value of the method is `nil`, the block will be skipped.
|
224
|
+
Therefore, make sure that your renderer has at least a `paragraph` method
|
225
|
+
implemented. If the method for a document element is not implemented, the
|
226
|
+
block will be skipped.
|
227
|
+
|
228
|
+
Example:
|
229
|
+
|
230
|
+
~~~~ ruby
|
231
|
+
class RenderWithoutCode < Redcarpet::Render::HTML
|
232
|
+
def block_code(code, language)
|
233
|
+
nil
|
234
|
+
end
|
235
|
+
end
|
236
|
+
~~~~
|
237
|
+
|
238
|
+
* block_code(code, language)
|
239
|
+
* block_quote(quote)
|
240
|
+
* block_html(raw_html)
|
241
|
+
* footnotes(content)
|
242
|
+
* footnote_def(content, number)
|
243
|
+
* header(text, header_level)
|
244
|
+
* hrule()
|
245
|
+
* list(contents, list_type)
|
246
|
+
* list_item(text, list_type)
|
247
|
+
* paragraph(text)
|
248
|
+
* table(header, body)
|
249
|
+
* table_row(content)
|
250
|
+
* table_cell(content, alignment)
|
251
|
+
|
252
|
+
### Span-level calls
|
253
|
+
|
254
|
+
A return value of `nil` will not output any data. If the method for
|
255
|
+
a document element is not implemented, the contents of the span will
|
256
|
+
be copied verbatim:
|
257
|
+
|
258
|
+
* autolink(link, link_type)
|
259
|
+
* codespan(code)
|
260
|
+
* double_emphasis(text)
|
261
|
+
* emphasis(text)
|
262
|
+
* image(link, title, alt_text)
|
263
|
+
* linebreak()
|
264
|
+
* link(link, title, content)
|
265
|
+
* raw_html(raw_html)
|
266
|
+
* triple_emphasis(text)
|
267
|
+
* strikethrough(text)
|
268
|
+
* superscript(text)
|
269
|
+
* underline(text)
|
270
|
+
* highlight(text)
|
271
|
+
* quote(text)
|
272
|
+
* footnote_ref(number)
|
273
|
+
|
274
|
+
**Note**: When overriding a renderer's method, be sure to return a HTML
|
275
|
+
element with a level that matches the level of that method (e.g. return a
|
276
|
+
block element when overriding a block-level callback). Otherwise, the output
|
277
|
+
may be unexpected.
|
278
|
+
|
279
|
+
### Low level rendering
|
280
|
+
|
281
|
+
* entity(text)
|
282
|
+
* normal_text(text)
|
283
|
+
|
284
|
+
### Header of the document
|
285
|
+
|
286
|
+
Rendered before any another elements:
|
287
|
+
|
288
|
+
* doc_header()
|
289
|
+
|
290
|
+
### Footer of the document
|
291
|
+
|
292
|
+
Rendered after all the other elements:
|
293
|
+
|
294
|
+
* doc_footer()
|
295
|
+
|
296
|
+
### Pre/post-process
|
297
|
+
|
298
|
+
Special callback: preprocess or postprocess the whole document before
|
299
|
+
or after the rendering process begins:
|
300
|
+
|
301
|
+
* preprocess(full_document)
|
302
|
+
* postprocess(full_document)
|
303
|
+
|
304
|
+
You can look at
|
305
|
+
["How to extend the Redcarpet 2 Markdown library?"](http://dev.af83.com/2012/02/27/howto-extend-the-redcarpet2-markdown-lib.html)
|
306
|
+
for some more explanations.
|
307
|
+
|
308
|
+
Also, now our Pants are much smarter
|
309
|
+
------------------------------------
|
310
|
+
|
311
|
+
Redcarpet 2 comes with a standalone [SmartyPants](
|
312
|
+
http://daringfireball.net/projects/smartypants/) implementation. It is fully
|
313
|
+
compliant with the original implementation. It is the fastest SmartyPants
|
314
|
+
parser there is, with a difference of several orders of magnitude.
|
315
|
+
|
316
|
+
The SmartyPants parser can be found in `Redcarpet::Render::SmartyPants`. It has
|
317
|
+
been implemented as a module, so it can be used standalone or as a mixin.
|
318
|
+
|
319
|
+
When mixed with a Renderer class, it will override the `postprocess` method
|
320
|
+
to perform SmartyPants replacements once the rendering is complete.
|
321
|
+
|
322
|
+
~~~~ ruby
|
323
|
+
# Mixin
|
324
|
+
class HTMLWithPants < Redcarpet::Render::HTML
|
325
|
+
include Redcarpet::Render::SmartyPants
|
326
|
+
end
|
327
|
+
|
328
|
+
# Standalone
|
329
|
+
Redcarpet::Render::SmartyPants.render("<p>Oh SmartyPants, you're so crazy...</p>")
|
330
|
+
~~~~~
|
331
|
+
|
332
|
+
SmartyPants works on top of already-rendered HTML, and will ignore replacements
|
333
|
+
inside the content of HTML tags and inside specific HTML blocks such as
|
334
|
+
`<code>` or `<pre>`.
|
335
|
+
|
336
|
+
What? You really want to mix Markdown renderers?
|
337
|
+
------------------------------------------------
|
338
|
+
|
339
|
+
Redcarpet used to be a drop-in replacement for Redcloth. This is no longer the
|
340
|
+
case since version 2 -- it now has its own API, but retains the old name. Yes,
|
341
|
+
that does mean that Redcarpet is not backwards-compatible with the 1.X
|
342
|
+
versions.
|
343
|
+
|
344
|
+
Each renderer has its own API and its own set of extensions: you should choose one
|
345
|
+
(it doesn't have to be Redcarpet, though that would be great!), write your
|
346
|
+
software accordingly, and force your users to install it. That's the
|
347
|
+
only way to have reliable and predictable Markdown output on your program.
|
348
|
+
|
349
|
+
Markdown is already ill-specified enough; if you create software that is
|
350
|
+
renderer-independent, the results will be completely unreliable!
|
351
|
+
|
352
|
+
Still, if major forces (let's say, tornadoes or other natural disasters) force you
|
353
|
+
to keep a Markdown-compatibility layer, Redcarpet also supports this:
|
354
|
+
|
355
|
+
~~~~~ ruby
|
356
|
+
require 'redcarpet/compat'
|
357
|
+
~~~~~
|
358
|
+
|
359
|
+
Requiring the compatibility library will declare a `Markdown` class with the
|
360
|
+
classical RedCloth API, e.g.
|
361
|
+
|
362
|
+
~~~~~ ruby
|
363
|
+
Markdown.new('this is my text').to_html
|
364
|
+
~~~~~
|
365
|
+
|
366
|
+
This class renders 100% standards compliant Markdown with 0 extensions. Nada.
|
367
|
+
Don't even try to enable extensions with a compatibility layer, because
|
368
|
+
that's a maintenance nightmare and won't work.
|
369
|
+
|
370
|
+
On a related topic: if your Markdown gem has a `lib/markdown.rb` file that
|
371
|
+
monkeypatches the Markdown class, you're a terrible human being. Just saying.
|
372
|
+
|
373
|
+
Boring legal stuff
|
374
|
+
------------------
|
375
|
+
|
376
|
+
Copyright (c) 2011-2015, Vicent Martí
|
377
|
+
|
378
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
379
|
+
of this software and associated documentation files (the "Software"), to deal
|
380
|
+
in the Software without restriction, including without limitation the rights
|
381
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
382
|
+
copies of the Software, and to permit persons to whom the Software is
|
383
|
+
furnished to do so, subject to the following conditions:
|
384
|
+
|
385
|
+
The above copyright notice and this permission notice shall be included in
|
386
|
+
all copies or substantial portions of the Software.
|
387
|
+
|
388
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
389
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
390
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
391
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
392
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
393
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
394
|
+
THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'rake/extensiontask'
|
4
|
+
require 'digest/md5'
|
5
|
+
|
6
|
+
task :default => [:test]
|
7
|
+
|
8
|
+
# Gem Spec
|
9
|
+
gem_spec = Gem::Specification.load('redcarpet.gemspec')
|
10
|
+
|
11
|
+
# Ruby Extension
|
12
|
+
Rake::ExtensionTask.new('redcarpet', gem_spec)
|
13
|
+
|
14
|
+
# Packaging
|
15
|
+
require 'bundler/gem_tasks'
|
16
|
+
|
17
|
+
# Testing
|
18
|
+
require 'rake/testtask'
|
19
|
+
|
20
|
+
Rake::TestTask.new('test:unit') do |t|
|
21
|
+
t.libs << 'lib'
|
22
|
+
t.libs << 'test'
|
23
|
+
t.pattern = 'test/*_test.rb'
|
24
|
+
t.verbose = true
|
25
|
+
t.warning = false
|
26
|
+
end
|
27
|
+
|
28
|
+
task 'test:unit' => :compile
|
29
|
+
|
30
|
+
desc 'Run conformance tests (MARKDOWN_TEST_VER=1.0.3)'
|
31
|
+
task 'test:conformance' => :compile do |t|
|
32
|
+
script = "#{pwd}/bin/redcarpet"
|
33
|
+
version = ENV['MARKDOWN_TEST_VER'] || '1.0.3'
|
34
|
+
lib_dir = "#{pwd}/lib"
|
35
|
+
|
36
|
+
chdir("test/MarkdownTest_#{version}") do
|
37
|
+
sh "RUBYLIB=#{lib_dir} ./MarkdownTest.pl --script='#{script}' --tidy"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
desc 'Run version 1.0 conformance suite'
|
42
|
+
task 'test:conformance:1.0' => :compile do |t|
|
43
|
+
ENV['MARKDOWN_TEST_VER'] = '1.0'
|
44
|
+
Rake::Task['test:conformance'].invoke
|
45
|
+
end
|
46
|
+
|
47
|
+
desc 'Run 1.0.3 conformance suite'
|
48
|
+
task 'test:conformance:1.0.3' => :compile do |t|
|
49
|
+
ENV['MARKDOWN_TEST_VER'] = '1.0.3'
|
50
|
+
Rake::Task['test:conformance'].invoke
|
51
|
+
end
|
52
|
+
|
53
|
+
desc 'Run unit and conformance tests'
|
54
|
+
task :test => %w[test:unit test:conformance]
|
55
|
+
|
56
|
+
desc 'Run benchmarks'
|
57
|
+
task :benchmark => :compile do |t|
|
58
|
+
$:.unshift 'lib'
|
59
|
+
load 'test/benchmark.rb'
|
60
|
+
end
|