document_t *new_document();
int is_utf8(char ch);
int next_nonblank(cstring_t *text, int i);
+int next_blank(cstring_t *text, int i);
document_t *markdown_load(FILE *input);
#endif // !defined( MARKDOWN_H )
}
}
- //TODO detect header
+ // detect header
+ line = doc->page->line;
+ if(line && line->text->size > 0 && line->text->text[0] == '%') {
+
+ // assign header to document
+ doc->header = line;
+
+ // find first non-header line
+ while(line->text->size > 0 && line->text->text[0] == '%') {
+ line = line->next;
+ }
+
+ // split linked list
+ line->prev->next = (void*)0;
+ line->prev = (void*)0;
+
+ // remove header lines from page
+ doc->page->line = line;
+ }
return doc;
}
return i;
};
+int next_blank(cstring_t *text, int i) {
+ while ((i < text->size) && !isspace((text->text)[i]))
+ ++i;
+ return i;
+};
+
-@title: Sample Presentation
-@author: Michael Göhler
-@date: 2014-08-07
+%title: Sample Presentation
+%author: Michael Göhler
+%date: 2014-08-07
Title
=====
doc = markdown_load(input);
// test line/page load
+ int offset;
+ line_t *header;
+ if(doc->header) {
+ header = doc->header;
+ while(header &&
+ header->text->size > 0 &&
+ header->text->text[0] == '%') {
+
+ offset = next_blank(header->text, 0) + 1;
+ printf("header: %s\n", &header->text->text[offset]);
+ header = header->next;
+ }
+ }
int cp = 0, cl = 0;
page_t *page = doc->page;
line_t *line;