aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2016-05-22 17:10:46 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2016-05-22 17:12:44 +0200
commitcc0c4d6866bb876e1ba098bc7f70fb8f312e9fc2 (patch)
tree52a5885d71682901ee46060954d5e2c589be9675
parentee0c0a7256b64b1ac2dd46436a7b627eb08c7724 (diff)
downloadblogc-cc0c4d6866bb876e1ba098bc7f70fb8f312e9fc2.tar.gz
blogc-cc0c4d6866bb876e1ba098bc7f70fb8f312e9fc2.tar.bz2
blogc-cc0c4d6866bb876e1ba098bc7f70fb8f312e9fc2.zip
content-parser: do not use paragraphs inside blockquote for DESCRIPTION
-rw-r--r--man/blogc-source.7.ronn3
-rw-r--r--src/content-parser.c5
-rw-r--r--tests/check_content_parser.c8
3 files changed, 10 insertions, 6 deletions
diff --git a/man/blogc-source.7.ronn b/man/blogc-source.7.ronn
index b583d6e..1945329 100644
--- a/man/blogc-source.7.ronn
+++ b/man/blogc-source.7.ronn
@@ -52,7 +52,8 @@ explicit definition in source file.
Another variable, `DESCRIPTION`, will be automatically created by the source
parser. Its content is the first line of the first paragraph of the content.
-This variable can be overriden by an explicit definition in source file.
+Paragraphs inside blockquotes are ignored. This variable can be overriden by
+an explicit definition in source file.
## SOURCE CONTENT - BLOCK ELEMENTS
diff --git a/src/content-parser.c b/src/content-parser.c
index 0c99e31..4840a1d 100644
--- a/src/content-parser.c
+++ b/src/content-parser.c
@@ -701,7 +701,10 @@ blogc_content_parse(const char *src, size_t *end_excerpt, char **description)
for (sb_slist_t *l = lines; l != NULL; l = l->next)
sb_string_append_printf(tmp_str, "%s%s", l->data,
line_ending);
- tmp = blogc_content_parse(tmp_str->str, NULL, description);
+ // do not propagate description to blockquote parsing,
+ // because we just want paragraphs from first level of
+ // content.
+ tmp = blogc_content_parse(tmp_str->str, NULL, NULL);
sb_string_append_printf(rv, "<blockquote>%s</blockquote>%s",
tmp, line_ending);
free(tmp);
diff --git a/tests/check_content_parser.c b/tests/check_content_parser.c
index 2444ebb..d3ef2b8 100644
--- a/tests/check_content_parser.c
+++ b/tests/check_content_parser.c
@@ -1153,7 +1153,7 @@ test_content_parse_description(void **state)
"</blockquote>\n"
"<p>bar</p>\n");
assert_non_null(d);
- assert_string_equal(d, "qwe");
+ assert_string_equal(d, "bar");
free(html);
free(d);
d = NULL;
@@ -1172,7 +1172,7 @@ test_content_parse_description(void **state)
"</blockquote>\n"
"<p>bar</p>\n");
assert_non_null(d);
- assert_string_equal(d, "qwe");
+ assert_string_equal(d, "bar");
free(html);
free(d);
}
@@ -1236,7 +1236,7 @@ test_content_parse_description_crlf(void **state)
"</blockquote>\r\n"
"<p>bar</p>\r\n");
assert_non_null(d);
- assert_string_equal(d, "qwe");
+ assert_string_equal(d, "bar");
free(html);
free(d);
d = NULL;
@@ -1255,7 +1255,7 @@ test_content_parse_description_crlf(void **state)
"</blockquote>\r\n"
"<p>bar</p>\r\n");
assert_non_null(d);
- assert_string_equal(d, "qwe");
+ assert_string_equal(d, "bar");
free(html);
free(d);
}