github-markdown 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -49,7 +49,7 @@ sd_autolink_issafe(const uint8_t *link, size_t link_len)
49
49
  }
50
50
 
51
51
  static size_t
52
- autolink_delim(uint8_t *data, size_t link_end, size_t offset, size_t size)
52
+ autolink_delim(uint8_t *data, size_t link_end, size_t max_rewind, size_t size)
53
53
  {
54
54
  uint8_t cclose, copen = 0;
55
55
  size_t i;
@@ -163,13 +163,13 @@ sd_autolink__www(
163
163
  size_t *rewind_p,
164
164
  struct buf *link,
165
165
  uint8_t *data,
166
- size_t offset,
166
+ size_t max_rewind,
167
167
  size_t size,
168
168
  unsigned int flags)
169
169
  {
170
170
  size_t link_end;
171
171
 
172
- if (offset > 0 && !ispunct(data[-1]) && !isspace(data[-1]))
172
+ if (max_rewind > 0 && !ispunct(data[-1]) && !isspace(data[-1]))
173
173
  return 0;
174
174
 
175
175
  if (size < 4 || memcmp(data, "www.", strlen("www.")) != 0)
@@ -183,7 +183,7 @@ sd_autolink__www(
183
183
  while (link_end < size && !isspace(data[link_end]))
184
184
  link_end++;
185
185
 
186
- link_end = autolink_delim(data, link_end, offset, size);
186
+ link_end = autolink_delim(data, link_end, max_rewind, size);
187
187
 
188
188
  if (link_end == 0)
189
189
  return 0;
@@ -199,14 +199,14 @@ sd_autolink__email(
199
199
  size_t *rewind_p,
200
200
  struct buf *link,
201
201
  uint8_t *data,
202
- size_t offset,
202
+ size_t max_rewind,
203
203
  size_t size,
204
204
  unsigned int flags)
205
205
  {
206
206
  size_t link_end, rewind;
207
207
  int nb = 0, np = 0;
208
208
 
209
- for (rewind = 0; rewind < offset; ++rewind) {
209
+ for (rewind = 0; rewind < max_rewind; ++rewind) {
210
210
  uint8_t c = data[-rewind - 1];
211
211
 
212
212
  if (isalnum(c))
@@ -238,7 +238,7 @@ sd_autolink__email(
238
238
  if (link_end < 2 || nb != 1 || np == 0)
239
239
  return 0;
240
240
 
241
- link_end = autolink_delim(data, link_end, offset, size);
241
+ link_end = autolink_delim(data, link_end, max_rewind, size);
242
242
 
243
243
  if (link_end == 0)
244
244
  return 0;
@@ -254,7 +254,7 @@ sd_autolink__url(
254
254
  size_t *rewind_p,
255
255
  struct buf *link,
256
256
  uint8_t *data,
257
- size_t offset,
257
+ size_t max_rewind,
258
258
  size_t size,
259
259
  unsigned int flags)
260
260
  {
@@ -263,7 +263,7 @@ sd_autolink__url(
263
263
  if (size < 4 || data[1] != '/' || data[2] != '/')
264
264
  return 0;
265
265
 
266
- while (rewind < offset && isalpha(data[-rewind - 1]))
266
+ while (rewind < max_rewind && isalpha(data[-rewind - 1]))
267
267
  rewind++;
268
268
 
269
269
  if (!sd_autolink_issafe(data - rewind, size + rewind))
@@ -283,7 +283,7 @@ sd_autolink__url(
283
283
  while (link_end < size && !isspace(data[link_end]))
284
284
  link_end++;
285
285
 
286
- link_end = autolink_delim(data, link_end, offset, size);
286
+ link_end = autolink_delim(data, link_end, max_rewind, size);
287
287
 
288
288
  if (link_end == 0)
289
289
  return 0;
@@ -501,7 +501,7 @@ parse_emph1(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t size
501
501
  if (data[i] == c && !_isspace(data[i - 1])) {
502
502
 
503
503
  if (rndr->ext_flags & MKDEXT_NO_INTRA_EMPHASIS) {
504
- if (!(i + 1 == size || _isspace(data[i + 1]) || ispunct(data[i + 1])))
504
+ if (i + 1 < size && isalnum(data[i + 1]))
505
505
  continue;
506
506
  }
507
507
 
@@ -596,6 +596,11 @@ char_emphasis(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t of
596
596
  uint8_t c = data[0];
597
597
  size_t ret;
598
598
 
599
+ if (rndr->ext_flags & MKDEXT_NO_INTRA_EMPHASIS) {
600
+ if (offset > 0 && !_isspace(data[-1]) && data[-1] != '>')
601
+ return 0;
602
+ }
603
+
599
604
  if (size > 2 && data[1] != c) {
600
605
  /* whitespace cannot follow an opening emphasis;
601
606
  * strikethrough only takes two characters '~~' */
@@ -1624,7 +1629,7 @@ static size_t
1624
1629
  parse_listitem(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t size, int *flags)
1625
1630
  {
1626
1631
  struct buf *work = 0, *inter = 0;
1627
- size_t beg = 0, end, pre, sublist = 0, orgpre = 0, nestpre = 0, i;
1632
+ size_t beg = 0, end, pre, sublist = 0, orgpre = 0, i;
1628
1633
  int in_empty = 0, has_inside_empty = 0, in_fence = 0;
1629
1634
 
1630
1635
  /* keeping track of the first indentation prefix */
@@ -1672,14 +1677,6 @@ parse_listitem(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t s
1672
1677
  while (i < 4 && beg + i < end && data[beg + i] == ' ')
1673
1678
  i++;
1674
1679
 
1675
- /* handle nested list items */
1676
- if (i > 0) {
1677
- if (nestpre == 0 || nestpre > i)
1678
- nestpre = i;
1679
- else
1680
- i = nestpre;
1681
- }
1682
-
1683
1680
  pre = i;
1684
1681
 
1685
1682
  if (rndr->ext_flags & MKDEXT_FENCED_CODE) {
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  Gem::Specification.new do |s|
3
3
  s.name = 'github-markdown'
4
- s.version = '0.5.1'
4
+ s.version = '0.5.2'
5
5
  s.summary = 'The Markdown parser for GitHub.com'
6
6
  s.description = 'Self-contained Markdown parser for GitHub, with all our custom extensions'
7
7
  s.date = '2012-07-08'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-markdown
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 1
10
- version: 0.5.1
9
+ - 2
10
+ version: 0.5.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - GitHub, Inc
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-07-08 00:00:00 -07:00
18
+ date: 2012-07-08 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency