diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2015-05-06 02:29:08 -0300 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2015-05-06 02:29:08 -0300 |
commit | 927fb000a76a9f70f229b222f89be34af38bd78c (patch) | |
tree | 92a0fa368d543b9a4d299156b3e8e5bd4f9b26d2 | |
parent | 903c8313bc1f8a1ce3d97fc944293d79ccdac76c (diff) | |
download | blogc-927fb000a76a9f70f229b222f89be34af38bd78c.tar.gz blogc-927fb000a76a9f70f229b222f89be34af38bd78c.tar.bz2 blogc-927fb000a76a9f70f229b222f89be34af38bd78c.zip |
content-parser: actually use inline parser
-rw-r--r-- | src/content-parser.c | 22 | ||||
-rw-r--r-- | 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, "<p>%s</p>\n", tmp); + parsed = blogc_content_parse_inline(tmp); + b_string_append_printf(rv, "<p>%s</p>\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) "</style>\n" "<p>guda\n" "yay</p>\n" - "<p>**bola**</p>\n"); + "<p><strong>bola</strong></p>\n"); free(html); } |