From 927fb000a76a9f70f229b222f89be34af38bd78c Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Wed, 6 May 2015 02:29:08 -0300 Subject: content-parser: actually use inline parser --- src/content-parser.c | 22 +++++++++++++++++++--- tests/check_content_parser.c | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/content-parser.c b/src/content-parser.c index 29a20bb..676da8b 100644 --- a/src/content-parser.c +++ b/src/content-parser.c @@ -280,6 +280,7 @@ blogc_content_parse(const char *src, size_t src_len, blogc_error_t **err) size_t prefix_len = 0; char *tmp = NULL; char *tmp2 = NULL; + char *tmp3 = NULL; char *parsed = NULL; char **tmpv = NULL; @@ -539,7 +540,13 @@ blogc_content_parse(const char *src, size_t src_len, blogc_error_t **err) end = is_last && c != '\n' && c != '\r' ? src_len : current; tmp = b_strndup(src + start, end - start); if (b_str_starts_with(tmp, prefix)) { - lines = b_slist_append(lines, b_strdup(tmp + strlen(prefix))); + tmp3 = b_strdup(tmp + strlen(prefix)); + parsed = blogc_content_parse_inline(tmp3); + free(tmp3); + tmp3 = NULL; + lines = b_slist_append(lines, b_strdup(parsed)); + free(parsed); + parsed = NULL; } else { *err = blogc_error_parser(BLOGC_ERROR_CONTENT_PARSER, src, src_len, @@ -623,8 +630,14 @@ blogc_content_parse(const char *src, size_t src_len, blogc_error_t **err) goto err_li; } } - lines = b_slist_append(lines, b_strdup(tmp + prefix_len)); + tmp3 = b_strdup(tmp + prefix_len); + parsed = blogc_content_parse_inline(tmp3); + free(tmp3); + tmp3 = NULL; + lines = b_slist_append(lines, b_strdup(parsed)); state = CONTENT_ORDERED_LIST_END; + free(parsed); + parsed = NULL; err_li: b_strv_free(tmpv); tmpv = NULL; @@ -665,7 +678,10 @@ err_li: case CONTENT_PARAGRAPH_END: if (c == '\n' || c == '\r' || is_last) { tmp = b_strndup(src + start, end - start); - b_string_append_printf(rv, "

%s

\n", tmp); + parsed = blogc_content_parse_inline(tmp); + b_string_append_printf(rv, "

%s

\n", parsed); + free(parsed); + parsed = NULL; free(tmp); tmp = NULL; state = CONTENT_START_LINE; diff --git a/tests/check_content_parser.c b/tests/check_content_parser.c index a613052..ab1bf49 100644 --- a/tests/check_content_parser.c +++ b/tests/check_content_parser.c @@ -94,7 +94,7 @@ test_content_parse(void **state) "\n" "

guda\n" "yay

\n" - "

**bola**

\n"); + "

bola

\n"); free(html); } -- cgit v1.2.3-18-g5258