aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am3
-rw-r--r--src/content-parser.c246
-rw-r--r--src/directives.c21
-rw-r--r--src/directives.h17
-rw-r--r--tests/check_content_parser.c620
5 files changed, 23 insertions, 884 deletions
diff --git a/Makefile.am b/Makefile.am
index 4e79863..4a28b8b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -26,7 +26,6 @@ MAINTAINERCLEANFILES = \
noinst_HEADERS = \
src/content-parser.h \
src/datetime-parser.h \
- src/directives.h \
src/file.h \
src/error.h \
src/loader.h \
@@ -54,7 +53,6 @@ check_PROGRAMS = \
libblogc_la_SOURCES = \
src/content-parser.c \
src/datetime-parser.c \
- src/directives.c \
src/file.c \
src/error.c \
src/loader.c \
@@ -200,7 +198,6 @@ tests_check_content_parser_CFLAGS = \
tests_check_content_parser_LDFLAGS = \
-no-install \
- -Wl,--wrap=blogc_directive_loader \
$(NULL)
tests_check_content_parser_LDADD = \
diff --git a/src/content-parser.c b/src/content-parser.c
index 1529ace..59e337e 100644
--- a/src/content-parser.c
+++ b/src/content-parser.c
@@ -15,7 +15,6 @@
#include "utils/utils.h"
#include "content-parser.h"
-#include "directives.h"
// this is a half ass implementation of a markdown-like syntax. bugs are
// expected. feel free to improve the parser and add new features.
@@ -44,7 +43,7 @@ blogc_slugify(const char *str)
typedef enum {
CONTENT_START_LINE = 1,
- CONTENT_EXCERPT_OR_DIRECTIVE,
+ CONTENT_EXCERPT,
CONTENT_EXCERPT_END,
CONTENT_HEADER,
CONTENT_HEADER_TITLE_START,
@@ -65,17 +64,6 @@ typedef enum {
CONTENT_ORDERED_LIST_SPACE,
CONTENT_ORDERED_LIST_START,
CONTENT_ORDERED_LIST_END,
- CONTENT_DIRECTIVE_NAME_START,
- CONTENT_DIRECTIVE_NAME,
- CONTENT_DIRECTIVE_COLON,
- CONTENT_DIRECTIVE_ARGUMENT_START,
- CONTENT_DIRECTIVE_ARGUMENT,
- CONTENT_DIRECTIVE_PARAM_PREFIX,
- CONTENT_DIRECTIVE_PARAM_KEY_START,
- CONTENT_DIRECTIVE_PARAM_KEY,
- CONTENT_DIRECTIVE_PARAM_VALUE_START,
- CONTENT_DIRECTIVE_PARAM_VALUE,
- CONTENT_DIRECTIVE_PARAM_END,
CONTENT_PARAGRAPH,
CONTENT_PARAGRAPH_END,
} blogc_content_parser_state_t;
@@ -416,9 +404,6 @@ blogc_content_parse(const char *src, size_t *end_excerpt)
size_t end = 0;
size_t eend = 0;
size_t real_end = 0;
- size_t spaces = 0;
-
- bool no_jump = false;
unsigned int header_level = 0;
char *prefix = NULL;
@@ -428,11 +413,6 @@ blogc_content_parse(const char *src, size_t *end_excerpt)
char *parsed = NULL;
char *slug = NULL;
- char *directive_name = NULL;
- char *directive_argument = NULL;
- char *directive_key = NULL;
- b_trie_t *directive_params = NULL;
-
// this isn't empty because we need some reasonable default value in the
// unlikely case that we need to print some line ending before evaluating
// the "real" value.
@@ -483,9 +463,11 @@ blogc_content_parse(const char *src, size_t *end_excerpt)
break;
start = current;
if (c == '.') {
- eend = rv->len; // fuck it
- state = CONTENT_EXCERPT_OR_DIRECTIVE;
- break;
+ if (end_excerpt != NULL) {
+ eend = rv->len; // fuck it
+ state = CONTENT_EXCERPT;
+ break;
+ }
}
if (c == '#') {
header_level = 1;
@@ -520,29 +502,26 @@ blogc_content_parse(const char *src, size_t *end_excerpt)
state = CONTENT_PARAGRAPH;
break;
- case CONTENT_EXCERPT_OR_DIRECTIVE:
- if (c == '.')
- break;
- if (c == ' ' && current - start == 2) {
- state = CONTENT_DIRECTIVE_NAME_START;
- if (is_last)
- goto para;
- break;
- }
- if (c == '\n' || c == '\r') {
- state = CONTENT_EXCERPT_END;
- break;
+ case CONTENT_EXCERPT:
+ if (end_excerpt != NULL) {
+ if (c == '.')
+ break;
+ if (c == '\n' || c == '\r') {
+ state = CONTENT_EXCERPT_END;
+ break;
+ }
}
eend = 0;
state = CONTENT_PARAGRAPH;
break;
case CONTENT_EXCERPT_END:
- if (c == '\n' || c == '\r') {
- if (end_excerpt != NULL)
+ if (end_excerpt != NULL) {
+ if (c == '\n' || c == '\r') {
*end_excerpt = eend;
- state = CONTENT_START_LINE;
- break;
+ state = CONTENT_START_LINE;
+ break;
+ }
}
eend = 0;
state = CONTENT_PARAGRAPH_END;
@@ -637,11 +616,6 @@ blogc_content_parse(const char *src, size_t *end_excerpt)
prefix = NULL;
b_slist_free_full(lines, free);
lines = NULL;
- if (is_last) {
- free(tmp);
- tmp = NULL;
- goto para;
- }
}
free(tmp);
tmp = NULL;
@@ -703,8 +677,6 @@ blogc_content_parse(const char *src, size_t *end_excerpt)
lines = NULL;
free(tmp);
tmp = NULL;
- if (is_last)
- goto para;
break;
}
free(tmp);
@@ -864,8 +836,6 @@ hr:
break;
}
state = CONTENT_PARAGRAPH;
- if (is_last)
- goto para;
break;
case CONTENT_ORDERED_LIST_SPACE:
@@ -967,172 +937,6 @@ hr:
}
break;
- case CONTENT_DIRECTIVE_NAME_START:
- if (is_last)
- goto para;
- if (c >= 'a' && c <= 'z') {
- start2 = current;
- state = CONTENT_DIRECTIVE_NAME;
- break;
- }
- state = CONTENT_PARAGRAPH;
- break;
-
- case CONTENT_DIRECTIVE_NAME:
- if (is_last)
- goto para;
- if ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '_')
- break;
- if (c == ':') {
- end = current;
- state = CONTENT_DIRECTIVE_COLON;
- break;
- }
- state = CONTENT_PARAGRAPH;
- break;
-
- case CONTENT_DIRECTIVE_COLON:
- if (c == ':') {
- free(directive_name);
- directive_name = b_strndup(src + start2, end - start2);
- state = CONTENT_DIRECTIVE_ARGUMENT_START;
- if (is_last)
- goto param_end;
- break;
- }
- if (is_last)
- goto para;
- state = CONTENT_PARAGRAPH;
- break;
-
- case CONTENT_DIRECTIVE_ARGUMENT_START:
- if (c == ' ') {
- if (is_last)
- goto param_end;
- break;
- }
- if (c == '\n' || c == '\r' || is_last) {
- state = CONTENT_DIRECTIVE_PARAM_PREFIX;
- directive_argument = NULL;
- if (is_last)
- goto param_end;
- break;
- }
- start2 = current;
- state = CONTENT_DIRECTIVE_ARGUMENT;
- break;
-
- case CONTENT_DIRECTIVE_ARGUMENT:
- if (c == '\n' || c == '\r' || is_last) {
- spaces = 0;
- state = CONTENT_DIRECTIVE_PARAM_PREFIX;
- end = is_last && c != '\n' && c != '\r' ? src_len :
- (real_end != 0 ? real_end : current);
- free(directive_argument);
- directive_argument = b_strndup(src + start2, end - start2);
- if (is_last)
- goto param_end;
- }
- break;
-
- case CONTENT_DIRECTIVE_PARAM_PREFIX:
- if (c == ' ') {
- spaces++;
- break;
- }
- if ((c == '\n' || c == '\r') && spaces == 0) {
- state = CONTENT_DIRECTIVE_PARAM_END;
- if (is_last)
- goto param_end;
- break;
- }
- if (c == ':' && spaces == 3) {
- state = CONTENT_DIRECTIVE_PARAM_KEY_START;
- break;
- }
- state = CONTENT_PARAGRAPH;
- if (is_last)
- goto para;
- break;
-
- case CONTENT_DIRECTIVE_PARAM_KEY_START:
- if (is_last)
- goto para;
- if (c >= 'a' && c <= 'z') {
- start2 = current;
- state = CONTENT_DIRECTIVE_PARAM_KEY;
- break;
- }
- state = CONTENT_PARAGRAPH;
- break;
-
- case CONTENT_DIRECTIVE_PARAM_KEY:
- if (is_last)
- goto para;
- if ((c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '_')
- break;
- if (c == ':') {
- free(directive_key);
- directive_key = b_strndup(src + start2, current - start2);
- state = CONTENT_DIRECTIVE_PARAM_VALUE_START;
- break;
- }
- state = CONTENT_PARAGRAPH;
- break;
-
- case CONTENT_DIRECTIVE_PARAM_VALUE_START:
- if (is_last)
- goto para;
- if (c == ' ')
- break;
- start2 = current;
- state = CONTENT_DIRECTIVE_PARAM_VALUE;
- break;
-
- case CONTENT_DIRECTIVE_PARAM_VALUE:
- if (c == '\n' || c == '\r' || is_last) {
- state = CONTENT_DIRECTIVE_PARAM_END;
- end = is_last && c != '\n' && c != '\r' ? src_len :
- (real_end != 0 ? real_end : current);
- if (directive_params == NULL)
- directive_params = b_trie_new(free);
- b_trie_insert(directive_params, directive_key,
- b_strndup(src + start2, end - start2));
- free(directive_key);
- directive_key = NULL;
- }
- if (!is_last)
- break;
-
- case CONTENT_DIRECTIVE_PARAM_END:
-param_end:
- if (c == '\n' || c == '\r' || is_last) {
- char *rv_d = blogc_directive_loader(directive_name,
- directive_argument, directive_params);
- if (rv_d)
- b_string_append(rv, rv_d);
- free(rv_d);
- state = CONTENT_START_LINE;
- start = current;
- free(directive_name);
- directive_name = NULL;
- free(directive_argument);
- directive_argument = NULL;
- b_trie_free(directive_params);
- directive_params = NULL;
- break;
- }
- if (c == ' ') {
- start2 = current;
- spaces = 1;
- state = CONTENT_DIRECTIVE_PARAM_PREFIX;
- break;
- }
- state = CONTENT_PARAGRAPH;
- if (is_last)
- goto para;
- break;
-
case CONTENT_PARAGRAPH:
if (c == '\n' || c == '\r' || is_last) {
state = CONTENT_PARAGRAPH_END;
@@ -1143,15 +947,8 @@ param_end:
break;
case CONTENT_PARAGRAPH_END:
- no_jump = true;
para:
if (c == '\n' || c == '\r' || is_last) {
- if (!no_jump && is_last) {
- if (c == '\n' || c == '\r')
- end = src_len - 1;
- else
- end = src_len;
- }
tmp = b_strndup(src + start, end - start);
parsed = blogc_content_parse_inline(tmp);
b_string_append_printf(rv, "<p>%s</p>%s", parsed,
@@ -1172,10 +969,5 @@ para:
current++;
}
- free(directive_name);
- free(directive_argument);
- free(directive_key);
- b_trie_free(directive_params);
-
return b_string_free(rv, false);
}
diff --git a/src/directives.c b/src/directives.c
deleted file mode 100644
index 7a6b47f..0000000
--- a/src/directives.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * blogc: A blog compiler.
- * Copyright (C) 2015 Rafael G. Martins <rafael@rafaelmartins.eng.br>
- *
- * This program can be distributed under the terms of the BSD License.
- * See the file LICENSE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#include "utils/utils.h"
-
-
-char*
-blogc_directive_loader(const char *name, const char *argument, b_trie_t *params)
-{
- // TODO: implement me!
- return b_strdup("TODO\n");
-}
diff --git a/src/directives.h b/src/directives.h
deleted file mode 100644
index fa758e2..0000000
--- a/src/directives.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * blogc: A blog compiler.
- * Copyright (C) 2015 Rafael G. Martins <rafael@rafaelmartins.eng.br>
- *
- * This program can be distributed under the terms of the BSD License.
- * See the file LICENSE.
- */
-
-#ifndef _DIRECTIVES_H
-#define _DIRECTIVES_H
-
-#include "utils/utils.h"
-
-char* blogc_directive_loader(const char *name, const char *argument,
- b_trie_t *params);
-
-#endif /* _DIRECTIVES_H */
diff --git a/tests/check_content_parser.c b/tests/check_content_parser.c
index 5d13564..994e900 100644
--- a/tests/check_content_parser.c
+++ b/tests/check_content_parser.c
@@ -1014,405 +1014,6 @@ test_content_parse_ordered_list_crlf(void **state)
}
-char*
-__wrap_blogc_directive_loader(const char *name, const char *argument,
- b_trie_t *params)
-{
- assert_string_equal(name, mock_type(const char*));
- const char *arg = mock_type(const char*);
- if (arg == NULL)
- assert_null(argument);
- else
- assert_string_equal(argument, arg);
- assert_int_equal(b_trie_size(params), mock_type(unsigned int));
-
- for (unsigned int i = 0; i < b_trie_size(params); i++)
- assert_string_equal(b_trie_lookup(params, mock_type(const char*)),
- mock_type(const char*));
-
- return b_strdup("CHUNDA\n");
-}
-
-
-static void
-test_content_parse_directive(void **state)
-{
- will_return(__wrap_blogc_directive_loader, "bola");
- will_return(__wrap_blogc_directive_loader, NULL);
- will_return(__wrap_blogc_directive_loader, 0);
- char *html = blogc_content_parse(
- ".. bola::",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "CHUNDA\n");
- free(html);
-
- will_return(__wrap_blogc_directive_loader, "bola");
- will_return(__wrap_blogc_directive_loader, NULL);
- will_return(__wrap_blogc_directive_loader, 0);
- html = blogc_content_parse(
- ".. bola::\n",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "CHUNDA\n");
- free(html);
-
- will_return(__wrap_blogc_directive_loader, "bola");
- will_return(__wrap_blogc_directive_loader, NULL);
- will_return(__wrap_blogc_directive_loader, 0);
- html = blogc_content_parse(
- ".. bola:: ",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "CHUNDA\n");
- free(html);
-
- will_return(__wrap_blogc_directive_loader, "bola");
- will_return(__wrap_blogc_directive_loader, NULL);
- will_return(__wrap_blogc_directive_loader, 0);
- html = blogc_content_parse(
- ".. bola:: \n",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "CHUNDA\n");
- free(html);
-
- will_return(__wrap_blogc_directive_loader, "bola");
- will_return(__wrap_blogc_directive_loader, NULL);
- will_return(__wrap_blogc_directive_loader, 0);
- html = blogc_content_parse(
- ".. bola::\r\n",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "CHUNDA\n");
- free(html);
-
- will_return(__wrap_blogc_directive_loader, "bola");
- will_return(__wrap_blogc_directive_loader, NULL);
- will_return(__wrap_blogc_directive_loader, 1);
- will_return(__wrap_blogc_directive_loader, "asd");
- will_return(__wrap_blogc_directive_loader, "qwe");
- html = blogc_content_parse(
- ".. bola::\n"
- " :asd: qwe",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "CHUNDA\n");
- free(html);
-
- will_return(__wrap_blogc_directive_loader, "bola");
- will_return(__wrap_blogc_directive_loader, NULL);
- will_return(__wrap_blogc_directive_loader, 1);
- will_return(__wrap_blogc_directive_loader, "asd");
- will_return(__wrap_blogc_directive_loader, "qwe");
- html = blogc_content_parse(
- ".. bola::\n"
- " :asd: qwe\n",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "CHUNDA\n");
- free(html);
-
- will_return(__wrap_blogc_directive_loader, "bola");
- will_return(__wrap_blogc_directive_loader, NULL);
- will_return(__wrap_blogc_directive_loader, 1);
- will_return(__wrap_blogc_directive_loader, "asd");
- will_return(__wrap_blogc_directive_loader, "qwe");
- html = blogc_content_parse(
- ".. bola::\r\n"
- " :asd: qwe\r\n",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "CHUNDA\n");
- free(html);
-
- will_return(__wrap_blogc_directive_loader, "bola");
- will_return(__wrap_blogc_directive_loader, NULL);
- will_return(__wrap_blogc_directive_loader, 2);
- will_return(__wrap_blogc_directive_loader, "asd");
- will_return(__wrap_blogc_directive_loader, "qwe");
- will_return(__wrap_blogc_directive_loader, "zxc");
- will_return(__wrap_blogc_directive_loader, "vbn");
- html = blogc_content_parse(
- ".. bola::\n"
- " :asd: qwe\n"
- " :zxc: vbn",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "CHUNDA\n");
- free(html);
-
- will_return(__wrap_blogc_directive_loader, "bola");
- will_return(__wrap_blogc_directive_loader, NULL);
- will_return(__wrap_blogc_directive_loader, 2);
- will_return(__wrap_blogc_directive_loader, "asd");
- will_return(__wrap_blogc_directive_loader, "qwe");
- will_return(__wrap_blogc_directive_loader, "zxc");
- will_return(__wrap_blogc_directive_loader, "vbn");
- html = blogc_content_parse(
- ".. bola::\n"
- " :asd: qwe\n"
- " :zxc: vbn\n",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "CHUNDA\n");
- free(html);
-
- will_return(__wrap_blogc_directive_loader, "bola");
- will_return(__wrap_blogc_directive_loader, NULL);
- will_return(__wrap_blogc_directive_loader, 2);
- will_return(__wrap_blogc_directive_loader, "asd");
- will_return(__wrap_blogc_directive_loader, "qwe");
- will_return(__wrap_blogc_directive_loader, "zxc");
- will_return(__wrap_blogc_directive_loader, "vbn");
- html = blogc_content_parse(
- ".. bola::\r\n"
- " :asd: qwe\r\n"
- " :zxc: vbn\r\n",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "CHUNDA\n");
- free(html);
-
- will_return(__wrap_blogc_directive_loader, "bola");
- will_return(__wrap_blogc_directive_loader, NULL);
- will_return(__wrap_blogc_directive_loader, 3);
- will_return(__wrap_blogc_directive_loader, "asd");
- will_return(__wrap_blogc_directive_loader, "qwe");
- will_return(__wrap_blogc_directive_loader, "ert");
- will_return(__wrap_blogc_directive_loader, "zxvc");
- will_return(__wrap_blogc_directive_loader, "qwe");
- will_return(__wrap_blogc_directive_loader, "bola");
- html = blogc_content_parse(
- "# foo\n"
- "\n"
- ".. bola::\n"
- " :asd: qwe\n"
- " :ert: zxvc\n"
- " :qwe: bola\n"
- "\n"
- "bola", NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<h1 id=\"foo\">foo</h1>\n"
- "CHUNDA\n"
- "<p>bola</p>\n");
- free(html);
-
- will_return(__wrap_blogc_directive_loader, "bola");
- will_return(__wrap_blogc_directive_loader, NULL);
- will_return(__wrap_blogc_directive_loader, 3);
- will_return(__wrap_blogc_directive_loader, "asd");
- will_return(__wrap_blogc_directive_loader, "qwe");
- will_return(__wrap_blogc_directive_loader, "ert");
- will_return(__wrap_blogc_directive_loader, "zxvc");
- will_return(__wrap_blogc_directive_loader, "qwe");
- will_return(__wrap_blogc_directive_loader, "bola");
- html = blogc_content_parse(
- "# foo\r\n"
- "\r\n"
- ".. bola::\r\n"
- " :asd: qwe\r\n"
- " :ert: zxvc\r\n"
- " :qwe: bola\r\n"
- "\r\n"
- "bola", NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<h1 id=\"foo\">foo</h1>\r\n"
- "CHUNDA\n"
- "<p>bola</p>\r\n");
- free(html);
-
- will_return(__wrap_blogc_directive_loader, "bola");
- will_return(__wrap_blogc_directive_loader, "chunda");
- will_return(__wrap_blogc_directive_loader, 0);
- html = blogc_content_parse(
- ".. bola:: chunda",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "CHUNDA\n");
- free(html);
-
- will_return(__wrap_blogc_directive_loader, "bola");
- will_return(__wrap_blogc_directive_loader, "chunda");
- will_return(__wrap_blogc_directive_loader, 0);
- html = blogc_content_parse(
- ".. bola:: chunda\n",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "CHUNDA\n");
- free(html);
-
- will_return(__wrap_blogc_directive_loader, "bola");
- will_return(__wrap_blogc_directive_loader, "chunda");
- will_return(__wrap_blogc_directive_loader, 0);
- html = blogc_content_parse(
- ".. bola:: chunda\r\n",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "CHUNDA\n");
- free(html);
-
- will_return(__wrap_blogc_directive_loader, "bola");
- will_return(__wrap_blogc_directive_loader, "chunda");
- will_return(__wrap_blogc_directive_loader, 1);
- will_return(__wrap_blogc_directive_loader, "asd");
- will_return(__wrap_blogc_directive_loader, "qwe");
- html = blogc_content_parse(
- ".. bola:: chunda\n"
- " :asd: qwe",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "CHUNDA\n");
- free(html);
-
- will_return(__wrap_blogc_directive_loader, "bola");
- will_return(__wrap_blogc_directive_loader, "chunda");
- will_return(__wrap_blogc_directive_loader, 1);
- will_return(__wrap_blogc_directive_loader, "asd");
- will_return(__wrap_blogc_directive_loader, "qwe");
- html = blogc_content_parse(
- ".. bola:: chunda\n"
- " :asd: qwe\n",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "CHUNDA\n");
- free(html);
-
- will_return(__wrap_blogc_directive_loader, "bola");
- will_return(__wrap_blogc_directive_loader, "chunda");
- will_return(__wrap_blogc_directive_loader, 1);
- will_return(__wrap_blogc_directive_loader, "asd");
- will_return(__wrap_blogc_directive_loader, "qwe");
- html = blogc_content_parse(
- ".. bola:: chunda\r\n"
- " :asd: qwe\r\n",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "CHUNDA\n");
- free(html);
-
- will_return(__wrap_blogc_directive_loader, "bola");
- will_return(__wrap_blogc_directive_loader, "chunda");
- will_return(__wrap_blogc_directive_loader, 2);
- will_return(__wrap_blogc_directive_loader, "asd");
- will_return(__wrap_blogc_directive_loader, "qwe");
- will_return(__wrap_blogc_directive_loader, "zxc");
- will_return(__wrap_blogc_directive_loader, "vbn");
- html = blogc_content_parse(
- ".. bola:: chunda\n"
- " :asd: qwe\n"
- " :zxc: vbn",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "CHUNDA\n");
- free(html);
-
- will_return(__wrap_blogc_directive_loader, "bola");
- will_return(__wrap_blogc_directive_loader, "chunda");
- will_return(__wrap_blogc_directive_loader, 2);
- will_return(__wrap_blogc_directive_loader, "asd");
- will_return(__wrap_blogc_directive_loader, "qwe");
- will_return(__wrap_blogc_directive_loader, "zxc");
- will_return(__wrap_blogc_directive_loader, "vbn");
- html = blogc_content_parse(
- ".. bola:: chunda\n"
- " :asd: qwe\n"
- " :zxc: vbn\n",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "CHUNDA\n");
- free(html);
-
- will_return(__wrap_blogc_directive_loader, "bola");
- will_return(__wrap_blogc_directive_loader, "chunda");
- will_return(__wrap_blogc_directive_loader, 2);
- will_return(__wrap_blogc_directive_loader, "asd");
- will_return(__wrap_blogc_directive_loader, "qwe");
- will_return(__wrap_blogc_directive_loader, "zxc");
- will_return(__wrap_blogc_directive_loader, "vbn");
- html = blogc_content_parse(
- ".. bola:: chunda\r\n"
- " :asd: qwe\r\n"
- " :zxc: vbn\r\n",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "CHUNDA\n");
- free(html);
-
- will_return(__wrap_blogc_directive_loader, "bola");
- will_return(__wrap_blogc_directive_loader, "chunda");
- will_return(__wrap_blogc_directive_loader, 3);
- will_return(__wrap_blogc_directive_loader, "asd");
- will_return(__wrap_blogc_directive_loader, "qwe");
- will_return(__wrap_blogc_directive_loader, "ert");
- will_return(__wrap_blogc_directive_loader, "zxvc");
- will_return(__wrap_blogc_directive_loader, "qwe");
- will_return(__wrap_blogc_directive_loader, "bola");
- html = blogc_content_parse(
- "# foo\n"
- "\n"
- ".. bola:: chunda\n"
- " :asd: qwe\n"
- " :ert: zxvc\n"
- " :qwe: bola\n"
- "\n"
- "bola", NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<h1 id=\"foo\">foo</h1>\n"
- "CHUNDA\n"
- "<p>bola</p>\n");
- free(html);
-
- will_return(__wrap_blogc_directive_loader, "bola");
- will_return(__wrap_blogc_directive_loader, "chunda");
- will_return(__wrap_blogc_directive_loader, 3);
- will_return(__wrap_blogc_directive_loader, "asd");
- will_return(__wrap_blogc_directive_loader, "qwe");
- will_return(__wrap_blogc_directive_loader, "ert");
- will_return(__wrap_blogc_directive_loader, "zxvc");
- will_return(__wrap_blogc_directive_loader, "qwe");
- will_return(__wrap_blogc_directive_loader, "bola");
- html = blogc_content_parse(
- "# foo\r\n"
- "\r\n"
- ".. bola:: chunda\r\n"
- " :asd: qwe\r\n"
- " :ert: zxvc\r\n"
- " :qwe: bola\r\n"
- "\r\n"
- "bola", NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<h1 id=\"foo\">foo</h1>\r\n"
- "CHUNDA\n"
- "<p>bola</p>\r\n");
- free(html);
-}
-
-
static void
test_content_parse_invalid_excerpt(void **state)
{
@@ -1534,14 +1135,6 @@ test_content_parse_invalid_blockquote(void **state)
"&gt; bola\n"
"&gt; foo</p>\n");
free(html);
- html = blogc_content_parse(
- "> asd\n"
- "> bola", NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<p>&gt; asd\n"
- "&gt; bola</p>\n");
- free(html);
}
@@ -1558,16 +1151,6 @@ test_content_parse_invalid_code(void **state)
" bola\n"
" foo</p>\n");
free(html);
- html = blogc_content_parse(
- " asd\n"
- " bola\n"
- " foo", NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<p> asd\n"
- " bola\n"
- " foo</p>\n");
- free(html);
}
@@ -1613,8 +1196,7 @@ test_content_parse_invalid_unordered_list(void **state)
assert_non_null(html);
assert_string_equal(html,
"<p><em> asd\n"
- "1. qwe"
- "</p>\n");
+ "1. qwe</p>\n");
free(html);
html = blogc_content_parse(
"* asd\n"
@@ -1622,8 +1204,7 @@ test_content_parse_invalid_unordered_list(void **state)
assert_non_null(html);
assert_string_equal(html,
"<p><em> asd\n"
- "1. qwe"
- "</p>\n");
+ "1. qwe</p>\n");
free(html);
html = blogc_content_parse(
"chunda\n"
@@ -1669,8 +1250,7 @@ test_content_parse_invalid_ordered_list(void **state)
assert_non_null(html);
assert_string_equal(html,
"<p>1. asd\n"
- "<em> qwe"
- "</p>\n");
+ "<em> qwe</p>\n");
free(html);
html = blogc_content_parse(
"1. asd\n"
@@ -1678,8 +1258,7 @@ test_content_parse_invalid_ordered_list(void **state)
assert_non_null(html);
assert_string_equal(html,
"<p>1. asd\n"
- "<em> qwe"
- "</p>\n");
+ "<em> qwe</p>\n");
free(html);
html = blogc_content_parse(
"chunda\n"
@@ -1724,195 +1303,6 @@ test_content_parse_invalid_ordered_list(void **state)
assert_non_null(html);
assert_string_equal(html, "<p>1.</p>\n");
free(html);
- html = blogc_content_parse("1 ", NULL);
- assert_non_null(html);
- assert_string_equal(html, "<p>1 </p>\n");
- free(html);
-}
-
-
-static void
-test_content_parse_invalid_directive(void **state)
-{
- char *html = blogc_content_parse(
- ".. ",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<p>.. </p>\n");
- free(html);
-
- html = blogc_content_parse(
- ".. \n",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<p>.. </p>\n");
- free(html);
-
- html = blogc_content_parse(
- ".. ",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<p>.. <br /></p>\n");
- free(html);
-
- html = blogc_content_parse(
- ".. \n",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<p>.. <br /></p>\n");
- free(html);
-
- html = blogc_content_parse(
- ".. a",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<p>.. a</p>\n");
- free(html);
-
- html = blogc_content_parse(
- ".. a\n",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<p>.. a</p>\n");
- free(html);
-
- html = blogc_content_parse(
- ".. asd",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<p>.. asd</p>\n");
- free(html);
-
- html = blogc_content_parse(
- ".. asd\n",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<p>.. asd</p>\n");
- free(html);
-
- html = blogc_content_parse(
- ".. asd:",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<p>.. asd:</p>\n");
- free(html);
-
- html = blogc_content_parse(
- ".. asd:\n",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<p>.. asd:</p>\n");
- free(html);
-
- html = blogc_content_parse(
- ".. asd::\n"
- " :",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<p>.. asd::\n"
- " :</p>\n");
- free(html);
-
- html = blogc_content_parse(
- ".. asd::\n"
- " :\n",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<p>.. asd::\n"
- " :</p>\n");
- free(html);
-
- html = blogc_content_parse(
- ".. asd::\n"
- " :a",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<p>.. asd::\n"
- " :a</p>\n");
- free(html);
-
- html = blogc_content_parse(
- ".. asd::\n"
- " :a\n",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<p>.. asd::\n"
- " :a</p>\n");
- free(html);
-
- html = blogc_content_parse(
- ".. asd::\n"
- " :as",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<p>.. asd::\n"
- " :as</p>\n");
- free(html);
-
- html = blogc_content_parse(
- ".. asd::\n"
- " :as\n",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<p>.. asd::\n"
- " :as</p>\n");
- free(html);
-
- html = blogc_content_parse(
- ".. asd::\n"
- " :as:",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<p>.. asd::\n"
- " :as:</p>\n");
- free(html);
-
- html = blogc_content_parse(
- ".. asd::\n"
- " :as:\n",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<p>.. asd::\n"
- " :as:</p>\n");
- free(html);
-
- html = blogc_content_parse(
- ".. asd::\n"
- " :as: ",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<p>.. asd::\n"
- " :as: </p>\n");
- free(html);
-
- html = blogc_content_parse(
- ".. asd::\n"
- " :as: \n",
- NULL);
- assert_non_null(html);
- assert_string_equal(html,
- "<p>.. asd::\n"
- " :as: </p>\n");
- free(html);
}
@@ -2266,7 +1656,6 @@ main(void)
unit_test(test_content_parse_unordered_list_crlf),
unit_test(test_content_parse_ordered_list),
unit_test(test_content_parse_ordered_list_crlf),
- unit_test(test_content_parse_directive),
unit_test(test_content_parse_invalid_excerpt),
unit_test(test_content_parse_invalid_header),
unit_test(test_content_parse_invalid_header_empty),
@@ -2275,7 +1664,6 @@ main(void)
unit_test(test_content_parse_invalid_horizontal_rule),
unit_test(test_content_parse_invalid_unordered_list),
unit_test(test_content_parse_invalid_ordered_list),
- unit_test(test_content_parse_invalid_directive),
unit_test(test_content_parse_inline),
unit_test(test_content_parse_inline_em),
unit_test(test_content_parse_inline_strong),