greenmat 3.2.2.4 → 3.5.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 76edffbbbd17aad1bb2dca2fe858ae3de4dac30ec712f923a9a5f4da23e910c8
4
- data.tar.gz: 71f03be1b989cec97a7453db1a7cb4eaba97b1be3857e52f178c8191d9f1d4c0
3
+ metadata.gz: f39bc77cb9919af4e018b008bbc6d1cd8347d7bee919592dbe96d09b8eeab19f
4
+ data.tar.gz: c3f07e638dddaa7bd603d0d044a6c847abd425c65aa2106701d1e8ccf4b547ce
5
5
  SHA512:
6
- metadata.gz: aecd348a33adfbe06bfe6033eeae1f2b0852172cff4b11536e22acd87386861d079df3afe487c3d3dfbe8a42902ffd9f42c9fa84783a0be213ef274922236ed5
7
- data.tar.gz: 6e6bea252d5660ede666d0030811780b8937b1ca6465569b0b93edb5b70322c4376f148b190dab68fabe23a0569a9fcf612ad648e4f61fdef55a6d8cd913ecf7
6
+ metadata.gz: '02870d7ebb28e12b26c38b80363be12db1961fcb0c1e2f2a99d0e95eded8f5c203c8750e95afa2300e08784c17ae3ccc5f73d19ff1ef8c3133cb98bf0eae1f22'
7
+ data.tar.gz: 722bb67d5443e75f266881a60a2dd090c4417dd44f1049ebaaf4185c9e4fa5d72232182794ce648a31cb3a33b0315e2ec7b6c4458428567b4c1a9449c6bfabc9
data/.travis.yml CHANGED
@@ -1,12 +1,27 @@
1
- before_install:
2
- - sudo apt-get -qq update
3
- - sudo apt-get -qq install tidy
1
+ sudo: false
2
+ dist: trusty
4
3
 
5
- install: travis_retry bundle install --without=benchmark
4
+ addons:
5
+ apt:
6
+ packages:
7
+ - tidy
8
+ - tcl
9
+ - tk
10
+
11
+ install: bundle install --without=benchmark
6
12
 
7
13
  rvm:
14
+ - 2.0.0
15
+ - 2.1
8
16
  - 2.2
9
17
  - 2.3
10
18
  - 2.4
19
+ - 2.5
20
+ - ruby-head
21
+
22
+ matrix:
23
+ allow_failures:
24
+ - rvm: ruby-head
25
+
11
26
  notifications:
12
27
  email: false
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## v3.5.1.0
6
+
7
+ * Update base Redcarpet version to 3.5.1.
8
+
5
9
  ## v3.2.2.4
6
10
 
7
11
  * Relax max nesting.
data/COPYING CHANGED
@@ -1,14 +1,20 @@
1
1
  Copyright (c) 2009, Natacha Porté
2
- Copyright (c) 2011, Vicent Marti
2
+ Copyright (c) 2015, Vicent Marti
3
3
 
4
- Permission to use, copy, modify, and distribute this software for any
5
- purpose with or without fee is hereby granted, provided that the above
6
- copyright notice and this permission notice appear in all copies.
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:
7
10
 
8
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
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 CHANGED
@@ -3,7 +3,7 @@ source "https://rubygems.org/"
3
3
  gemspec
4
4
 
5
5
  group :benchmark do
6
- gem "benchmark-ips", "~> 1.2.0"
6
+ gem "benchmark-ips", "~> 2.7.2"
7
7
  gem "bluecloth", "~> 2.2.0"
8
- gem "kramdown", "~> 1.0.2"
8
+ gem "kramdown", "~> 1.13.2"
9
9
  end
data/README.md CHANGED
@@ -54,16 +54,22 @@ We appreciate Redcarpet project and the contributors for the great efforts!
54
54
 
55
55
  ### Redcarpet
56
56
 
57
- Copyright (c) 2011-2014, Vicent Martí
58
-
59
- Permission to use, copy, modify, and/or distribute this software for any
60
- purpose with or without fee is hereby granted, provided that the above
61
- copyright notice and this permission notice appear in all copies.
62
-
63
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
64
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
65
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
66
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
67
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
68
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
69
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
57
+ Copyright (c) 2011-2016, Vicent Martí
58
+
59
+ Permission is hereby granted, free of charge, to any person obtaining a copy
60
+ of this software and associated documentation files (the "Software"), to deal
61
+ in the Software without restriction, including without limitation the rights
62
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
63
+ copies of the Software, and to permit persons to whom the Software is
64
+ furnished to do so, subject to the following conditions:
65
+
66
+ The above copyright notice and this permission notice shall be included in
67
+ all copies or substantial portions of the Software.
68
+
69
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
70
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
71
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
72
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
73
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
74
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
75
+ THE SOFTWARE.
data/bin/greenmat CHANGED
@@ -1,43 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
- # Usage: greenmat [--parse-<extension>...] [--render-<extension>...] [--smarty] [<file>...]
3
- # Convert one or more Markdown files to HTML and write to standard output. With
4
- # no <file> or when <file> is '-', read Markdown source text from standard input.
5
- # With <extension>s, perform additional Markdown processing before writing output.
6
- # With --smarty, use the SmartyHTML renderer
7
- if ARGV.include?('--help') or ARGV.include?('-h')
8
- File.read(__FILE__).split("\n").grep(/^# /).each do |line|
9
- puts line[2..-1]
10
- end
11
- exit 0
12
- end
2
+ lib_path = File.expand_path('../../lib', __FILE__)
3
+ $:.unshift(lib_path)
13
4
 
14
- require 'greenmat'
5
+ require 'greenmat/cli'
15
6
 
16
- if ARGV.include?('--version') or ARGV.include?('-v')
17
- puts "Greenmat #{Greenmat::VERSION}"
18
- exit 0
19
- end
20
-
21
- root = File.expand_path('../../', __FILE__)
22
- $:.unshift File.expand_path('lib', root)
23
-
24
- render_extensions = {}
25
- parse_extensions = {}
26
- renderer = Greenmat::Render::HTML
27
-
28
- ARGV.delete_if do |arg|
29
- if arg =~ /^--render-([\w-]+)$/
30
- arg = $1.gsub('-', '_')
31
- render_extensions[arg.to_sym] = true
32
- elsif arg =~ /^--parse-([\w-]+)$/
33
- arg = $1.gsub('-', '_')
34
- parse_extensions[arg.to_sym] = true
35
- elsif arg == '--smarty'
36
- renderer = Greenmat::Render::SmartyHTML
37
- else
38
- false
39
- end
40
- end
41
-
42
- render = renderer.new(render_extensions)
43
- STDOUT.write(Greenmat::Markdown.new(render, parse_extensions).render(ARGF.read))
7
+ Greenmat::CLI.process(ARGV)
@@ -1,17 +1,23 @@
1
1
  /*
2
- * Copyright (c) 2011, Vicent Marti
2
+ * Copyright (c) 2015, Vicent Marti
3
3
  *
4
- * Permission to use, copy, modify, and distribute this software for any
5
- * purpose with or without fee is hereby granted, provided that the above
6
- * copyright notice and this permission notice appear in all copies.
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:
7
10
  *
8
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
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.
15
21
  */
16
22
 
17
23
  #include "buffer.h"
@@ -289,9 +295,15 @@ sd_autolink__url(
289
295
  if (link_end == 0)
290
296
  return 0;
291
297
 
298
+ /**
299
+ * In certain cases, we may refer to a link at the end of a
300
+ * sentence so the period should not be part of the URL.
301
+ */
302
+ if (data[link_end - 1] == '.')
303
+ link_end--;
304
+
292
305
  bufput(link, data - rewind, link_end + rewind);
293
306
  *rewind_p = rewind;
294
307
 
295
308
  return link_end;
296
309
  }
297
-
@@ -1,21 +1,28 @@
1
1
  /*
2
2
  * Copyright (c) 2008, Natacha Porté
3
- * Copyright (c) 2011, Vicent Martí
3
+ * Copyright (c) 2015, Vicent Marti
4
4
  *
5
- * Permission to use, copy, modify, and distribute this software for any
6
- * purpose with or without fee is hereby granted, provided that the above
7
- * copyright notice and this permission notice appear in all copies.
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
8
11
  *
9
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
12
+ * The above copyright notice and this permission notice shall be included in
13
+ * all copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ * THE SOFTWARE.
16
22
  */
17
23
 
18
24
  #define BUFFER_MAX_ALLOC_SIZE (1024 * 1024 * 16) //16mb
25
+ #define __USE_MINGW_ANSI_STDIO 1
19
26
 
20
27
  #include "buffer.h"
21
28
 
@@ -94,14 +101,14 @@ bufnew(size_t unit)
94
101
 
95
102
  /* bufnullterm: NULL-termination of the string array */
96
103
  const char *
97
- bufcstr(struct buf *buf)
104
+ bufcstr(const struct buf *buf)
98
105
  {
99
106
  assert(buf && buf->unit);
100
107
 
101
108
  if (buf->size < buf->asize && buf->data[buf->size] == 0)
102
109
  return (char *)buf->data;
103
110
 
104
- if (buf->size + 1 <= buf->asize || bufgrow(buf, buf->size + 1) == 0) {
111
+ if (buf->size + 1 <= buf->asize || bufgrow(buf, buf->size + 1) == BUF_OK) {
105
112
  buf->data[buf->size] = 0;
106
113
  return (char *)buf->data;
107
114
  }
@@ -118,7 +125,7 @@ bufprintf(struct buf *buf, const char *fmt, ...)
118
125
 
119
126
  assert(buf && buf->unit);
120
127
 
121
- if (buf->size >= buf->asize && bufgrow(buf, buf->size + 1) < 0)
128
+ if (buf->size >= buf->asize && bufgrow(buf, buf->size + 1) < BUF_OK)
122
129
  return;
123
130
 
124
131
  va_start(ap, fmt);
@@ -136,7 +143,7 @@ bufprintf(struct buf *buf, const char *fmt, ...)
136
143
  }
137
144
 
138
145
  if ((size_t)n >= buf->asize - buf->size) {
139
- if (bufgrow(buf, buf->size + n + 1) < 0)
146
+ if (bufgrow(buf, buf->size + n + 1) < BUF_OK)
140
147
  return;
141
148
 
142
149
  va_start(ap, fmt);
@@ -156,7 +163,7 @@ bufput(struct buf *buf, const void *data, size_t len)
156
163
  {
157
164
  assert(buf && buf->unit);
158
165
 
159
- if (buf->size + len > buf->asize && bufgrow(buf, buf->size + len) < 0)
166
+ if (buf->size + len > buf->asize && bufgrow(buf, buf->size + len) < BUF_OK)
160
167
  return;
161
168
 
162
169
  memcpy(buf->data + buf->size, data, len);
@@ -177,7 +184,7 @@ bufputc(struct buf *buf, int c)
177
184
  {
178
185
  assert(buf && buf->unit);
179
186
 
180
- if (buf->size + 1 > buf->asize && bufgrow(buf, buf->size + 1) < 0)
187
+ if (buf->size + 1 > buf->asize && bufgrow(buf, buf->size + 1) < BUF_OK)
181
188
  return;
182
189
 
183
190
  buf->data[buf->size] = c;
@@ -1,18 +1,24 @@
1
1
  /*
2
2
  * Copyright (c) 2008, Natacha Porté
3
- * Copyright (c) 2011, Vicent Martí
3
+ * Copyright (c) 2015, Vicent Marti
4
4
  *
5
- * Permission to use, copy, modify, and distribute this software for any
6
- * purpose with or without fee is hereby granted, provided that the above
7
- * copyright notice and this permission notice appear in all copies.
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
8
11
  *
9
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
12
+ * The above copyright notice and this permission notice shall be included in
13
+ * all copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ * THE SOFTWARE.
16
22
  */
17
23
 
18
24
  #ifndef BUFFER_H__
@@ -55,7 +61,7 @@ int bufgrow(struct buf *, size_t);
55
61
  struct buf *bufnew(size_t) __attribute__ ((malloc));
56
62
 
57
63
  /* bufnullterm: NUL-termination of the string array (making a C-string) */
58
- const char *bufcstr(struct buf *);
64
+ const char *bufcstr(const struct buf *);
59
65
 
60
66
  /* bufprefix: compare the beginning of a buffer with a string */
61
67
  int bufprefix(const struct buf *buf, const char *prefix);
@@ -80,4 +86,3 @@ void bufprintf(struct buf *, const char *, ...) __attribute__ ((format (printf,
80
86
  #endif
81
87
 
82
88
  #endif
83
-
@@ -1,22 +1,30 @@
1
1
  /*
2
- * Copyright (c) 2011, Vicent Marti
2
+ * Copyright (c) 2015, Vicent Marti
3
3
  *
4
- * Permission to use, copy, modify, and distribute this software for any
5
- * purpose with or without fee is hereby granted, provided that the above
6
- * copyright notice and this permission notice appear in all copies.
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:
7
10
  *
8
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
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.
15
21
  */
22
+
16
23
  #include "greenmat.h"
17
24
 
18
25
  VALUE rb_mGreenmat;
19
26
  VALUE rb_cMarkdown;
27
+ VALUE rb_cRenderHTML_TOC;
20
28
 
21
29
  extern VALUE rb_cRenderBase;
22
30
 
@@ -84,7 +92,7 @@ rb_greenmat_md__free(void *markdown)
84
92
 
85
93
  static VALUE rb_greenmat_md__new(int argc, VALUE *argv, VALUE klass)
86
94
  {
87
- VALUE rb_markdown, rb_rndr, hash;
95
+ VALUE rb_markdown, rb_rndr, hash, rndr_options;
88
96
  unsigned int extensions = 0;
89
97
 
90
98
  struct rb_greenmat_rndr *rndr;
@@ -99,8 +107,23 @@ static VALUE rb_greenmat_md__new(int argc, VALUE *argv, VALUE klass)
99
107
  if (!rb_obj_is_kind_of(rb_rndr, rb_cRenderBase))
100
108
  rb_raise(rb_eTypeError, "Invalid Renderer instance given");
101
109
 
110
+ /**
111
+ * Automatically enable the `fenced_code_blocks` option if
112
+ * given a kind of `HTML_TOC` object since many languages
113
+ * like Ruby use the sharp to comment code so these comments
114
+ * would be processed as titles.
115
+ */
116
+ if (rb_obj_is_kind_of(rb_rndr, rb_cRenderHTML_TOC))
117
+ extensions |= MKDEXT_FENCED_CODE;
118
+
102
119
  Data_Get_Struct(rb_rndr, struct rb_greenmat_rndr, rndr);
103
120
 
121
+ /* Merge the current options in the @options hash */
122
+ if (hash != Qnil) {
123
+ rndr_options = rb_funcall(rb_iv_get(rb_rndr, "@options"), rb_intern("merge"), 1, hash);
124
+ rb_iv_set(rb_rndr, "@options", rndr_options);
125
+ }
126
+
104
127
  markdown = sd_markdown_new(extensions, MAX_NESTING, &rndr->callbacks, &rndr->options);
105
128
  if (!markdown)
106
129
  rb_raise(rb_eRuntimeError, "Failed to create new Renderer class");
@@ -167,4 +190,3 @@ void Init_greenmat()
167
190
 
168
191
  Init_greenmat_rndr();
169
192
  }
170
-