packages feed

sundown 0.5 → 0.5.0.1

raw patch · 9 files changed

+63/−21 lines, 9 filesdep ~utf8-string

Dependency ranges changed: utf8-string

Files

src/Text/Sundown/Foreign.hsc view
@@ -1,3 +1,4 @@+{-# Language EmptyDataDecls #-} {-# Language ForeignFunctionInterface #-} module Text.Sundown.Foreign     ( Extensions (..)
src/Text/Sundown/Html/Foreign.hsc view
@@ -1,8 +1,8 @@+{-# Language EmptyDataDecls #-} {-# Language ForeignFunctionInterface #-} module Text.Sundown.Html.Foreign     ( HtmlRenderMode (..)     , sdhtml_renderer-    , sdhtml_torenderer     , sdhtml_smartypants     ) where @@ -56,9 +56,6 @@ sdhtml_renderer rndr options mode = sdhtml_renderer' rndr options (toCUInt mode) foreign import ccall "html.h sdhtml_renderer"     sdhtml_renderer' :: Ptr Callbacks -> Ptr HtmlRenderOptions -> CUInt -> IO ()--foreign import ccall "html.h sdhtml_toc_renderer"-    sdhtml_torenderer :: Ptr Callbacks -> Ptr HtmlRenderOptions -> IO ()  foreign import ccall "html.h sdhtml_smartypants"     sdhtml_smartypants :: Ptr Buffer -> CString -> CSize -> IO ()
sundown-c/autolink.c view
@@ -49,7 +49,7 @@ }  static size_t-autolink_delim(uint8_t *data, size_t link_end, size_t offset, size_t size)+autolink_delim(uint8_t *data, size_t link_end, size_t max_rewind, size_t size) { 	uint8_t cclose, copen = 0; 	size_t i;@@ -163,13 +163,13 @@ 	size_t *rewind_p, 	struct buf *link, 	uint8_t *data,-	size_t offset,+	size_t max_rewind, 	size_t size, 	unsigned int flags) { 	size_t link_end; -	if (offset > 0 && !ispunct(data[-1]) && !isspace(data[-1]))+	if (max_rewind > 0 && !ispunct(data[-1]) && !isspace(data[-1])) 		return 0;  	if (size < 4 || memcmp(data, "www.", strlen("www.")) != 0)@@ -183,7 +183,7 @@ 	while (link_end < size && !isspace(data[link_end])) 		link_end++; -	link_end = autolink_delim(data, link_end, offset, size);+	link_end = autolink_delim(data, link_end, max_rewind, size);  	if (link_end == 0) 		return 0;@@ -199,14 +199,14 @@ 	size_t *rewind_p, 	struct buf *link, 	uint8_t *data,-	size_t offset,+	size_t max_rewind, 	size_t size, 	unsigned int flags) { 	size_t link_end, rewind; 	int nb = 0, np = 0; -	for (rewind = 0; rewind < offset; ++rewind) {+	for (rewind = 0; rewind < max_rewind; ++rewind) { 		uint8_t c = data[-rewind - 1];  		if (isalnum(c))@@ -238,7 +238,7 @@ 	if (link_end < 2 || nb != 1 || np == 0) 		return 0; -	link_end = autolink_delim(data, link_end, offset, size);+	link_end = autolink_delim(data, link_end, max_rewind, size);  	if (link_end == 0) 		return 0;@@ -254,7 +254,7 @@ 	size_t *rewind_p, 	struct buf *link, 	uint8_t *data,-	size_t offset,+	size_t max_rewind, 	size_t size, 	unsigned int flags) {@@ -263,7 +263,7 @@ 	if (size < 4 || data[1] != '/' || data[2] != '/') 		return 0; -	while (rewind < offset && isalpha(data[-rewind - 1]))+	while (rewind < max_rewind && isalpha(data[-rewind - 1])) 		rewind++;  	if (!sd_autolink_issafe(data - rewind, size + rewind))@@ -283,7 +283,7 @@ 	while (link_end < size && !isspace(data[link_end])) 		link_end++; -	link_end = autolink_delim(data, link_end, offset, size);+	link_end = autolink_delim(data, link_end, max_rewind, size);  	if (link_end == 0) 		return 0;
sundown-c/houdini.h view
@@ -3,6 +3,10 @@  #include "buffer.h" +#ifdef __cplusplus+extern "C" {+#endif+ #ifdef HOUDINI_USE_LOCALE #	define _isxdigit(c) isxdigit(c) #	define _isdigit(c) isdigit(c)@@ -25,5 +29,9 @@ extern void houdini_unescape_url(struct buf *ob, const uint8_t *src, size_t size); extern void houdini_escape_js(struct buf *ob, const uint8_t *src, size_t size); extern void houdini_unescape_js(struct buf *ob, const uint8_t *src, size_t size);++#ifdef __cplusplus+}+#endif  #endif
sundown-c/html.c view
@@ -491,6 +491,13 @@ { 	struct html_renderopt *options = opaque; +	/* set the level offset if this is the first header+	 * we're parsing for the document */+	if (options->toc_data.current_level == 0) {+		options->toc_data.level_offset = level - 1;+	}+	level -= options->toc_data.level_offset;+ 	if (level > options->toc_data.current_level) { 		while (level > options->toc_data.current_level) { 			BUFPUTSL(ob, "<ul>\n<li>\n");@@ -509,10 +516,18 @@  	bufprintf(ob, "<a href=\"#toc_%d\">", options->toc_data.header_count++); 	if (text)-		bufput(ob, text->data, text->size);+		escape_html(ob, text->data, text->size); 	BUFPUTSL(ob, "</a>\n"); } +static int+toc_link(struct buf *ob, const struct buf *link, const struct buf *title, const struct buf *content, void *opaque)+{+	if (content && content->size)+		bufput(ob, content->data, content->size);+	return 1;+}+ static void toc_finalize(struct buf *ob, void *opaque) {@@ -546,7 +561,7 @@ 		rndr_emphasis, 		NULL, 		NULL,-		NULL,+		toc_link, 		NULL, 		rndr_triple_emphasis, 		rndr_strikethrough,
sundown-c/html.h view
@@ -21,10 +21,15 @@ #include "buffer.h" #include <stdlib.h> +#ifdef __cplusplus+extern "C" {+#endif+ struct html_renderopt { 	struct { 		int header_count; 		int current_level;+		int level_offset; 	} toc_data;  	unsigned int flags;@@ -63,6 +68,10 @@  extern void sdhtml_smartypants(struct buf *ob, const uint8_t *text, size_t size);++#ifdef __cplusplus+}+#endif  #endif 
sundown-c/html_smartypants.c view
@@ -22,6 +22,10 @@ #include <stdio.h> #include <ctype.h> +#if defined(_WIN32)+#define snprintf	_snprintf		+#endif+ struct smartypants_data { 	int in_squote; 	int in_dquote;
sundown-c/markdown.c view
@@ -501,7 +501,7 @@ 		if (data[i] == c && !_isspace(data[i - 1])) {  			if (rndr->ext_flags & MKDEXT_NO_INTRA_EMPHASIS) {-				if (!(i + 1 == size || _isspace(data[i + 1]) || ispunct(data[i + 1])))+				if (i + 1 < size && isalnum(data[i + 1])) 					continue; 			} @@ -595,6 +595,11 @@ { 	uint8_t c = data[0]; 	size_t ret;++	if (rndr->ext_flags & MKDEXT_NO_INTRA_EMPHASIS) {+		if (offset > 0 && !_isspace(data[-1]) && data[-1] != '>')+			return 0;+	}  	if (size > 2 && data[1] != c) { 		/* whitespace cannot follow an opening emphasis;
sundown.cabal view
@@ -1,6 +1,6 @@ Cabal-version:      >= 1.6 Name:               sundown-Version:            0.5+Version:            0.5.0.1 Author:             Francesco Mazzoli (f@mazzo.li) Maintainer:         Francesco Mazzoli (f@mazzo.li) Build-Type:         Simple@@ -12,7 +12,7 @@ Homepage:           https://github.com/bitonic/sundown Bug-Reports:        https://github.com/bitonic/sundown/issues Description:-    Bindings to GitHub's C markdown library: <https://github.com/tanoku/sundown>.+    Bindings to GitHub's C markdown library: <https://github.com/vmg/sundown>.     .      The Haskell code is in the public domain. For sundown's license, refer to     its GitHub page.@@ -23,9 +23,12 @@  Library     Hs-Source-Dirs:   src-    Build-Depends:    base >= 3 && < 5, bytestring, utf8-string, text+    Build-Depends:    base >= 3 && < 5,+                      bytestring,+                      utf8-string >= 0.3,+                      text     GHC-Options:      -Wall -O2 -fno-cse-    Extensions:       ForeignFunctionInterface, EmptyDataDecls+    Extensions:       EmptyDataDecls, ForeignFunctionInterface      Exposed-Modules:  Text.Sundown,                       Text.Sundown.Html.ByteString,