redcarpet 1.14.2 → 1.15.0
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.
Potentially problematic release.
This version of redcarpet might be problematic. Click here for more details.
- data/README.markdown +4 -2
 - data/ext/redcarpet/array.h +0 -1
 - data/ext/redcarpet/buffer.h +8 -1
 - data/ext/redcarpet/markdown.c +202 -50
 - data/ext/redcarpet/markdown.h +3 -3
 - data/lib/redcarpet.rb +1 -1
 - data/redcarpet.gemspec +3 -2
 - data/test/rails_test.rb +121 -0
 - metadata +5 -4
 
    
        data/README.markdown
    CHANGED
    
    | 
         @@ -40,7 +40,7 @@ markdown = Redcarpet.new("Hello World!") 
     | 
|
| 
       40 
40 
     | 
    
         
             
            puts markdown.to_html
         
     | 
| 
       41 
41 
     | 
    
         
             
            ~~~~~~
         
     | 
| 
       42 
42 
     | 
    
         | 
| 
       43 
     | 
    
         
            -
            Additional processing options can be turned on when creating the
         
     | 
| 
      
 43 
     | 
    
         
            +
            [Additional processing options](http://rdoc.info/github/tanoku/redcarpet/master/Redcarpet#autolink-instance_method) can be turned on when creating the
         
     | 
| 
       44 
44 
     | 
    
         
             
            Redcarpet object:
         
     | 
| 
       45 
45 
     | 
    
         | 
| 
       46 
46 
     | 
    
         
             
            ~~~~~~ {ruby}
         
     | 
| 
         @@ -57,7 +57,9 @@ and behavior as the RDiscount library, which acts as a drop-in replacement. 
     | 
|
| 
       57 
57 
     | 
    
         
             
            License
         
     | 
| 
       58 
58 
     | 
    
         
             
            -------
         
     | 
| 
       59 
59 
     | 
    
         | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
      
 60 
     | 
    
         
            +
            Copyright (c) 2011, Vicent Martí
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
            Permission to use, copy, modify, and/or distribute this software for any
         
     | 
| 
       61 
63 
     | 
    
         
             
            purpose with or without fee is hereby granted, provided that the above
         
     | 
| 
       62 
64 
     | 
    
         
             
            copyright notice and this permission notice appear in all copies.
         
     | 
| 
       63 
65 
     | 
    
         | 
    
        data/ext/redcarpet/array.h
    CHANGED
    
    
    
        data/ext/redcarpet/buffer.h
    CHANGED
    
    | 
         @@ -21,6 +21,13 @@ 
     | 
|
| 
       21 
21 
     | 
    
         | 
| 
       22 
22 
     | 
    
         
             
            #include <stddef.h>
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
      
 24 
     | 
    
         
            +
            #if defined(_MSC_VER)
         
     | 
| 
      
 25 
     | 
    
         
            +
            #define __attribute__(x)
         
     | 
| 
      
 26 
     | 
    
         
            +
            #define inline
         
     | 
| 
      
 27 
     | 
    
         
            +
            #define strncasecmp _strnicmp
         
     | 
| 
      
 28 
     | 
    
         
            +
            #define snprintf _snprintf
         
     | 
| 
      
 29 
     | 
    
         
            +
            #define va_copy(d,s) ((d) = (s))
         
     | 
| 
      
 30 
     | 
    
         
            +
            #endif
         
     | 
| 
       24 
31 
     | 
    
         | 
| 
       25 
32 
     | 
    
         
             
            /********************
         
     | 
| 
       26 
33 
     | 
    
         
             
             * TYPE DEFINITIONS *
         
     | 
| 
         @@ -72,7 +79,7 @@ bufcmp(const struct buf *, const struct buf *); 
     | 
|
| 
       72 
79 
     | 
    
         
             
            int
         
     | 
| 
       73 
80 
     | 
    
         
             
            bufcmps(const struct buf *, const char *);
         
     | 
| 
       74 
81 
     | 
    
         | 
| 
       75 
     | 
    
         
            -
            /* bufprefix * compare the  
     | 
| 
      
 82 
     | 
    
         
            +
            /* bufprefix * compare the beginning of a buffer with a string */
         
     | 
| 
       76 
83 
     | 
    
         
             
            int
         
     | 
| 
       77 
84 
     | 
    
         
             
            bufprefix(const struct buf *buf, const char *prefix);
         
     | 
| 
       78 
85 
     | 
    
         | 
    
        data/ext/redcarpet/markdown.c
    CHANGED
    
    | 
         @@ -22,7 +22,7 @@ 
     | 
|
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         
             
            #include <assert.h>
         
     | 
| 
       24 
24 
     | 
    
         
             
            #include <string.h>
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
      
 25 
     | 
    
         
            +
            //#include <strings.h> /* for strncasecmp */
         
     | 
| 
       26 
26 
     | 
    
         
             
            #include <ctype.h>
         
     | 
| 
       27 
27 
     | 
    
         
             
            #include <stdio.h>
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
         @@ -56,7 +56,9 @@ static size_t char_codespan(struct buf *ob, struct render *rndr, char *data, siz 
     | 
|
| 
       56 
56 
     | 
    
         
             
            static size_t char_escape(struct buf *ob, struct render *rndr, char *data, size_t offset, size_t size);
         
     | 
| 
       57 
57 
     | 
    
         
             
            static size_t char_entity(struct buf *ob, struct render *rndr, char *data, size_t offset, size_t size);
         
     | 
| 
       58 
58 
     | 
    
         
             
            static size_t char_langle_tag(struct buf *ob, struct render *rndr, char *data, size_t offset, size_t size);
         
     | 
| 
       59 
     | 
    
         
            -
            static size_t  
     | 
| 
      
 59 
     | 
    
         
            +
            static size_t char_autolink_url(struct buf *ob, struct render *rndr, char *data, size_t offset, size_t size);
         
     | 
| 
      
 60 
     | 
    
         
            +
            static size_t char_autolink_email(struct buf *ob, struct render *rndr, char *data, size_t offset, size_t size);
         
     | 
| 
      
 61 
     | 
    
         
            +
            static size_t char_autolink_www(struct buf *ob, struct render *rndr, char *data, size_t offset, size_t size);
         
     | 
| 
       60 
62 
     | 
    
         
             
            static size_t char_link(struct buf *ob, struct render *rndr, char *data, size_t offset, size_t size);
         
     | 
| 
       61 
63 
     | 
    
         | 
| 
       62 
64 
     | 
    
         
             
            enum markdown_char_t {
         
     | 
| 
         @@ -68,7 +70,9 @@ enum markdown_char_t { 
     | 
|
| 
       68 
70 
     | 
    
         
             
            	MD_CHAR_LANGLE,
         
     | 
| 
       69 
71 
     | 
    
         
             
            	MD_CHAR_ESCAPE,
         
     | 
| 
       70 
72 
     | 
    
         
             
            	MD_CHAR_ENTITITY,
         
     | 
| 
       71 
     | 
    
         
            -
            	 
     | 
| 
      
 73 
     | 
    
         
            +
            	MD_CHAR_AUTOLINK_URL,
         
     | 
| 
      
 74 
     | 
    
         
            +
            	MD_CHAR_AUTOLINK_EMAIL,
         
     | 
| 
      
 75 
     | 
    
         
            +
            	MD_CHAR_AUTOLINK_WWW
         
     | 
| 
       72 
76 
     | 
    
         
             
            };
         
     | 
| 
       73 
77 
     | 
    
         | 
| 
       74 
78 
     | 
    
         
             
            static char_trigger markdown_char_ptrs[] = {
         
     | 
| 
         @@ -80,7 +84,9 @@ static char_trigger markdown_char_ptrs[] = { 
     | 
|
| 
       80 
84 
     | 
    
         
             
            	&char_langle_tag,
         
     | 
| 
       81 
85 
     | 
    
         
             
            	&char_escape,
         
     | 
| 
       82 
86 
     | 
    
         
             
            	&char_entity,
         
     | 
| 
       83 
     | 
    
         
            -
            	& 
     | 
| 
      
 87 
     | 
    
         
            +
            	&char_autolink_url,
         
     | 
| 
      
 88 
     | 
    
         
            +
            	&char_autolink_email,
         
     | 
| 
      
 89 
     | 
    
         
            +
            	&char_autolink_www,
         
     | 
| 
       84 
90 
     | 
    
         
             
            };
         
     | 
| 
       85 
91 
     | 
    
         | 
| 
       86 
92 
     | 
    
         
             
            /* render • structure containing one particular render */
         
     | 
| 
         @@ -142,12 +148,22 @@ static struct html_tag block_tags[] = { 
     | 
|
| 
       142 
148 
     | 
    
         
             
            /*10*/	{ "del",	3 },
         
     | 
| 
       143 
149 
     | 
    
         
             
            	{ "div",	3 },
         
     | 
| 
       144 
150 
     | 
    
         
             
            /*12*/	{ "ins",	3 },
         
     | 
| 
      
 151 
     | 
    
         
            +
            	{ "nav",	3 },
         
     | 
| 
       145 
152 
     | 
    
         
             
            	{ "pre",	3 },
         
     | 
| 
      
 153 
     | 
    
         
            +
            	{ "abbr",	4 },
         
     | 
| 
       146 
154 
     | 
    
         
             
            	{ "form",	4 },
         
     | 
| 
       147 
155 
     | 
    
         
             
            	{ "math",	4 },
         
     | 
| 
      
 156 
     | 
    
         
            +
            	{ "aside",	5 },
         
     | 
| 
       148 
157 
     | 
    
         
             
            	{ "table",	5 },
         
     | 
| 
      
 158 
     | 
    
         
            +
            	{ "canvas",	6 },
         
     | 
| 
      
 159 
     | 
    
         
            +
            	{ "figure",	6 },
         
     | 
| 
      
 160 
     | 
    
         
            +
            	{ "footer",	6 },
         
     | 
| 
      
 161 
     | 
    
         
            +
            	{ "header",	6 },
         
     | 
| 
      
 162 
     | 
    
         
            +
            	{ "hgroup",	6 },
         
     | 
| 
       149 
163 
     | 
    
         
             
            	{ "iframe",	6 },
         
     | 
| 
       150 
164 
     | 
    
         
             
            	{ "script",	6 },
         
     | 
| 
      
 165 
     | 
    
         
            +
            	{ "article",	7 },
         
     | 
| 
      
 166 
     | 
    
         
            +
            	{ "section",	7 },
         
     | 
| 
       151 
167 
     | 
    
         
             
            	{ "fieldset",	8 },
         
     | 
| 
       152 
168 
     | 
    
         
             
            	{ "noscript",	8 },
         
     | 
| 
       153 
169 
     | 
    
         
             
            	{ "blockquote",	10 }
         
     | 
| 
         @@ -224,7 +240,7 @@ cmp_html_tag(const void *a, const void *b) 
     | 
|
| 
       224 
240 
     | 
    
         
             
            {
         
     | 
| 
       225 
241 
     | 
    
         
             
            	const struct html_tag *hta = a;
         
     | 
| 
       226 
242 
     | 
    
         
             
            	const struct html_tag *htb = b;
         
     | 
| 
       227 
     | 
    
         
            -
            	if (hta->size != htb->size) return (int)( 
     | 
| 
      
 243 
     | 
    
         
            +
            	if (hta->size != htb->size) return (int)(hta->size - htb->size);
         
     | 
| 
       228 
244 
     | 
    
         
             
            	return strncasecmp(hta->text, htb->text, hta->size);
         
     | 
| 
       229 
245 
     | 
    
         
             
            }
         
     | 
| 
       230 
246 
     | 
    
         | 
| 
         @@ -306,7 +322,7 @@ tag_length(char *data, size_t size, enum mkd_autolink *autolink) 
     | 
|
| 
       306 
322 
     | 
    
         
             
            	/* scheme test */
         
     | 
| 
       307 
323 
     | 
    
         
             
            	*autolink = MKDA_NOT_AUTOLINK;
         
     | 
| 
       308 
324 
     | 
    
         | 
| 
       309 
     | 
    
         
            -
            	/* try to find the  
     | 
| 
      
 325 
     | 
    
         
            +
            	/* try to find the beginning of an URI */
         
     | 
| 
       310 
326 
     | 
    
         
             
            	while (i < size && (isalnum(data[i]) || data[i] == '.' || data[i] == '+' || data[i] == '-'))
         
     | 
| 
       311 
327 
     | 
    
         
             
            		i++;
         
     | 
| 
       312 
328 
     | 
    
         | 
| 
         @@ -357,7 +373,7 @@ parse_inline(struct buf *ob, struct render *rndr, char *data, size_t size) 
     | 
|
| 
       357 
373 
     | 
    
         
             
            	struct buf work = { 0, 0, 0, 0, 0 };
         
     | 
| 
       358 
374 
     | 
    
         | 
| 
       359 
375 
     | 
    
         
             
            	if (rndr->work_bufs[BUFFER_SPAN].size +
         
     | 
| 
       360 
     | 
    
         
            -
            		rndr->work_bufs[BUFFER_BLOCK].size > rndr->max_nesting)
         
     | 
| 
      
 376 
     | 
    
         
            +
            		rndr->work_bufs[BUFFER_BLOCK].size > (int)rndr->max_nesting)
         
     | 
| 
       361 
377 
     | 
    
         
             
            		return;
         
     | 
| 
       362 
378 
     | 
    
         | 
| 
       363 
379 
     | 
    
         
             
            	while (i < size) {
         
     | 
| 
         @@ -670,7 +686,7 @@ char_escape(struct buf *ob, struct render *rndr, char *data, size_t offset, size 
     | 
|
| 
       670 
686 
     | 
    
         
             
            }
         
     | 
| 
       671 
687 
     | 
    
         | 
| 
       672 
688 
     | 
    
         
             
            /* char_entity • '&' escaped when it doesn't belong to an entity */
         
     | 
| 
       673 
     | 
    
         
            -
            /* valid entities are assumed to be anything  
     | 
| 
      
 689 
     | 
    
         
            +
            /* valid entities are assumed to be anything matching &#?[A-Za-z0-9]+; */
         
     | 
| 
       674 
690 
     | 
    
         
             
            static size_t
         
     | 
| 
       675 
691 
     | 
    
         
             
            char_entity(struct buf *ob, struct render *rndr, char *data, size_t offset, size_t size)
         
     | 
| 
       676 
692 
     | 
    
         
             
            {
         
     | 
| 
         @@ -725,32 +741,44 @@ char_langle_tag(struct buf *ob, struct render *rndr, char *data, size_t offset, 
     | 
|
| 
       725 
741 
     | 
    
         
             
            }
         
     | 
| 
       726 
742 
     | 
    
         | 
| 
       727 
743 
     | 
    
         
             
            static size_t
         
     | 
| 
       728 
     | 
    
         
            -
             
     | 
| 
      
 744 
     | 
    
         
            +
            autolink_delim(char *data, size_t link_end, size_t offset, size_t size)
         
     | 
| 
       729 
745 
     | 
    
         
             
            {
         
     | 
| 
       730 
     | 
    
         
            -
            	struct buf work = { data, 0, 0, 0, 0 };
         
     | 
| 
       731 
746 
     | 
    
         
             
            	char copen = 0;
         
     | 
| 
       732 
     | 
    
         
            -
            	size_t link_end;
         
     | 
| 
       733 
747 
     | 
    
         | 
| 
       734 
     | 
    
         
            -
            	if  
     | 
| 
       735 
     | 
    
         
            -
             
     | 
| 
       736 
     | 
    
         
            -
             
     | 
| 
      
 748 
     | 
    
         
            +
            	/* See if the link finishes with a punctuation sign that can be skipped. */
         
     | 
| 
      
 749 
     | 
    
         
            +
            	switch (data[link_end - 1]) {
         
     | 
| 
      
 750 
     | 
    
         
            +
            	case '?':
         
     | 
| 
      
 751 
     | 
    
         
            +
            	case '!':
         
     | 
| 
      
 752 
     | 
    
         
            +
            	case '.':
         
     | 
| 
      
 753 
     | 
    
         
            +
            	case ',':
         
     | 
| 
      
 754 
     | 
    
         
            +
            		link_end--;
         
     | 
| 
      
 755 
     | 
    
         
            +
            		break;
         
     | 
| 
      
 756 
     | 
    
         
            +
             
     | 
| 
      
 757 
     | 
    
         
            +
            	case ';':
         
     | 
| 
      
 758 
     | 
    
         
            +
            	{
         
     | 
| 
      
 759 
     | 
    
         
            +
            		size_t new_end = link_end - 2;
         
     | 
| 
      
 760 
     | 
    
         
            +
             
     | 
| 
      
 761 
     | 
    
         
            +
            		while (new_end > 0 && isalpha(data[new_end]))
         
     | 
| 
      
 762 
     | 
    
         
            +
            			new_end--;
         
     | 
| 
      
 763 
     | 
    
         
            +
             
     | 
| 
      
 764 
     | 
    
         
            +
            		if (new_end < link_end - 2 && data[new_end] == '&')
         
     | 
| 
      
 765 
     | 
    
         
            +
            			link_end = new_end;
         
     | 
| 
      
 766 
     | 
    
         
            +
            		else
         
     | 
| 
      
 767 
     | 
    
         
            +
            			link_end--;
         
     | 
| 
      
 768 
     | 
    
         
            +
             
     | 
| 
      
 769 
     | 
    
         
            +
            		break;
         
     | 
| 
       737 
770 
     | 
    
         
             
            	}
         
     | 
| 
       738 
771 
     | 
    
         | 
| 
       739 
     | 
    
         
            -
            	 
     | 
| 
       740 
     | 
    
         
            -
            		 
     | 
| 
      
 772 
     | 
    
         
            +
            	case '>':
         
     | 
| 
      
 773 
     | 
    
         
            +
            		while (link_end > 0 && data[link_end] != '<')
         
     | 
| 
      
 774 
     | 
    
         
            +
            			link_end--;
         
     | 
| 
       741 
775 
     | 
    
         | 
| 
       742 
     | 
    
         
            -
             
     | 
| 
       743 
     | 
    
         
            -
             
     | 
| 
       744 
     | 
    
         
            -
            		link_end++;
         
     | 
| 
      
 776 
     | 
    
         
            +
            		if (link_end == 0)
         
     | 
| 
      
 777 
     | 
    
         
            +
            			return 0;
         
     | 
| 
       745 
778 
     | 
    
         | 
| 
       746 
     | 
    
         
            -
             
     | 
| 
       747 
     | 
    
         
            -
            	 
     | 
| 
       748 
     | 
    
         
            -
            		data[link_end - 1] == ',' ||
         
     | 
| 
       749 
     | 
    
         
            -
            		data[link_end - 1] == ';') &&
         
     | 
| 
       750 
     | 
    
         
            -
            		data[link_end - 2] != '\\')
         
     | 
| 
       751 
     | 
    
         
            -
            		link_end--;
         
     | 
| 
      
 779 
     | 
    
         
            +
            		break;
         
     | 
| 
      
 780 
     | 
    
         
            +
            	}
         
     | 
| 
       752 
781 
     | 
    
         | 
| 
       753 
     | 
    
         
            -
            	/* See if the link finishes with a punctuation sign that can be closed. */
         
     | 
| 
       754 
782 
     | 
    
         
             
            	switch (data[link_end - 1]) {
         
     | 
| 
       755 
783 
     | 
    
         
             
            	case '"':	copen = '"'; break;
         
     | 
| 
       756 
784 
     | 
    
         
             
            	case '\'':	copen = '\''; break;
         
     | 
| 
         @@ -762,8 +790,7 @@ char_autolink(struct buf *ob, struct render *rndr, char *data, size_t offset, si 
     | 
|
| 
       762 
790 
     | 
    
         
             
            	if (copen != 0) {
         
     | 
| 
       763 
791 
     | 
    
         
             
            		char *buf_start = data - offset;
         
     | 
| 
       764 
792 
     | 
    
         
             
            		char *buf_end = data + link_end - 2;
         
     | 
| 
       765 
     | 
    
         
            -
             
     | 
| 
       766 
     | 
    
         
            -
            		size_t open_delim = 1;
         
     | 
| 
      
 793 
     | 
    
         
            +
            		char *open_delim = NULL;
         
     | 
| 
       767 
794 
     | 
    
         | 
| 
       768 
795 
     | 
    
         
             
            		/* Try to close the final punctuation sign in this same line;
         
     | 
| 
       769 
796 
     | 
    
         
             
            		 * if we managed to close it outside of the URL, that means that it's
         
     | 
| 
         @@ -785,31 +812,161 @@ char_autolink(struct buf *ob, struct render *rndr, char *data, size_t offset, si 
     | 
|
| 
       785 
812 
     | 
    
         
             
            		 *		=> foo http://www.pokemon.com/Pikachu_(Electric)
         
     | 
| 
       786 
813 
     | 
    
         
             
            		 */
         
     | 
| 
       787 
814 
     | 
    
         | 
| 
       788 
     | 
    
         
            -
            		while (buf_end >= buf_start && *buf_end != '\n' 
     | 
| 
       789 
     | 
    
         
            -
            			if (*buf_end == data[link_end - 1])
         
     | 
| 
       790 
     | 
    
         
            -
            				open_delim++;
         
     | 
| 
       791 
     | 
    
         
            -
             
     | 
| 
      
 815 
     | 
    
         
            +
            		while (buf_end >= buf_start && *buf_end != '\n') {
         
     | 
| 
       792 
816 
     | 
    
         
             
            			if (*buf_end == copen)
         
     | 
| 
       793 
     | 
    
         
            -
            				open_delim 
     | 
| 
      
 817 
     | 
    
         
            +
            				open_delim = buf_end;
         
     | 
| 
       794 
818 
     | 
    
         | 
| 
       795 
819 
     | 
    
         
             
            			buf_end--;
         
     | 
| 
       796 
820 
     | 
    
         
             
            		}
         
     | 
| 
       797 
821 
     | 
    
         | 
| 
       798 
     | 
    
         
            -
            		if (open_delim  
     | 
| 
      
 822 
     | 
    
         
            +
            		if (open_delim != NULL && open_delim < data)
         
     | 
| 
       799 
823 
     | 
    
         
             
            			link_end--;
         
     | 
| 
       800 
824 
     | 
    
         
             
            	}
         
     | 
| 
       801 
825 
     | 
    
         | 
| 
      
 826 
     | 
    
         
            +
            	return link_end;
         
     | 
| 
      
 827 
     | 
    
         
            +
            }
         
     | 
| 
      
 828 
     | 
    
         
            +
             
     | 
| 
      
 829 
     | 
    
         
            +
             
     | 
| 
      
 830 
     | 
    
         
            +
            static size_t
         
     | 
| 
      
 831 
     | 
    
         
            +
            char_autolink_www(struct buf *ob, struct render *rndr, char *data, size_t offset, size_t size)
         
     | 
| 
      
 832 
     | 
    
         
            +
            {
         
     | 
| 
      
 833 
     | 
    
         
            +
            	struct buf work = { 0, 0, 0, 0, 0 };
         
     | 
| 
      
 834 
     | 
    
         
            +
            	size_t link_end;
         
     | 
| 
      
 835 
     | 
    
         
            +
            	int np = 0;
         
     | 
| 
      
 836 
     | 
    
         
            +
             
     | 
| 
      
 837 
     | 
    
         
            +
            	if (offset > 0 && !ispunct(data[-1]) && !isspace(data[-1]))
         
     | 
| 
      
 838 
     | 
    
         
            +
            		return 0;
         
     | 
| 
      
 839 
     | 
    
         
            +
             
     | 
| 
      
 840 
     | 
    
         
            +
            	if (size < 4 || memcmp(data, "www.", STRLEN("www.")) != 0)
         
     | 
| 
      
 841 
     | 
    
         
            +
            		return 0;
         
     | 
| 
      
 842 
     | 
    
         
            +
             
     | 
| 
      
 843 
     | 
    
         
            +
            	link_end = 0;
         
     | 
| 
      
 844 
     | 
    
         
            +
            	while (link_end < size && !isspace(data[link_end])) {
         
     | 
| 
      
 845 
     | 
    
         
            +
            		if (data[link_end] == '.')
         
     | 
| 
      
 846 
     | 
    
         
            +
            			np++;
         
     | 
| 
      
 847 
     | 
    
         
            +
             
     | 
| 
      
 848 
     | 
    
         
            +
            		link_end++;
         
     | 
| 
      
 849 
     | 
    
         
            +
            	}
         
     | 
| 
      
 850 
     | 
    
         
            +
             
     | 
| 
      
 851 
     | 
    
         
            +
            	if (np < 2)
         
     | 
| 
      
 852 
     | 
    
         
            +
            		return 0;
         
     | 
| 
      
 853 
     | 
    
         
            +
             
     | 
| 
      
 854 
     | 
    
         
            +
            	link_end = autolink_delim(data, link_end, offset, size);
         
     | 
| 
      
 855 
     | 
    
         
            +
             
     | 
| 
      
 856 
     | 
    
         
            +
            	if (link_end == 0)
         
     | 
| 
      
 857 
     | 
    
         
            +
            		return 0;
         
     | 
| 
      
 858 
     | 
    
         
            +
             
     | 
| 
       802 
859 
     | 
    
         
             
            	work.size = link_end;
         
     | 
| 
      
 860 
     | 
    
         
            +
            	work.data = data;
         
     | 
| 
      
 861 
     | 
    
         
            +
             
     | 
| 
      
 862 
     | 
    
         
            +
            	if (rndr->make.link) {
         
     | 
| 
      
 863 
     | 
    
         
            +
            		struct buf *u_link = rndr_newbuf(rndr, BUFFER_SPAN);
         
     | 
| 
      
 864 
     | 
    
         
            +
            		BUFPUTSL(u_link, "http://");
         
     | 
| 
      
 865 
     | 
    
         
            +
            		unscape_text(u_link, &work);
         
     | 
| 
      
 866 
     | 
    
         
            +
             
     | 
| 
      
 867 
     | 
    
         
            +
            		rndr->make.link(ob, u_link, NULL, &work, rndr->make.opaque);
         
     | 
| 
      
 868 
     | 
    
         
            +
            		rndr_popbuf(rndr, BUFFER_SPAN);
         
     | 
| 
      
 869 
     | 
    
         
            +
            	}
         
     | 
| 
      
 870 
     | 
    
         
            +
             
     | 
| 
      
 871 
     | 
    
         
            +
            	return link_end;
         
     | 
| 
      
 872 
     | 
    
         
            +
            }
         
     | 
| 
      
 873 
     | 
    
         
            +
             
     | 
| 
      
 874 
     | 
    
         
            +
            static size_t
         
     | 
| 
      
 875 
     | 
    
         
            +
            char_autolink_email(struct buf *ob, struct render *rndr, char *data, size_t offset, size_t size)
         
     | 
| 
      
 876 
     | 
    
         
            +
            {
         
     | 
| 
      
 877 
     | 
    
         
            +
            	struct buf work = { 0, 0, 0, 0, 0 };
         
     | 
| 
      
 878 
     | 
    
         
            +
            	size_t link_end, rewind;
         
     | 
| 
      
 879 
     | 
    
         
            +
            	int nb = 0, np = 0;
         
     | 
| 
      
 880 
     | 
    
         
            +
             
     | 
| 
      
 881 
     | 
    
         
            +
            	for (rewind = 0; rewind < offset; ++rewind) {
         
     | 
| 
      
 882 
     | 
    
         
            +
            		char c = data[-rewind - 1];
         
     | 
| 
      
 883 
     | 
    
         
            +
             
     | 
| 
      
 884 
     | 
    
         
            +
            		if (isalnum(c))
         
     | 
| 
      
 885 
     | 
    
         
            +
            			continue;
         
     | 
| 
      
 886 
     | 
    
         
            +
             
     | 
| 
      
 887 
     | 
    
         
            +
            		if (strchr(".!#$%&*+-/=?^_`|~", c) != NULL)
         
     | 
| 
      
 888 
     | 
    
         
            +
            			continue;
         
     | 
| 
      
 889 
     | 
    
         
            +
             
     | 
| 
      
 890 
     | 
    
         
            +
            		break;
         
     | 
| 
      
 891 
     | 
    
         
            +
            	}
         
     | 
| 
      
 892 
     | 
    
         
            +
             
     | 
| 
      
 893 
     | 
    
         
            +
            	if (rewind == 0)
         
     | 
| 
      
 894 
     | 
    
         
            +
            		return 0;
         
     | 
| 
      
 895 
     | 
    
         
            +
             
     | 
| 
      
 896 
     | 
    
         
            +
            	for (link_end = 0; link_end < size; ++link_end) {
         
     | 
| 
      
 897 
     | 
    
         
            +
            		char c = data[link_end];
         
     | 
| 
      
 898 
     | 
    
         
            +
             
     | 
| 
      
 899 
     | 
    
         
            +
            		if (isalnum(c))
         
     | 
| 
      
 900 
     | 
    
         
            +
            			continue;
         
     | 
| 
      
 901 
     | 
    
         
            +
             
     | 
| 
      
 902 
     | 
    
         
            +
            		if (c == '@')
         
     | 
| 
      
 903 
     | 
    
         
            +
            			nb++;
         
     | 
| 
      
 904 
     | 
    
         
            +
            		else if (c == '.')
         
     | 
| 
      
 905 
     | 
    
         
            +
            			np++;
         
     | 
| 
      
 906 
     | 
    
         
            +
            		else if (c != '-' && c != '_')
         
     | 
| 
      
 907 
     | 
    
         
            +
            			break;
         
     | 
| 
      
 908 
     | 
    
         
            +
            	}
         
     | 
| 
      
 909 
     | 
    
         
            +
             
     | 
| 
      
 910 
     | 
    
         
            +
            	if (link_end < 2 || nb != 1 || np == 0)
         
     | 
| 
      
 911 
     | 
    
         
            +
            		return 0;
         
     | 
| 
      
 912 
     | 
    
         
            +
             
     | 
| 
      
 913 
     | 
    
         
            +
            	link_end = autolink_delim(data, link_end, offset, size);
         
     | 
| 
      
 914 
     | 
    
         
            +
             
     | 
| 
      
 915 
     | 
    
         
            +
            	if (link_end == 0)
         
     | 
| 
      
 916 
     | 
    
         
            +
            		return 0;
         
     | 
| 
      
 917 
     | 
    
         
            +
             
     | 
| 
      
 918 
     | 
    
         
            +
            	work.size = link_end + rewind;
         
     | 
| 
      
 919 
     | 
    
         
            +
            	work.data = data - rewind;
         
     | 
| 
      
 920 
     | 
    
         
            +
             
     | 
| 
      
 921 
     | 
    
         
            +
            	if (rndr->make.autolink) {
         
     | 
| 
      
 922 
     | 
    
         
            +
            		struct buf *u_link = rndr_newbuf(rndr, BUFFER_SPAN);
         
     | 
| 
      
 923 
     | 
    
         
            +
            		unscape_text(u_link, &work);
         
     | 
| 
      
 924 
     | 
    
         
            +
             
     | 
| 
      
 925 
     | 
    
         
            +
            		ob->size -= rewind;
         
     | 
| 
      
 926 
     | 
    
         
            +
            		rndr->make.autolink(ob, u_link, MKDA_EMAIL, rndr->make.opaque);
         
     | 
| 
      
 927 
     | 
    
         
            +
            		rndr_popbuf(rndr, BUFFER_SPAN);
         
     | 
| 
      
 928 
     | 
    
         
            +
            	}
         
     | 
| 
      
 929 
     | 
    
         
            +
             
     | 
| 
      
 930 
     | 
    
         
            +
            	return link_end;
         
     | 
| 
      
 931 
     | 
    
         
            +
            }
         
     | 
| 
      
 932 
     | 
    
         
            +
             
     | 
| 
      
 933 
     | 
    
         
            +
            static size_t
         
     | 
| 
      
 934 
     | 
    
         
            +
            char_autolink_url(struct buf *ob, struct render *rndr, char *data, size_t offset, size_t size)
         
     | 
| 
      
 935 
     | 
    
         
            +
            {
         
     | 
| 
      
 936 
     | 
    
         
            +
            	struct buf work = { 0, 0, 0, 0, 0 };
         
     | 
| 
      
 937 
     | 
    
         
            +
            	size_t link_end, rewind = 0;
         
     | 
| 
      
 938 
     | 
    
         
            +
             
     | 
| 
      
 939 
     | 
    
         
            +
            	if (size < 4 || data[1] != '/' || data[2] != '/')
         
     | 
| 
      
 940 
     | 
    
         
            +
            		return 0;
         
     | 
| 
      
 941 
     | 
    
         
            +
             
     | 
| 
      
 942 
     | 
    
         
            +
            	while (rewind < offset && isalpha(data[-rewind - 1]))
         
     | 
| 
      
 943 
     | 
    
         
            +
            		rewind++;
         
     | 
| 
      
 944 
     | 
    
         
            +
             
     | 
| 
      
 945 
     | 
    
         
            +
            	if (!is_safe_link(data - rewind, size + rewind))
         
     | 
| 
      
 946 
     | 
    
         
            +
            		return 0;
         
     | 
| 
      
 947 
     | 
    
         
            +
             
     | 
| 
      
 948 
     | 
    
         
            +
            	link_end = 0;
         
     | 
| 
      
 949 
     | 
    
         
            +
            	while (link_end < size && !isspace(data[link_end]))
         
     | 
| 
      
 950 
     | 
    
         
            +
            		link_end++;
         
     | 
| 
      
 951 
     | 
    
         
            +
             
     | 
| 
      
 952 
     | 
    
         
            +
            	link_end = autolink_delim(data, link_end, offset, size);
         
     | 
| 
      
 953 
     | 
    
         
            +
             
     | 
| 
      
 954 
     | 
    
         
            +
            	if (link_end == 0)
         
     | 
| 
      
 955 
     | 
    
         
            +
            		return 0;
         
     | 
| 
      
 956 
     | 
    
         
            +
             
     | 
| 
      
 957 
     | 
    
         
            +
            	work.size = link_end + rewind;
         
     | 
| 
      
 958 
     | 
    
         
            +
            	work.data = data - rewind;
         
     | 
| 
       803 
959 
     | 
    
         | 
| 
       804 
960 
     | 
    
         
             
            	if (rndr->make.autolink) {
         
     | 
| 
       805 
961 
     | 
    
         
             
            		struct buf *u_link = rndr_newbuf(rndr, BUFFER_SPAN);
         
     | 
| 
       806 
962 
     | 
    
         
             
            		unscape_text(u_link, &work);
         
     | 
| 
       807 
963 
     | 
    
         | 
| 
      
 964 
     | 
    
         
            +
            		ob->size -= rewind;
         
     | 
| 
       808 
965 
     | 
    
         
             
            		rndr->make.autolink(ob, u_link, MKDA_NORMAL, rndr->make.opaque);
         
     | 
| 
       809 
966 
     | 
    
         
             
            		rndr_popbuf(rndr, BUFFER_SPAN);
         
     | 
| 
       810 
967 
     | 
    
         
             
            	}
         
     | 
| 
       811 
968 
     | 
    
         | 
| 
       812 
     | 
    
         
            -
            	return  
     | 
| 
      
 969 
     | 
    
         
            +
            	return link_end;
         
     | 
| 
       813 
970 
     | 
    
         
             
            }
         
     | 
| 
       814 
971 
     | 
    
         | 
| 
       815 
972 
     | 
    
         
             
            /* char_link • '[': parsing a link or an image */
         
     | 
| 
         @@ -1124,7 +1281,7 @@ is_codefence(char *data, size_t size, struct buf *syntax) 
     | 
|
| 
       1124 
1281 
     | 
    
         
             
            			if (i == size || data[i] != '}')
         
     | 
| 
       1125 
1282 
     | 
    
         
             
            				return 0;
         
     | 
| 
       1126 
1283 
     | 
    
         | 
| 
       1127 
     | 
    
         
            -
            			/* strip all whitespace at the  
     | 
| 
      
 1284 
     | 
    
         
            +
            			/* strip all whitespace at the beginning and the end
         
     | 
| 
       1128 
1285 
     | 
    
         
             
            			 * of the {} block */
         
     | 
| 
       1129 
1286 
     | 
    
         
             
            			while (syn > 0 && isspace(syntax->data[0])) {
         
     | 
| 
       1130 
1287 
     | 
    
         
             
            				syntax->data++; syn--;
         
     | 
| 
         @@ -1255,7 +1412,7 @@ static void parse_block(struct buf *ob, struct render *rndr, 
     | 
|
| 
       1255 
1412 
     | 
    
         
             
            			char *data, size_t size);
         
     | 
| 
       1256 
1413 
     | 
    
         | 
| 
       1257 
1414 
     | 
    
         | 
| 
       1258 
     | 
    
         
            -
            /* parse_blockquote •  
     | 
| 
      
 1415 
     | 
    
         
            +
            /* parse_blockquote • handles parsing of a blockquote fragment */
         
     | 
| 
       1259 
1416 
     | 
    
         
             
            static size_t
         
     | 
| 
       1260 
1417 
     | 
    
         
             
            parse_blockquote(struct buf *ob, struct render *rndr, char *data, size_t size)
         
     | 
| 
       1261 
1418 
     | 
    
         
             
            {
         
     | 
| 
         @@ -1300,7 +1457,7 @@ parse_blockquote(struct buf *ob, struct render *rndr, char *data, size_t size) 
     | 
|
| 
       1300 
1457 
     | 
    
         
             
            static size_t
         
     | 
| 
       1301 
1458 
     | 
    
         
             
            parse_htmlblock(struct buf *ob, struct render *rndr, char *data, size_t size, int do_render);
         
     | 
| 
       1302 
1459 
     | 
    
         | 
| 
       1303 
     | 
    
         
            -
            /* parse_blockquote •  
     | 
| 
      
 1460 
     | 
    
         
            +
            /* parse_blockquote • handles parsing of a regular paragraph */
         
     | 
| 
       1304 
1461 
     | 
    
         
             
            static size_t
         
     | 
| 
       1305 
1462 
     | 
    
         
             
            parse_paragraph(struct buf *ob, struct render *rndr, char *data, size_t size)
         
     | 
| 
       1306 
1463 
     | 
    
         
             
            {
         
     | 
| 
         @@ -1380,7 +1537,7 @@ parse_paragraph(struct buf *ob, struct render *rndr, char *data, size_t size) 
     | 
|
| 
       1380 
1537 
     | 
    
         
             
            	return end;
         
     | 
| 
       1381 
1538 
     | 
    
         
             
            }
         
     | 
| 
       1382 
1539 
     | 
    
         | 
| 
       1383 
     | 
    
         
            -
            /* parse_fencedcode •  
     | 
| 
      
 1540 
     | 
    
         
            +
            /* parse_fencedcode • handles parsing of a block-level code fragment */
         
     | 
| 
       1384 
1541 
     | 
    
         
             
            static size_t
         
     | 
| 
       1385 
1542 
     | 
    
         
             
            parse_fencedcode(struct buf *ob, struct render *rndr, char *data, size_t size)
         
     | 
| 
       1386 
1543 
     | 
    
         
             
            {
         
     | 
| 
         @@ -1474,7 +1631,7 @@ parse_listitem(struct buf *ob, struct render *rndr, char *data, size_t size, int 
     | 
|
| 
       1474 
1631 
     | 
    
         
             
            	size_t beg = 0, end, pre, sublist = 0, orgpre = 0, i;
         
     | 
| 
       1475 
1632 
     | 
    
         
             
            	int in_empty = 0, has_inside_empty = 0;
         
     | 
| 
       1476 
1633 
     | 
    
         | 
| 
       1477 
     | 
    
         
            -
            	/* keeping  
     | 
| 
      
 1634 
     | 
    
         
            +
            	/* keeping track of the first indentation prefix */
         
     | 
| 
       1478 
1635 
     | 
    
         
             
            	while (orgpre < 3 && orgpre < size && data[orgpre] == ' ')
         
     | 
| 
       1479 
1636 
     | 
    
         
             
            		orgpre++;
         
     | 
| 
       1480 
1637 
     | 
    
         | 
| 
         @@ -1650,7 +1807,7 @@ htmlblock_end(struct html_tag *tag, struct render *rndr, char *data, size_t size 
     | 
|
| 
       1650 
1807 
     | 
    
         | 
| 
       1651 
1808 
     | 
    
         
             
            	/* assuming data[0] == '<' && data[1] == '/' already tested */
         
     | 
| 
       1652 
1809 
     | 
    
         | 
| 
       1653 
     | 
    
         
            -
            	/* checking tag is a match */
         
     | 
| 
      
 1810 
     | 
    
         
            +
            	/* checking if tag is a match */
         
     | 
| 
       1654 
1811 
     | 
    
         
             
            	if (tag->size + 3 >= size
         
     | 
| 
       1655 
1812 
     | 
    
         
             
            	|| strncasecmp(data + 2, tag->text, tag->size)
         
     | 
| 
       1656 
1813 
     | 
    
         
             
            	|| data[tag->size + 2] != '>')
         
     | 
| 
         @@ -1949,7 +2106,7 @@ parse_block(struct buf *ob, struct render *rndr, char *data, size_t size) 
     | 
|
| 
       1949 
2106 
     | 
    
         
             
            	beg = 0;
         
     | 
| 
       1950 
2107 
     | 
    
         | 
| 
       1951 
2108 
     | 
    
         
             
            	if (rndr->work_bufs[BUFFER_SPAN].size +
         
     | 
| 
       1952 
     | 
    
         
            -
            		rndr->work_bufs[BUFFER_BLOCK].size > rndr->max_nesting)
         
     | 
| 
      
 2109 
     | 
    
         
            +
            		rndr->work_bufs[BUFFER_BLOCK].size > (int)rndr->max_nesting)
         
     | 
| 
       1953 
2110 
     | 
    
         
             
            		return;
         
     | 
| 
       1954 
2111 
     | 
    
         | 
| 
       1955 
2112 
     | 
    
         
             
            	while (beg < size) {
         
     | 
| 
         @@ -2187,14 +2344,9 @@ ups_markdown(struct buf *ob, struct buf *ib, const struct mkd_renderer *rndrer, 
     | 
|
| 
       2187 
2344 
     | 
    
         
             
            	rndr.active_char['&'] = MD_CHAR_ENTITITY;
         
     | 
| 
       2188 
2345 
     | 
    
         | 
| 
       2189 
2346 
     | 
    
         
             
            	if (extensions & MKDEXT_AUTOLINK) {
         
     | 
| 
       2190 
     | 
    
         
            -
            		rndr.active_char[' 
     | 
| 
       2191 
     | 
    
         
            -
            		rndr.active_char[' 
     | 
| 
       2192 
     | 
    
         
            -
             
     | 
| 
       2193 
     | 
    
         
            -
            		rndr.active_char['f'] = MD_CHAR_AUTOLINK; // ftp
         
     | 
| 
       2194 
     | 
    
         
            -
            		rndr.active_char['F'] = MD_CHAR_AUTOLINK;
         
     | 
| 
       2195 
     | 
    
         
            -
             
     | 
| 
       2196 
     | 
    
         
            -
            		rndr.active_char['m'] = MD_CHAR_AUTOLINK; // mailto
         
     | 
| 
       2197 
     | 
    
         
            -
            		rndr.active_char['M'] = MD_CHAR_AUTOLINK;
         
     | 
| 
      
 2347 
     | 
    
         
            +
            		rndr.active_char[':'] = MD_CHAR_AUTOLINK_URL;
         
     | 
| 
      
 2348 
     | 
    
         
            +
            		rndr.active_char['@'] = MD_CHAR_AUTOLINK_EMAIL;
         
     | 
| 
      
 2349 
     | 
    
         
            +
            		rndr.active_char['w'] = MD_CHAR_AUTOLINK_WWW;
         
     | 
| 
       2198 
2350 
     | 
    
         
             
            	}
         
     | 
| 
       2199 
2351 
     | 
    
         | 
| 
       2200 
2352 
     | 
    
         
             
            	/* Extension data */
         
     | 
    
        data/ext/redcarpet/markdown.h
    CHANGED
    
    | 
         @@ -21,10 +21,10 @@ 
     | 
|
| 
       21 
21 
     | 
    
         | 
| 
       22 
22 
     | 
    
         
             
            #include "buffer.h"
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
            #define UPSKIRT_VERSION "1. 
     | 
| 
      
 24 
     | 
    
         
            +
            #define UPSKIRT_VERSION "1.15.0"
         
     | 
| 
       25 
25 
     | 
    
         
             
            #define UPSKIRT_VER_MAJOR 1
         
     | 
| 
       26 
     | 
    
         
            -
            #define UPSKIRT_VER_MINOR  
     | 
| 
       27 
     | 
    
         
            -
            #define UPSKIRT_VER_REVISION  
     | 
| 
      
 26 
     | 
    
         
            +
            #define UPSKIRT_VER_MINOR 15
         
     | 
| 
      
 27 
     | 
    
         
            +
            #define UPSKIRT_VER_REVISION 0
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
29 
     | 
    
         
             
            /********************
         
     | 
| 
       30 
30 
     | 
    
         
             
             * TYPE DEFINITIONS *
         
     | 
    
        data/lib/redcarpet.rb
    CHANGED
    
    
    
        data/redcarpet.gemspec
    CHANGED
    
    | 
         @@ -1,9 +1,9 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       2 
2 
     | 
    
         
             
              s.name = 'redcarpet'
         
     | 
| 
       3 
     | 
    
         
            -
              s.version = '1. 
     | 
| 
      
 3 
     | 
    
         
            +
              s.version = '1.15.0'
         
     | 
| 
       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- 
     | 
| 
      
 6 
     | 
    
         
            +
              s.date = '2011-06-02'
         
     | 
| 
       7 
7 
     | 
    
         
             
              s.email = 'vicent@github.com'
         
     | 
| 
       8 
8 
     | 
    
         
             
              s.homepage = 'http://github.com/tanoku/redcarpet'
         
     | 
| 
       9 
9 
     | 
    
         
             
              s.authors = ["Natacha Porté", "Vicent Martí"]
         
     | 
| 
         @@ -30,6 +30,7 @@ Gem::Specification.new do |s| 
     | 
|
| 
       30 
30 
     | 
    
         
             
                test/benchmark.rb
         
     | 
| 
       31 
31 
     | 
    
         
             
                test/benchmark.txt
         
     | 
| 
       32 
32 
     | 
    
         
             
                test/markdown_test.rb
         
     | 
| 
      
 33 
     | 
    
         
            +
                test/rails_test.rb
         
     | 
| 
       33 
34 
     | 
    
         
             
                test/redcarpet_test.rb
         
     | 
| 
       34 
35 
     | 
    
         
             
                upskirt
         
     | 
| 
       35 
36 
     | 
    
         
             
              ]
         
     | 
    
        data/test/rails_test.rb
    ADDED
    
    | 
         @@ -0,0 +1,121 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # encoding: utf-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            rootdir = File.dirname(File.dirname(__FILE__))
         
     | 
| 
      
 3 
     | 
    
         
            +
            $LOAD_PATH.unshift "#{rootdir}/lib"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            require 'test/unit'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'cgi'
         
     | 
| 
      
 7 
     | 
    
         
            +
            require 'redcarpet'
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            class RedcarpetRailsTest < Test::Unit::TestCase
         
     | 
| 
      
 10 
     | 
    
         
            +
              def assert_linked(expected, url)
         
     | 
| 
      
 11 
     | 
    
         
            +
                assert_equal "<p>#{expected}</p>", Redcarpet.new(url, :autolink).to_html.strip
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              def test_auto_link_works
         
     | 
| 
      
 15 
     | 
    
         
            +
                url = "http://example.com/"
         
     | 
| 
      
 16 
     | 
    
         
            +
                assert_linked "<a href=\"#{url}\">#{url}</a>", url
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              def test_does_not_autolink_www
         
     | 
| 
      
 20 
     | 
    
         
            +
                assert_linked "Awww... man", "Awww... man"
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              def test_does_not_terminate_on_dash
         
     | 
| 
      
 24 
     | 
    
         
            +
                url = "http://example.com/Notification_Center-GitHub-20101108-140050.jpg"
         
     | 
| 
      
 25 
     | 
    
         
            +
                assert_linked "<a href=\"#{url}\">#{url}</a>", url
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              def test_does_not_include_gt
         
     | 
| 
      
 29 
     | 
    
         
            +
                url = "http://example.com/"
         
     | 
| 
      
 30 
     | 
    
         
            +
                assert_linked "<<a href=\"#{url}\">#{url}</a>>", "<#{url}>"
         
     | 
| 
      
 31 
     | 
    
         
            +
              end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
              def test_links_with_anchors
         
     | 
| 
      
 34 
     | 
    
         
            +
                url = "https://github.com/github/hubot/blob/master/scripts/cream.js#L20-20"
         
     | 
| 
      
 35 
     | 
    
         
            +
                assert_linked "<a href=\"#{url}\">#{url}</a>", url
         
     | 
| 
      
 36 
     | 
    
         
            +
              end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
              def test_links_like_rails
         
     | 
| 
      
 39 
     | 
    
         
            +
                urls = %w(http://www.rubyonrails.com
         
     | 
| 
      
 40 
     | 
    
         
            +
                          http://www.rubyonrails.com:80
         
     | 
| 
      
 41 
     | 
    
         
            +
                          http://www.rubyonrails.com/~minam
         
     | 
| 
      
 42 
     | 
    
         
            +
                          https://www.rubyonrails.com/~minam
         
     | 
| 
      
 43 
     | 
    
         
            +
                          http://www.rubyonrails.com/~minam/url%20with%20spaces
         
     | 
| 
      
 44 
     | 
    
         
            +
                          http://www.rubyonrails.com/foo.cgi?something=here
         
     | 
| 
      
 45 
     | 
    
         
            +
                          http://www.rubyonrails.com/foo.cgi?something=here&and=here
         
     | 
| 
      
 46 
     | 
    
         
            +
                          http://www.rubyonrails.com/contact;new
         
     | 
| 
      
 47 
     | 
    
         
            +
                          http://www.rubyonrails.com/contact;new%20with%20spaces
         
     | 
| 
      
 48 
     | 
    
         
            +
                          http://www.rubyonrails.com/contact;new?with=query&string=params
         
     | 
| 
      
 49 
     | 
    
         
            +
                          http://www.rubyonrails.com/~minam/contact;new?with=query&string=params
         
     | 
| 
      
 50 
     | 
    
         
            +
                          http://en.wikipedia.org/wiki/Wikipedia:Today%27s_featured_picture_%28animation%29/January_20%2C_2007
         
     | 
| 
      
 51 
     | 
    
         
            +
                          http://www.mail-archive.com/rails@lists.rubyonrails.org/
         
     | 
| 
      
 52 
     | 
    
         
            +
                          http://www.amazon.com/Testing-Equal-Sign-In-Path/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1198861734&sr=8-1
         
     | 
| 
      
 53 
     | 
    
         
            +
                          http://en.wikipedia.org/wiki/Sprite_(computer_graphics)
         
     | 
| 
      
 54 
     | 
    
         
            +
                          http://en.wikipedia.org/wiki/Texas_hold'em
         
     | 
| 
      
 55 
     | 
    
         
            +
                          https://www.google.com/doku.php?id=gps:resource:scs:start
         
     | 
| 
      
 56 
     | 
    
         
            +
                        )
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                urls.each do |url|
         
     | 
| 
      
 59 
     | 
    
         
            +
                  assert_linked %(<a href="#{url}">#{CGI.escapeHTML(url)}</a>), url
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
              def test_like_rails_rules
         
     | 
| 
      
 64 
     | 
    
         
            +
                email_raw    = 'david@loudthinking.com'
         
     | 
| 
      
 65 
     | 
    
         
            +
                email_result = %{<a href="mailto:#{email_raw}">#{email_raw}</a>}
         
     | 
| 
      
 66 
     | 
    
         
            +
                email2_raw    = '+david@loudthinking.com'
         
     | 
| 
      
 67 
     | 
    
         
            +
                email2_result = %{<a href="mailto:#{email2_raw}">#{email2_raw}</a>}
         
     | 
| 
      
 68 
     | 
    
         
            +
                link_raw     = 'http://www.rubyonrails.com'
         
     | 
| 
      
 69 
     | 
    
         
            +
                link_result  = %{<a href="#{link_raw}">#{link_raw}</a>}
         
     | 
| 
      
 70 
     | 
    
         
            +
                link_result_with_options  = %{<a href="#{link_raw}" target="_blank">#{CGI.escapeHTML(link_raw)}</a>}
         
     | 
| 
      
 71 
     | 
    
         
            +
                link2_raw    = 'www.rubyonrails.com'
         
     | 
| 
      
 72 
     | 
    
         
            +
                link2_result = %{<a href="http://#{link2_raw}">#{CGI.escapeHTML(link2_raw)}</a>}
         
     | 
| 
      
 73 
     | 
    
         
            +
                link3_raw    = 'http://manuals.ruby-on-rails.com/read/chapter.need_a-period/103#page281'
         
     | 
| 
      
 74 
     | 
    
         
            +
                link3_result = %{<a href="#{link3_raw}">#{CGI.escapeHTML(link3_raw)}</a>}
         
     | 
| 
      
 75 
     | 
    
         
            +
                link4_raw    = 'http://foo.example.com/controller/action?parm=value&p2=v2#anchor123'
         
     | 
| 
      
 76 
     | 
    
         
            +
                link4_result = %{<a href="#{link4_raw}">#{CGI.escapeHTML(link4_raw)}</a>}
         
     | 
| 
      
 77 
     | 
    
         
            +
                link5_raw    = 'http://foo.example.com:3000/controller/action'
         
     | 
| 
      
 78 
     | 
    
         
            +
                link5_result = %{<a href="#{link5_raw}">#{CGI.escapeHTML(link5_raw)}</a>}
         
     | 
| 
      
 79 
     | 
    
         
            +
                link6_raw    = 'http://foo.example.com:3000/controller/action+pack'
         
     | 
| 
      
 80 
     | 
    
         
            +
                link6_result = %{<a href="#{link6_raw}">#{CGI.escapeHTML(link6_raw)}</a>}
         
     | 
| 
      
 81 
     | 
    
         
            +
                link7_raw    = 'http://foo.example.com/controller/action?parm=value&p2=v2#anchor-123'
         
     | 
| 
      
 82 
     | 
    
         
            +
                link7_result = %{<a href="#{link7_raw}">#{CGI.escapeHTML(link7_raw)}</a>}
         
     | 
| 
      
 83 
     | 
    
         
            +
                link8_raw    = 'http://foo.example.com:3000/controller/action.html'
         
     | 
| 
      
 84 
     | 
    
         
            +
                link8_result = %{<a href="#{link8_raw}">#{CGI.escapeHTML(link8_raw)}</a>}
         
     | 
| 
      
 85 
     | 
    
         
            +
                link9_raw    = 'http://business.timesonline.co.uk/article/0,,9065-2473189,00.html'
         
     | 
| 
      
 86 
     | 
    
         
            +
                link9_result = %{<a href="#{link9_raw}">#{CGI.escapeHTML(link9_raw)}</a>}
         
     | 
| 
      
 87 
     | 
    
         
            +
                link10_raw    = 'http://www.mail-archive.com/ruby-talk@ruby-lang.org/'
         
     | 
| 
      
 88 
     | 
    
         
            +
                link10_result = %{<a href="#{link10_raw}">#{CGI.escapeHTML(link10_raw)}</a>}
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
                assert_linked %(Go to #{link_result} and say hello to #{email_result}), "Go to #{link_raw} and say hello to #{email_raw}"
         
     | 
| 
      
 91 
     | 
    
         
            +
                assert_linked %(Link #{link_result}), "Link #{link_raw}"
         
     | 
| 
      
 92 
     | 
    
         
            +
                assert_linked %(#{link_result} Link), "#{link_raw} Link"
         
     | 
| 
      
 93 
     | 
    
         
            +
                assert_linked %(Go to #{link_result}.), %(Go to #{link_raw}.)
         
     | 
| 
      
 94 
     | 
    
         
            +
                assert_linked %(Go to #{link_result}, then say hello to #{email_result}.), %(Go to #{link_raw}, then say hello to #{email_raw}.)
         
     | 
| 
      
 95 
     | 
    
         
            +
                assert_linked %(Link #{link2_result}), "Link #{link2_raw}"
         
     | 
| 
      
 96 
     | 
    
         
            +
                assert_linked %(#{link2_result} Link), "#{link2_raw} Link"
         
     | 
| 
      
 97 
     | 
    
         
            +
                assert_linked %(Go to #{link2_result}.), %(Go to #{link2_raw}.)
         
     | 
| 
      
 98 
     | 
    
         
            +
                assert_linked %(Say hello to #{email_result}, then go to #{link2_result}.), %(Say hello to #{email_raw}, then go to #{link2_raw}.)
         
     | 
| 
      
 99 
     | 
    
         
            +
                assert_linked %(Link #{link3_result}), "Link #{link3_raw}"
         
     | 
| 
      
 100 
     | 
    
         
            +
                assert_linked %(#{link3_result} Link), "#{link3_raw} Link"
         
     | 
| 
      
 101 
     | 
    
         
            +
                assert_linked %(Go to #{link3_result}.), %(Go to #{link3_raw}.)
         
     | 
| 
      
 102 
     | 
    
         
            +
                assert_linked %(Go to #{link3_result}. seriously, #{link3_result}? i think I'll say hello to #{email_result}. instead.), %(Go to #{link3_raw}. seriously, #{link3_raw}? i think I'll say hello to #{email_raw}. instead.)
         
     | 
| 
      
 103 
     | 
    
         
            +
                assert_linked %(Link #{link4_result}), "Link #{link4_raw}"
         
     | 
| 
      
 104 
     | 
    
         
            +
                assert_linked %(#{link4_result} Link), "#{link4_raw} Link"
         
     | 
| 
      
 105 
     | 
    
         
            +
                assert_linked %(#{link5_result} Link), "#{link5_raw} Link"
         
     | 
| 
      
 106 
     | 
    
         
            +
                assert_linked %(#{link6_result} Link), "#{link6_raw} Link"
         
     | 
| 
      
 107 
     | 
    
         
            +
                assert_linked %(#{link7_result} Link), "#{link7_raw} Link"
         
     | 
| 
      
 108 
     | 
    
         
            +
                assert_linked %(Link #{link8_result}), "Link #{link8_raw}"
         
     | 
| 
      
 109 
     | 
    
         
            +
                assert_linked %(#{link8_result} Link), "#{link8_raw} Link"
         
     | 
| 
      
 110 
     | 
    
         
            +
                assert_linked %(Go to #{link8_result}.), %(Go to #{link8_raw}.)
         
     | 
| 
      
 111 
     | 
    
         
            +
                assert_linked %(Go to #{link8_result}. seriously, #{link8_result}? i think I'll say hello to #{email_result}. instead.), %(Go to #{link8_raw}. seriously, #{link8_raw}? i think I'll say hello to #{email_raw}. instead.)
         
     | 
| 
      
 112 
     | 
    
         
            +
                assert_linked %(Link #{link9_result}), "Link #{link9_raw}"
         
     | 
| 
      
 113 
     | 
    
         
            +
                #assert_linked %(#{link9_result} Link), "#{link9_raw} Link"
         
     | 
| 
      
 114 
     | 
    
         
            +
                assert_linked %(Go to #{link9_result}.), %(Go to #{link9_raw}.)
         
     | 
| 
      
 115 
     | 
    
         
            +
                #assert_linked %(Go to #{link9_result}. seriously, #{link9_result}? i think I'll say hello to #{email_result}. instead.), %(Go to #{link9_raw}. seriously, #{link9_raw}? i think I'll say hello to #{email_raw}. instead.)
         
     | 
| 
      
 116 
     | 
    
         
            +
                #assert_linked %(#{link10_result} Link), "#{link10_raw} Link"
         
     | 
| 
      
 117 
     | 
    
         
            +
                assert_linked email2_result, email2_raw
         
     | 
| 
      
 118 
     | 
    
         
            +
                assert_linked "#{link_result} #{link_result} #{link_result}", "#{link_raw} #{link_raw} #{link_raw}"
         
     | 
| 
      
 119 
     | 
    
         
            +
                assert_linked '<a href="http://www.rubyonrails.com">Ruby On Rails</a>', '<a href="http://www.rubyonrails.com">Ruby On Rails</a>'
         
     | 
| 
      
 120 
     | 
    
         
            +
              end
         
     | 
| 
      
 121 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version 
     | 
|
| 
       5 
5 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       6 
6 
     | 
    
         
             
              segments: 
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 1
         
     | 
| 
       8 
     | 
    
         
            -
              -  
     | 
| 
       9 
     | 
    
         
            -
              -  
     | 
| 
       10 
     | 
    
         
            -
              version: 1. 
     | 
| 
      
 8 
     | 
    
         
            +
              - 15
         
     | 
| 
      
 9 
     | 
    
         
            +
              - 0
         
     | 
| 
      
 10 
     | 
    
         
            +
              version: 1.15.0
         
     | 
| 
       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- 
     | 
| 
      
 19 
     | 
    
         
            +
            date: 2011-06-02 00:00:00 +02:00
         
     | 
| 
       20 
20 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       21 
21 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
         @@ -50,6 +50,7 @@ files: 
     | 
|
| 
       50 
50 
     | 
    
         
             
            - test/benchmark.rb
         
     | 
| 
       51 
51 
     | 
    
         
             
            - test/benchmark.txt
         
     | 
| 
       52 
52 
     | 
    
         
             
            - test/markdown_test.rb
         
     | 
| 
      
 53 
     | 
    
         
            +
            - test/rails_test.rb
         
     | 
| 
       53 
54 
     | 
    
         
             
            - test/redcarpet_test.rb
         
     | 
| 
       54 
55 
     | 
    
         
             
            has_rdoc: true
         
     | 
| 
       55 
56 
     | 
    
         
             
            homepage: http://github.com/tanoku/redcarpet
         
     |