Permalink
Browse files

update sundown and support Sondown\Render\HTML

  • Loading branch information...
1 parent 3f4063a commit 71ba79ba9c9083bf300ace324bdeb6233c7681fa @chobie committed Sep 16, 2011
Showing with 1,504 additions and 1,104 deletions.
  1. +12 −12 src/autolink.c
  2. +4 −4 src/autolink.h
  3. +123 −218 src/buffer.c
  4. +49 −112 src/buffer.h
  5. +16 −1 src/config.m4
  6. +28 −0 src/houdini.h
  7. +108 −0 src/houdini_href_e.c
  8. +84 −0 src/houdini_html_e.c
  9. +77 −148 src/html.c
  10. +8 −12 src/html.h
  11. +24 −0 src/html_block_names.txt
  12. +205 −0 src/html_blocks.h
  13. +42 −42 src/html_smartypants.c
  14. +468 −371 src/markdown.c
  15. +35 −25 src/markdown.h
  16. +48 −94 src/php_sundown.c
  17. +33 −0 src/php_sundown.h
  18. +24 −23 src/render_base.c
  19. +3 −1 src/render_html.c
  20. +81 −0 src/stack.c
  21. +21 −0 src/stack.h
  22. +10 −40 src/sundown_markdown.c
  23. +1 −1 sundown
View
@@ -22,7 +22,7 @@
#include <ctype.h>
int
-sd_autolink_issafe(const char *link, size_t link_len)
+sd_autolink_issafe(const uint8_t *link, size_t link_len)
{
static const size_t valid_uris_count = 4;
static const char *valid_uris[] = {
@@ -35,7 +35,7 @@ sd_autolink_issafe(const char *link, size_t link_len)
size_t len = strlen(valid_uris[i]);
if (link_len > len &&
- strncasecmp(link, valid_uris[i], len) == 0 &&
+ strncasecmp((char *)link, valid_uris[i], len) == 0 &&
isalnum(link[len]))
return 1;
}
@@ -44,9 +44,9 @@ sd_autolink_issafe(const char *link, size_t link_len)
}
static size_t
-autolink_delim(char *data, size_t link_end, size_t offset, size_t size)
+autolink_delim(uint8_t *data, size_t link_end, size_t offset, size_t size)
{
- char cclose, copen = 0;
+ uint8_t cclose, copen = 0;
size_t i;
for (i = 0; i < link_end; ++i)
@@ -128,7 +128,7 @@ autolink_delim(char *data, size_t link_end, size_t offset, size_t size)
}
static size_t
-check_domain(char *data, size_t size)
+check_domain(uint8_t *data, size_t size)
{
size_t i, np = 0;
@@ -147,14 +147,14 @@ check_domain(char *data, size_t size)
}
size_t
-sd_autolink__www(size_t *rewind_p, struct buf *link, char *data, size_t offset, size_t size)
+sd_autolink__www(size_t *rewind_p, struct buf *link, uint8_t *data, size_t offset, size_t size)
{
size_t link_end;
if (offset > 0 && !ispunct(data[-1]) && !isspace(data[-1]))
return 0;
- if (size < 4 || memcmp(data, "www.", STRLEN("www.")) != 0)
+ if (size < 4 || memcmp(data, "www.", strlen("www.")) != 0)
return 0;
link_end = check_domain(data, size);
@@ -177,13 +177,13 @@ sd_autolink__www(size_t *rewind_p, struct buf *link, char *data, size_t offset,
}
size_t
-sd_autolink__email(size_t *rewind_p, struct buf *link, char *data, size_t offset, size_t size)
+sd_autolink__email(size_t *rewind_p, struct buf *link, uint8_t *data, size_t offset, size_t size)
{
size_t link_end, rewind;
int nb = 0, np = 0;
for (rewind = 0; rewind < offset; ++rewind) {
- char c = data[-rewind - 1];
+ uint8_t c = data[-rewind - 1];
if (isalnum(c))
continue;
@@ -198,7 +198,7 @@ sd_autolink__email(size_t *rewind_p, struct buf *link, char *data, size_t offset
return 0;
for (link_end = 0; link_end < size; ++link_end) {
- char c = data[link_end];
+ uint8_t c = data[link_end];
if (isalnum(c))
continue;
@@ -226,7 +226,7 @@ sd_autolink__email(size_t *rewind_p, struct buf *link, char *data, size_t offset
}
size_t
-sd_autolink__url(size_t *rewind_p, struct buf *link, char *data, size_t offset, size_t size)
+sd_autolink__url(size_t *rewind_p, struct buf *link, uint8_t *data, size_t offset, size_t size)
{
size_t link_end, rewind = 0, domain_len;
@@ -238,7 +238,7 @@ sd_autolink__url(size_t *rewind_p, struct buf *link, char *data, size_t offset,
if (!sd_autolink_issafe(data - rewind, size + rewind))
return 0;
- link_end = STRLEN("://");
+ link_end = strlen("://");
domain_len = check_domain(data + link_end, size - link_end);
if (domain_len == 0)
View
@@ -20,16 +20,16 @@
#include "buffer.h"
extern int
-sd_autolink_issafe(const char *link, size_t link_len);
+sd_autolink_issafe(const uint8_t *link, size_t link_len);
extern size_t
-sd_autolink__www(size_t *rewind_p, struct buf *link, char *data, size_t offset, size_t size);
+sd_autolink__www(size_t *rewind_p, struct buf *link, uint8_t *data, size_t offset, size_t size);
extern size_t
-sd_autolink__email(size_t *rewind_p, struct buf *link, char *data, size_t offset, size_t size);
+sd_autolink__email(size_t *rewind_p, struct buf *link, uint8_t *data, size_t offset, size_t size);
extern size_t
-sd_autolink__url(size_t *rewind_p, struct buf *link, char *data, size_t offset, size_t size);
+sd_autolink__url(size_t *rewind_p, struct buf *link, uint8_t *data, size_t offset, size_t size);
#endif
Oops, something went wrong.

0 comments on commit 71ba79b

Please sign in to comment.