github-markdown 0.3.0 → 0.3.1

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.
@@ -1189,48 +1189,46 @@ prefix_codefence(uint8_t *data, size_t size)
1189
1189
  static size_t
1190
1190
  is_codefence(uint8_t *data, size_t size, struct buf *syntax)
1191
1191
  {
1192
- size_t i = 0;
1192
+ size_t i = 0, syn = 0;
1193
1193
 
1194
1194
  i = prefix_codefence(data, size);
1195
1195
  if (i == 0)
1196
1196
  return 0;
1197
1197
 
1198
- if (syntax != NULL) {
1199
- size_t syn = 0;
1200
-
1201
- while (i < size && data[i] == ' ')
1202
- i++;
1198
+ while (i < size && data[i] == ' ')
1199
+ i++;
1203
1200
 
1201
+ if (syntax)
1204
1202
  syntax->data = data + i;
1205
1203
 
1206
- if (i < size && data[i] == '{') {
1207
- i++; syntax->data++;
1204
+ if (i < size && data[i] == '{') {
1205
+ i++; syntax->data++;
1208
1206
 
1209
- while (i < size && data[i] != '}' && data[i] != '\n') {
1210
- syn++; i++;
1211
- }
1207
+ while (i < size && data[i] != '}' && data[i] != '\n') {
1208
+ syn++; i++;
1209
+ }
1212
1210
 
1213
- if (i == size || data[i] != '}')
1214
- return 0;
1211
+ if (i == size || data[i] != '}')
1212
+ return 0;
1215
1213
 
1216
- /* strip all whitespace at the beginning and the end
1217
- * of the {} block */
1218
- while (syn > 0 && _isspace(syntax->data[0])) {
1219
- syntax->data++; syn--;
1220
- }
1214
+ /* strip all whitespace at the beginning and the end
1215
+ * of the {} block */
1216
+ while (syn > 0 && _isspace(syntax->data[0])) {
1217
+ syntax->data++; syn--;
1218
+ }
1221
1219
 
1222
- while (syn > 0 && _isspace(syntax->data[syn - 1]))
1223
- syn--;
1220
+ while (syn > 0 && _isspace(syntax->data[syn - 1]))
1221
+ syn--;
1224
1222
 
1225
- i++;
1226
- } else {
1227
- while (i < size && !_isspace(data[i])) {
1228
- syn++; i++;
1229
- }
1223
+ i++;
1224
+ } else {
1225
+ while (i < size && !_isspace(data[i])) {
1226
+ syn++; i++;
1230
1227
  }
1228
+ }
1231
1229
 
1230
+ if (syntax)
1232
1231
  syntax->size = syn;
1233
- }
1234
1232
 
1235
1233
  while (i < size && data[i] != '\n') {
1236
1234
  if (!_isspace(data[i]))
@@ -1440,6 +1438,13 @@ parse_paragraph(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t
1440
1438
  if ((level = is_headerline(data + i, size - i)) != 0)
1441
1439
  break;
1442
1440
 
1441
+ if (is_atxheader(rndr, data + i, size - i) ||
1442
+ is_hrule(data + i, size - i) ||
1443
+ prefix_quote(data + i, size - i)) {
1444
+ end = i;
1445
+ break;
1446
+ }
1447
+
1443
1448
  /*
1444
1449
  * Early termination of a paragraph with the same logic
1445
1450
  * as Markdown 1.0.0. If this logic is applied, the
@@ -1450,10 +1455,7 @@ parse_paragraph(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t
1450
1455
  * here
1451
1456
  */
1452
1457
  if ((rndr->ext_flags & MKDEXT_LAX_SPACING) && !isalnum(data[i])) {
1453
- if (is_atxheader(rndr, data + i, size - i) ||
1454
- is_hrule(data + i, size - i) ||
1455
- prefix_quote(data + i, size - i) ||
1456
- prefix_oli(data + i, size - i) ||
1458
+ if (prefix_oli(data + i, size - i) ||
1457
1459
  prefix_uli(data + i, size - i)) {
1458
1460
  end = i;
1459
1461
  break;
@@ -1468,7 +1470,7 @@ parse_paragraph(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t
1468
1470
 
1469
1471
  /* see if a code fence starts here */
1470
1472
  if ((rndr->ext_flags & MKDEXT_FENCED_CODE) != 0 &&
1471
- prefix_codefence(data + i, size - i) != 0) {
1473
+ is_codefence(data + i, size - i, NULL) != 0) {
1472
1474
  end = i;
1473
1475
  break;
1474
1476
  }
@@ -1543,9 +1545,10 @@ parse_fencedcode(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t
1543
1545
 
1544
1546
  while (beg < size) {
1545
1547
  size_t fence_end;
1548
+ struct buf fence_trail = { 0, 0, 0, 0 };
1546
1549
 
1547
- fence_end = is_codefence(data + beg, size - beg, NULL);
1548
- if (fence_end != 0) {
1550
+ fence_end = is_codefence(data + beg, size - beg, &fence_trail);
1551
+ if (fence_end != 0 && fence_trail.size == 0) {
1549
1552
  beg += fence_end;
1550
1553
  break;
1551
1554
  }
@@ -1670,7 +1673,7 @@ parse_listitem(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t s
1670
1673
  pre = i;
1671
1674
 
1672
1675
  if (rndr->ext_flags & MKDEXT_FENCED_CODE) {
1673
- if (prefix_codefence(data + beg + i, end - beg - i) != 0)
1676
+ if (is_codefence(data + beg + i, end - beg - i, NULL) != 0)
1674
1677
  in_fence = !in_fence;
1675
1678
  }
1676
1679
 
@@ -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.3.0'
4
+ s.version = '0.3.1'
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-04-04'
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: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - GitHub, Inc