aboutsummaryrefslogtreecommitdiffstats
path: root/src/content-parser.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/content-parser.h')
-rw-r--r--src/content-parser.h119
1 files changed, 115 insertions, 4 deletions
diff --git a/src/content-parser.h b/src/content-parser.h
index c1eaf2c..3a72317 100644
--- a/src/content-parser.h
+++ b/src/content-parser.h
@@ -14,14 +14,119 @@
#include "utils.h"
+/*
+ * Raw node
+ *
+ * +-----+
+ * | RAW | -> ...
+ * +-----+
+ *
+ */
+
+/*
+ * Header node
+ *
+ * +--------+
+ * | HEADER | -> ...
+ * +--------+
+ * |
+ * +-----+ +------+ +-----+
+ * | raw | -> | bold | -> | raw | -> ...
+ * +-----+ +------+ +-----+
+ *
+ */
+
+/*
+ * Blockquote node
+ *
+ * +------------+
+ * | BLOCKQUOTE | -> ...
+ * +------------+
+ * |
+ * +-----------+ +--------+ +-----------+
+ * | PARAGRAPH | -> | HEADER | -> | PARAGRAPH | -> ...
+ * +-----------+ +--------+ +-----------+
+ * |
+ * +-----+
+ * | raw | -> ...
+ * +-----+
+ *
+ */
+
+/*
+ * Code node
+ *
+ * +------+
+ * | CODE | -> ...
+ * +------+
+ *
+ */
+
+/*
+ * Horizontal rule node
+ *
+ * +-----------------+
+ * | HORIZONTAL_RULE | -> ...
+ * +-----------------+
+ *
+ */
+
+/*
+ * Unordered list node
+ *
+ * +----------------+
+ * | UNORDERED_LIST | -> ...
+ * +----------------+
+ * |
+ * +-----------+ +-----------+
+ * | LIST_ITEM | -> | LIST_ITEM | -> ...
+ * +-----------+ +-----------+
+ * |
+ * +-----+ +------+
+ * | raw | -> | bold | -> ...
+ * +-----+ +------+
+ *
+ */
+
+/*
+ * Ordered list node
+ *
+ * +--------------+
+ * | ORDERED_LIST | -> ...
+ * +--------------+
+ * |
+ * +-----------+ +-----------+
+ * | LIST_ITEM | -> | LIST_ITEM | -> ...
+ * +-----------+ +-----------+
+ * |
+ * +-----+ +------+
+ * | raw | -> | bold | -> ...
+ * +-----+ +------+
+ *
+ */
+
+/*
+ * Paragraph node
+ *
+ * +-----------+
+ * | PARAGRAPH | -> ...
+ * +-----------+
+ * |
+ * +-----+ +------+ +-----+
+ * | raw | -> | bold | -> | raw |
+ * +-----+ +------+ +-----+
+ *
+ */
+
+
typedef enum {
BLOGC_CONTENT_BLOCK = 1,
BLOGC_CONTENT_INLINE,
} blogc_content_node_type_t;
typedef enum {
- BLOGC_CONTENT_BLOCK_HEADER = 1,
- BLOGC_CONTENT_BLOCK_RAW,
+ BLOGC_CONTENT_BLOCK_RAW = 1,
+ BLOGC_CONTENT_BLOCK_HEADER,
BLOGC_CONTENT_BLOCK_BLOCKQUOTE,
BLOGC_CONTENT_BLOCK_CODE,
BLOGC_CONTENT_BLOCK_HORIZONTAL_RULE,
@@ -29,10 +134,12 @@ typedef enum {
BLOGC_CONTENT_BLOCK_ORDERED_LIST,
BLOGC_CONTENT_BLOCK_LIST_ITEM,
BLOGC_CONTENT_BLOCK_PARAGRAPH,
+ BLOGC_CONTENT_BLOCK_EXCERPT,
} blogc_content_block_type_t;
typedef enum {
- BLOGC_CONTENT_INLINE_LINK = 1,
+ BLOGC_CONTENT_INLINE_RAW = 1,
+ BLOGC_CONTENT_INLINE_LINK,
BLOGC_CONTENT_INLINE_IMAGE,
BLOGC_CONTENT_INLINE_BOLD,
BLOGC_CONTENT_INLINE_ITALIC,
@@ -57,7 +164,11 @@ char* blogc_htmlentities(const char *str);
char* blogc_fix_description(const char *paragraph);
char* blogc_content_parse_inline(const char *src);
bool blogc_is_ordered_list_item(const char *str, size_t prefix_len);
-char* blogc_content_parse(const char *src, size_t *end_excerpt,
+blogc_content_node_t* blogc_content_parse_ast(const char *src, char **nl);
+void blogc_content_free_ast(blogc_content_node_t *ast);
+char* blogc_content_parse(const char *src, char **excerpt, char **description);
+char* blogc_content_render_html(blogc_content_node_t *ast, char *nl, char **excerpt,
char **description);
+void blogc_content_debug(blogc_content_node_t *ast);
#endif /* _CONTENT_PARSER_H */