*/
static CxMap* tags2map(GSList *tags) {
CxMap *map = cxHashMapCreateSimple(CX_STORE_POINTERS);
+ int anon_tag = 0;
+ char buf[32];
while(tags) {
GtkTextTag *t = tags->data;
GValue name_value = G_VALUE_INIT;
const char *name = g_value_get_string(&name_value);
if(name) {
cxMapPut(map, name, t);
+ } else {
+ snprintf(buf, 32, "_%d", anon_tag++);
+ cxMapPut(map, buf, t);
}
tags = tags->next;
}
cxMapFree(prev_tags);
prev_tags = begin_tags;
+ TextLink *link = NULL;
// check all new tags and add tag prefix code
CxMapIterator i = cxMapIterator(new_tags);
cx_foreach(CxMapEntry *, entry, i) {
+ const char *name = entry->key->data;
MDTag *t = cxMapGet(markdown_tags, *entry->key);
if(t && t->begin) {
cxBufferPutString(&out, t->begin);
}
+ if(name[0] == '_') {
+ GtkTextTag *tag = entry->value;
+ link = g_object_get_data(G_OBJECT(tag), "link");
+ if(link) {
+ cxBufferPut(&out, '[');
+ }
+ }
}
cxMapFree(new_tags);
cxBufferPutString(&out, t->end);
}
}
+ if(link) {
+ cxBufferPutString(&out, "](");
+ cxBufferPutString(&out, link->link);
+ cxBufferPut(&out, ')');
+ }
cxMapFree(begin_tags2);
cxMapFree(end_tags);