if(link && link->href.size > 0) {
node->link = cx_strdup_a(data->a, cx_strn(link->href.text, link->href.size));
}
+ } else if(type == MD_SPAN_IMG) {
+ MD_SPAN_IMG_DETAIL *img = detail;
+ if(img) {
+ node->link = cx_strdup_a(data->a, cx_strn(img->src.text, img->src.size));
+ }
}
return 0;
// if the previous node is a text node, we can merge the nodes
// there are 2 cases: the root node is a text node (current->text.ptr)
// or the current node is not a text node, but has text children
- if(current) {
+ if(current) {
MDNode *prev_text_node = NULL;
if(current->text.ptr) {
prev_text_node = current;
if(n->text.ptr) {
cxBufferWrite(n->text.ptr, 1, n->text.length, buf);
+ } else if(n->type == MD_SPAN_IMG) {
+ MDDocStyleSection sec;
+ sec.pos = buf->pos;
+ sec.length = MDDocStyleSection_IMAGE;
+ sec.style = n->children_begin ? n->children_begin->text.ptr : NULL;
+ sec.link = n->link.ptr;
+ cxListAdd(sections, &sec);
} else {
size_t start_pos = buf->pos;
#define EDITOR_STYLE_STRONG "strong"
#define EDITOR_STYLE_CODE "code"
#define EDITOR_STYLE_LINK "link"
+
+#define MDDocStyleSection_IMAGE -1
#define MD_MAX_DEPTH 50
CxIterator i = cxListIterator(styles);
cx_foreach(MDDocStyleSection*, sec, i) {
+ if(sec->length == MDDocStyleSection_IMAGE) {
+ // TODO: insert image
+ continue;
+ }
+
GtkTextIter begin, end;
gtk_text_buffer_get_iter_at_offset(buffer, &begin, sec->pos);
gtk_text_buffer_get_iter_at_offset(buffer, &end, sec->pos + sec->length);