#define MARKDOWN_H
/*
- * A implementation of markdown objects.
+ * An implementation of markdown objects.
+ * Copyright (C) 2014 Michael Goehler
+ *
+ * This file is part of mdp.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ *
+ * enum: line_bitmask which enumerates markdown formating bits
+ *
+ * struct: deck_t the root object representing a deck of slides
+ * struct: slide_t a linked list element of type slide contained in a deck
+ * struct: line_t a linked list element of type line contained in a slide
+ *
+ * function: new_deck to initialize a new deck
+ * function: new_slide to initialize a new linked list of type slide
+ * function: next_slide to extend a linked list of type slide by one element
+ * function: new_line to initialize a new linked list of type line
+ * function: next_line to extend a linked list of type line by one element
+ * function: free_line to free a line elements memory
+ * function: free_deck to free a deck's memory
*
*/
#include "cstring.h"
-
-#define SET_BIT(var, pos) ((var) |= (1<<(pos)))
-#define CLEAR_BIT(var, pos) ((var) &= (~(1<<(pos))))
-#define TOGGLE_BIT(var, pos) ((var) ^= (1<<(pos)))
-#define CHECK_BIT(var, pos) ((var) & (1<<(pos)))
+#include "bitops.h"
enum line_bitmask {
- IS_HEADER,
- IS_HEADER2,
+ IS_H1,
+ IS_H1_ATX,
+ IS_H2,
+ IS_H2_ATX,
IS_QUOTE,
IS_CODE,
- IS_LIST,
- IS_NUMLIST,
- IS_HR
+ IS_HR,
+ IS_UNORDERED_LIST_1,
+ IS_UNORDERED_LIST_2,
+ IS_UNORDERED_LIST_3,
+ IS_UNORDERED_LIST_EXT,
+ IS_CENTER,
+ IS_EMPTY
};
typedef struct _line_t {
struct _line_t *prev;
struct _line_t *next;
int bits;
+ int length;
int offset;
} line_t;
-typedef struct _page_t {
+typedef struct _slide_t {
line_t *line;
- struct _page_t *prev;
- struct _page_t *next;
-} page_t;
-
-typedef struct _document_t {
- line_t *title;
- line_t *author;
- line_t *date;
- page_t *page;
-} document_t;
-
-line_t *new_line() {
- line_t *x = malloc(sizeof(line_t));
- return x;
-}
-
-line_t *next_line(line_t *prev) {
- line_t *x = new_line();
- x->prev = prev;
- prev->next = x;
- return x;
-}
-
-page_t *new_page() {
- page_t *x = malloc(sizeof(page_t));
- return x;
-}
+ struct _slide_t *prev;
+ struct _slide_t *next;
+ int lines;
+} slide_t;
-page_t *next_page(page_t *prev) {
- page_t *x = new_page();
- x->prev = prev;
- prev->next = x;
- return x;
-}
+typedef struct _deck_t {
+ line_t *header;
+ slide_t *slide;
+ int slides;
+ int headers;
+} deck_t;
-document_t *new_document() {
- document_t *x = malloc(sizeof(document_t));
- return x;
-}
+line_t *new_line();
+line_t *next_line(line_t *prev);
+slide_t *new_slide();
+slide_t *next_slide(slide_t *prev);
+deck_t *new_deck();
+void free_line(line_t *l);
+void free_deck(deck_t *);
#endif // !defined( MARKDOWN_H )