redcarpet 1.13.1 → 1.13.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of redcarpet might be problematic. Click here for more details.
- data/README.markdown +8 -4
- data/ext/redcarpet/buffer.c +7 -3
- data/ext/redcarpet/html.c +10 -10
- data/ext/redcarpet/markdown.c +8 -0
- data/ext/redcarpet/markdown.h +10 -1
- data/lib/redcarpet.rb +1 -1
- data/redcarpet.gemspec +2 -3
- data/test/redcarpet_test.rb +1 -1
- metadata +4 -4
data/README.markdown
CHANGED
@@ -34,14 +34,18 @@ Usage
|
|
34
34
|
|
35
35
|
Redcarpet implements the basic protocol popularized by RedCloth:
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
~~~~~~ {ruby}
|
38
|
+
require 'redcarpet'
|
39
|
+
markdown = Redcarpet.new("Hello World!")
|
40
|
+
puts markdown.to_html
|
41
|
+
~~~~~~
|
40
42
|
|
41
43
|
Additional processing options can be turned on when creating the
|
42
44
|
Redcarpet object:
|
43
45
|
|
44
|
-
|
46
|
+
~~~~~~ {ruby}
|
47
|
+
markdown = Redcarpet.new("Hello World!", :smart, :filter_html)
|
48
|
+
~~~~~~
|
45
49
|
|
46
50
|
Note that by default, Redcarpet parses standard Markdown (with no extensions)
|
47
51
|
and offers a sane subset of parse options which allow you to modify the rendering
|
data/ext/redcarpet/buffer.c
CHANGED
@@ -188,7 +188,7 @@ void
|
|
188
188
|
bufnullterm(struct buf *buf) {
|
189
189
|
if (!buf || !buf->unit) return;
|
190
190
|
if (buf->size < buf->asize && buf->data[buf->size] == 0) return;
|
191
|
-
if (bufgrow(buf, buf->size + 1))
|
191
|
+
if (buf->size + 1 <= buf->asize || bufgrow(buf, buf->size + 1))
|
192
192
|
buf->data[buf->size] = 0; }
|
193
193
|
|
194
194
|
|
@@ -205,7 +205,9 @@ bufprintf(struct buf *buf, const char *fmt, ...) {
|
|
205
205
|
/* bufput • appends raw data to a buffer */
|
206
206
|
void
|
207
207
|
bufput(struct buf *buf, const void *data, size_t len) {
|
208
|
-
if (!buf
|
208
|
+
if (!buf) return;
|
209
|
+
if (buf->size + len > buf->asize && !bufgrow(buf, buf->size + len))
|
210
|
+
return;
|
209
211
|
memcpy(buf->data + buf->size, data, len);
|
210
212
|
buf->size += len; }
|
211
213
|
|
@@ -219,7 +221,9 @@ bufputs(struct buf *buf, const char *str) {
|
|
219
221
|
/* bufputc • appends a single char to a buffer */
|
220
222
|
void
|
221
223
|
bufputc(struct buf *buf, char c) {
|
222
|
-
if (!buf
|
224
|
+
if (!buf) return;
|
225
|
+
if (buf->size + 1 > buf->asize && !bufgrow(buf, buf->size + 1))
|
226
|
+
return;
|
223
227
|
buf->data[buf->size] = c;
|
224
228
|
buf->size += 1; }
|
225
229
|
|
data/ext/redcarpet/html.c
CHANGED
@@ -278,11 +278,11 @@ rndr_header(struct buf *ob, struct buf *text, int level, void *opaque)
|
|
278
278
|
if (ob->size)
|
279
279
|
bufputc(ob, '\n');
|
280
280
|
|
281
|
-
if (options->flags & HTML_TOC)
|
282
|
-
bufprintf(ob, "<
|
283
|
-
|
281
|
+
if (options->flags & HTML_TOC)
|
282
|
+
bufprintf(ob, "<h%d id=\"toc_%d\">", level, options->toc_data.header_count++);
|
283
|
+
else
|
284
|
+
bufprintf(ob, "<h%d>", level);
|
284
285
|
|
285
|
-
bufprintf(ob, "<h%d>", level);
|
286
286
|
if (text) bufput(ob, text->data, text->size);
|
287
287
|
bufprintf(ob, "</h%d>\n", level);
|
288
288
|
}
|
@@ -511,20 +511,20 @@ toc_header(struct buf *ob, struct buf *text, int level, void *opaque)
|
|
511
511
|
{
|
512
512
|
struct html_renderopt *options = opaque;
|
513
513
|
|
514
|
-
|
515
|
-
if (
|
514
|
+
while (level > options->toc_data.current_level) {
|
515
|
+
if (options->toc_data.current_level > 0)
|
516
516
|
BUFPUTSL(ob, "<li>");
|
517
517
|
BUFPUTSL(ob, "<ul>\n");
|
518
|
+
options->toc_data.current_level++;
|
518
519
|
}
|
519
|
-
|
520
|
-
|
520
|
+
|
521
|
+
while (level < options->toc_data.current_level) {
|
521
522
|
BUFPUTSL(ob, "</ul>");
|
522
523
|
if (options->toc_data.current_level > 1)
|
523
524
|
BUFPUTSL(ob, "</li>\n");
|
525
|
+
options->toc_data.current_level--;
|
524
526
|
}
|
525
527
|
|
526
|
-
options->toc_data.current_level = level;
|
527
|
-
|
528
528
|
bufprintf(ob, "<li><a href=\"#toc_%d\">", options->toc_data.header_count++);
|
529
529
|
if (text)
|
530
530
|
bufput(ob, text->data, text->size);
|
data/ext/redcarpet/markdown.c
CHANGED
@@ -2215,4 +2215,12 @@ ups_markdown(struct buf *ob, struct buf *ib, const struct mkd_renderer *rndrer,
|
|
2215
2215
|
parr_free(&rndr.work_bufs[BUFFER_BLOCK]);
|
2216
2216
|
}
|
2217
2217
|
|
2218
|
+
void
|
2219
|
+
ups_version(int *ver_major, int *ver_minor, int *ver_revision)
|
2220
|
+
{
|
2221
|
+
*ver_major = UPSKIRT_VER_MAJOR;
|
2222
|
+
*ver_minor = UPSKIRT_VER_MINOR;
|
2223
|
+
*ver_revision = UPSKIRT_VER_REVISION;
|
2224
|
+
}
|
2225
|
+
|
2218
2226
|
/* vim: set filetype=c: */
|
data/ext/redcarpet/markdown.h
CHANGED
@@ -21,6 +21,11 @@
|
|
21
21
|
|
22
22
|
#include "buffer.h"
|
23
23
|
|
24
|
+
#define UPSKIRT_VERSION "1.2.0"
|
25
|
+
#define UPSKIRT_VER_MAJOR 1
|
26
|
+
#define UPSKIRT_VER_MINOR 2
|
27
|
+
#define UPSKIRT_VER_REVISION 0
|
28
|
+
|
24
29
|
/********************
|
25
30
|
* TYPE DEFINITIONS *
|
26
31
|
********************/
|
@@ -104,10 +109,14 @@ is_safe_link(const char *link, size_t link_len);
|
|
104
109
|
* EXPORTED FUNCTIONS *
|
105
110
|
**********************/
|
106
111
|
|
107
|
-
/*
|
112
|
+
/* ups_markdown * parses the input buffer and renders it into the output buffer */
|
108
113
|
extern void
|
109
114
|
ups_markdown(struct buf *ob, struct buf *ib, const struct mkd_renderer *rndr, unsigned int extensions);
|
110
115
|
|
116
|
+
/* ups_version * returns the library version as major.minor.rev */
|
117
|
+
extern void
|
118
|
+
ups_version(int *major, int *minor, int *revision);
|
119
|
+
|
111
120
|
#endif
|
112
121
|
|
113
122
|
/* vim: set filetype=c: */
|
data/lib/redcarpet.rb
CHANGED
data/redcarpet.gemspec
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'redcarpet'
|
3
|
-
s.version = '1.13.
|
3
|
+
s.version = '1.13.2'
|
4
4
|
s.summary = "Ruby bindings for libupskirt"
|
5
5
|
s.description = 'A fast and safe Markdown to (X)HTML parser'
|
6
|
-
s.date = '2011-05-
|
6
|
+
s.date = '2011-05-16'
|
7
7
|
s.email = 'vicent@github.com'
|
8
8
|
s.homepage = 'http://github.com/tanoku/redcarpet'
|
9
|
-
s.has_rdoc = true
|
10
9
|
s.authors = ["Natacha Porté", "Vicent Martí"]
|
11
10
|
# = MANIFEST =
|
12
11
|
s.files = %w[
|
data/test/redcarpet_test.rb
CHANGED
@@ -113,7 +113,7 @@ class RedcarpetTest < Test::Unit::TestCase
|
|
113
113
|
def test_that_generate_toc_sets_toc_ids
|
114
114
|
rd = Redcarpet.new("# Level 1\n\n## Level 2", :generate_toc)
|
115
115
|
assert rd.generate_toc
|
116
|
-
assert_equal %(<
|
116
|
+
assert_equal %(<h1 id="toc_0">Level 1</h1>\n\n<h2 id="toc_1">Level 2</h2>\n), rd.to_html
|
117
117
|
end
|
118
118
|
|
119
119
|
def test_should_get_the_generated_toc
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redcarpet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 39
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 13
|
9
|
-
-
|
10
|
-
version: 1.13.
|
9
|
+
- 2
|
10
|
+
version: 1.13.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Natacha Port\xC3\xA9"
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-05-
|
19
|
+
date: 2011-05-16 00:00:00 +03:00
|
20
20
|
default_executable:
|
21
21
|
dependencies: []
|
22
22
|
|