github-markdown 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,6 +19,10 @@
19
19
 
20
20
  #include "buffer.h"
21
21
 
22
+ #ifdef __cplusplus
23
+ extern "C" {
24
+ #endif
25
+
22
26
  extern int
23
27
  sd_autolink_issafe(const uint8_t *link, size_t link_len);
24
28
 
@@ -31,6 +35,10 @@ sd_autolink__email(size_t *rewind_p, struct buf *link, uint8_t *data, size_t off
31
35
  extern size_t
32
36
  sd_autolink__url(size_t *rewind_p, struct buf *link, uint8_t *data, size_t offset, size_t size);
33
37
 
38
+ #ifdef __cplusplus
39
+ }
40
+ #endif
41
+
34
42
  #endif
35
43
 
36
44
  /* vim: set filetype=c: */
@@ -22,6 +22,10 @@
22
22
  #include <stdarg.h>
23
23
  #include <stdint.h>
24
24
 
25
+ #ifdef __cplusplus
26
+ extern "C" {
27
+ #endif
28
+
25
29
  #if defined(_MSC_VER)
26
30
  #define __attribute__(x)
27
31
  #define inline
@@ -85,4 +89,8 @@ void bufslurp(struct buf *, size_t);
85
89
  /* bufprintf: formatted printing to a buffer */
86
90
  void bufprintf(struct buf *, const char *, ...) __attribute__ ((format (printf, 2, 3)));
87
91
 
92
+ #ifdef __cplusplus
93
+ }
94
+ #endif
95
+
88
96
  #endif
@@ -130,8 +130,9 @@ static const int GITHUB_MD_NESTING = 16;
130
130
  /* Default flags for all Markdown pipelines:
131
131
  *
132
132
  * - NO_INTRA_EMPHASIS: disallow emphasis inside of words
133
- * - LAX_HTML_BLOCKS: do not require an empty line after
134
- * a HTML block, unlike Markdown.pl does
133
+ * - LAX_SPACING: Do spacing like in Markdown 1.0.0 (i.e.
134
+ * do not require an empty line between two different
135
+ * blocks in a paragraph)
135
136
  * - STRIKETHROUGH: strike out words with `~~`, same semantics
136
137
  * as emphasis
137
138
  * - TABLES: the tables extension from PHP-Markdown extra
@@ -140,7 +141,7 @@ static const int GITHUB_MD_NESTING = 16;
140
141
  */
141
142
  static const int GITHUB_MD_FLAGS =
142
143
  MKDEXT_NO_INTRA_EMPHASIS |
143
- MKDEXT_LAX_HTML_BLOCKS |
144
+ MKDEXT_LAX_SPACING |
144
145
  MKDEXT_STRIKETHROUGH |
145
146
  MKDEXT_TABLES |
146
147
  MKDEXT_FENCED_CODE;
@@ -3,6 +3,10 @@
3
3
 
4
4
  #include "buffer.h"
5
5
 
6
+ #ifdef __cplusplus
7
+ extern "C" {
8
+ #endif
9
+
6
10
  #ifdef HOUDINI_USE_LOCALE
7
11
  # define _isxdigit(c) isxdigit(c)
8
12
  # define _isdigit(c) isdigit(c)
@@ -26,4 +30,8 @@ extern void houdini_unescape_url(struct buf *ob, const uint8_t *src, size_t size
26
30
  extern void houdini_escape_js(struct buf *ob, const uint8_t *src, size_t size);
27
31
  extern void houdini_unescape_js(struct buf *ob, const uint8_t *src, size_t size);
28
32
 
33
+ #ifdef __cplusplus
34
+ }
35
+ #endif
36
+
29
37
  #endif
data/ext/markdown/html.h CHANGED
@@ -21,6 +21,10 @@
21
21
  #include "buffer.h"
22
22
  #include <stdlib.h>
23
23
 
24
+ #ifdef __cplusplus
25
+ extern "C" {
26
+ #endif
27
+
24
28
  struct html_renderopt {
25
29
  struct {
26
30
  int header_count;
@@ -65,5 +69,9 @@ sdhtml_toc_renderer(struct sd_callbacks *callbacks, struct html_renderopt *optio
65
69
  extern void
66
70
  sdhtml_smartypants(struct buf *ob, const uint8_t *text, size_t size);
67
71
 
72
+ #ifdef __cplusplus
73
+ }
74
+ #endif
75
+
68
76
  #endif
69
77
 
@@ -1426,18 +1426,38 @@ parse_paragraph(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t
1426
1426
  if ((level = is_headerline(data + i, size - i)) != 0)
1427
1427
  break;
1428
1428
 
1429
- if (rndr->ext_flags & MKDEXT_LAX_HTML_BLOCKS) {
1430
- if (data[i] == '<' && rndr->cb.blockhtml && parse_htmlblock(ob, rndr, data + i, size - i, 0)) {
1429
+ /*
1430
+ * Early termination of a paragraph with the same logic
1431
+ * as Markdown 1.0.0. If this logic is applied, the
1432
+ * Markdown 1.0.3 test suite won't pass cleanly
1433
+ *
1434
+ * :: If the first character in a new line is not a letter,
1435
+ * let's check to see if there's some kind of block starting
1436
+ * here
1437
+ */
1438
+ if ((rndr->ext_flags & MKDEXT_LAX_SPACING) && !isalnum(data[i])) {
1439
+ if (is_atxheader(rndr, data + i, size - i) ||
1440
+ is_hrule(data + i, size - i) ||
1441
+ prefix_quote(data + i, size - i) ||
1442
+ prefix_oli(data + i, size - i) ||
1443
+ prefix_uli(data + i, size - i)) {
1431
1444
  end = i;
1432
1445
  break;
1433
1446
  }
1434
- }
1435
1447
 
1436
- if (is_atxheader(rndr, data + i, size - i) ||
1437
- is_hrule(data + i, size - i) ||
1438
- prefix_quote(data + i, size - i)) {
1439
- end = i;
1440
- break;
1448
+ /* see if an html block starts here */
1449
+ if (data[i] == '<' && rndr->cb.blockhtml &&
1450
+ parse_htmlblock(ob, rndr, data + i, size - i, 0)) {
1451
+ end = i;
1452
+ break;
1453
+ }
1454
+
1455
+ /* see if a code fence starts here */
1456
+ if ((rndr->ext_flags & MKDEXT_FENCED_CODE) != 0 &&
1457
+ is_codefence(data + i, size - i, NULL) != 0) {
1458
+ end = i;
1459
+ break;
1460
+ }
1441
1461
  }
1442
1462
 
1443
1463
  i = end;
@@ -1586,8 +1606,7 @@ parse_listitem(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t s
1586
1606
  {
1587
1607
  struct buf *work = 0, *inter = 0;
1588
1608
  size_t beg = 0, end, pre, sublist = 0, orgpre = 0, i;
1589
- int in_empty = 0, has_inside_empty = 0;
1590
- size_t has_next_uli, has_next_oli;
1609
+ int in_empty = 0, has_inside_empty = 0, in_fence = 0;
1591
1610
 
1592
1611
  /* keeping track of the first indentation prefix */
1593
1612
  while (orgpre < 3 && orgpre < size && data[orgpre] == ' ')
@@ -1615,6 +1634,8 @@ parse_listitem(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t s
1615
1634
 
1616
1635
  /* process the following lines */
1617
1636
  while (beg < size) {
1637
+ size_t has_next_uli = 0, has_next_oli = 0;
1638
+
1618
1639
  end++;
1619
1640
 
1620
1641
  while (end < size && data[end - 1] != '\n')
@@ -1634,8 +1655,17 @@ parse_listitem(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t s
1634
1655
 
1635
1656
  pre = i;
1636
1657
 
1637
- has_next_uli = prefix_uli(data + beg + i, end - beg - i);
1638
- has_next_oli = prefix_oli(data + beg + i, end - beg - i);
1658
+ if (rndr->ext_flags & MKDEXT_FENCED_CODE) {
1659
+ if (is_codefence(data + beg + i, end - beg - i, NULL) != 0)
1660
+ in_fence = !in_fence;
1661
+ }
1662
+
1663
+ /* Only check for new list items if we are **not** inside
1664
+ * a fenced code block */
1665
+ if (!in_fence) {
1666
+ has_next_uli = prefix_uli(data + beg + i, end - beg - i);
1667
+ has_next_oli = prefix_oli(data + beg + i, end - beg - i);
1668
+ }
1639
1669
 
1640
1670
  /* checking for ul/ol switch */
1641
1671
  if (in_empty && (
@@ -1656,10 +1686,12 @@ parse_listitem(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t s
1656
1686
  if (!sublist)
1657
1687
  sublist = work->size;
1658
1688
  }
1659
- /* joining only indented stuff after empty lines */
1660
- else if (in_empty && i < 4) {
1661
- *flags |= MKD_LI_END;
1662
- break;
1689
+ /* joining only indented stuff after empty lines;
1690
+ * note that now we only require 1 space of indentation
1691
+ * to continue a list */
1692
+ else if (in_empty && pre == 0) {
1693
+ *flags |= MKD_LI_END;
1694
+ break;
1663
1695
  }
1664
1696
  else if (in_empty) {
1665
1697
  bufputc(work, '\n');
@@ -1790,13 +1822,8 @@ htmlblock_end_tag(
1790
1822
  i += w;
1791
1823
  w = 0;
1792
1824
 
1793
- if (rndr->ext_flags & MKDEXT_LAX_HTML_BLOCKS) {
1794
- if (i < size)
1795
- w = is_empty(data + i, size - i);
1796
- } else {
1797
- if (i < size && (w = is_empty(data + i, size - i)) == 0)
1798
- return 0; /* non-blank line after tag line */
1799
- }
1825
+ if (i < size)
1826
+ w = is_empty(data + i, size - i);
1800
1827
 
1801
1828
  return i + w;
1802
1829
  }
@@ -2497,9 +2524,9 @@ sd_markdown_free(struct sd_markdown *md)
2497
2524
  void
2498
2525
  sd_version(int *ver_major, int *ver_minor, int *ver_revision)
2499
2526
  {
2500
- *ver_major = UPSKIRT_VER_MAJOR;
2501
- *ver_minor = UPSKIRT_VER_MINOR;
2502
- *ver_revision = UPSKIRT_VER_REVISION;
2527
+ *ver_major = SUNDOWN_VER_MAJOR;
2528
+ *ver_minor = SUNDOWN_VER_MINOR;
2529
+ *ver_revision = SUNDOWN_VER_REVISION;
2503
2530
  }
2504
2531
 
2505
2532
  /* vim: set filetype=c: */
@@ -22,10 +22,14 @@
22
22
  #include "buffer.h"
23
23
  #include "autolink.h"
24
24
 
25
- #define UPSKIRT_VERSION "1.15.2"
26
- #define UPSKIRT_VER_MAJOR 1
27
- #define UPSKIRT_VER_MINOR 15
28
- #define UPSKIRT_VER_REVISION 2
25
+ #ifdef __cplusplus
26
+ extern "C" {
27
+ #endif
28
+
29
+ #define SUNDOWN_VERSION "1.16.0"
30
+ #define SUNDOWN_VER_MAJOR 1
31
+ #define SUNDOWN_VER_MINOR 16
32
+ #define SUNDOWN_VER_REVISION 0
29
33
 
30
34
  /********************
31
35
  * TYPE DEFINITIONS *
@@ -52,9 +56,9 @@ enum mkd_extensions {
52
56
  MKDEXT_FENCED_CODE = (1 << 2),
53
57
  MKDEXT_AUTOLINK = (1 << 3),
54
58
  MKDEXT_STRIKETHROUGH = (1 << 4),
55
- MKDEXT_LAX_HTML_BLOCKS = (1 << 5),
56
59
  MKDEXT_SPACE_HEADERS = (1 << 6),
57
60
  MKDEXT_SUPERSCRIPT = (1 << 7),
61
+ MKDEXT_LAX_SPACING = (1 << 8),
58
62
  };
59
63
 
60
64
  /* sd_callbacks - functions for rendering parsed data */
@@ -125,6 +129,10 @@ sd_markdown_free(struct sd_markdown *md);
125
129
  extern void
126
130
  sd_version(int *major, int *minor, int *revision);
127
131
 
132
+ #ifdef __cplusplus
133
+ }
134
+ #endif
135
+
128
136
  #endif
129
137
 
130
138
  /* vim: set filetype=c: */
data/ext/markdown/stack.h CHANGED
@@ -3,6 +3,10 @@
3
3
 
4
4
  #include <stdlib.h>
5
5
 
6
+ #ifdef __cplusplus
7
+ extern "C" {
8
+ #endif
9
+
6
10
  struct stack {
7
11
  void **item;
8
12
  size_t size;
@@ -18,4 +22,8 @@ int stack_push(struct stack *, void *);
18
22
  void *stack_pop(struct stack *);
19
23
  void *stack_top(struct stack *);
20
24
 
25
+ #ifdef __cplusplus
26
+ }
27
+ #endif
28
+
21
29
  #endif
@@ -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.1.3'
4
+ s.version = '0.2.0'
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: 29
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 3
10
- version: 0.1.3
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - GitHub, Inc