if (text && text->child) {
temp_char = label_from_token(source, text);
- if (strcmp(temp_char, &(link->url[1])) == 0) {
- // [bar][bar] or [bar](#bar) or [bar]
- printf("\\autoref{%s}", &(link->url)[1]);
- } else {
+ if (temp_char && temp_char[0] != '\0') {
mmd_export_token_tree_latex(out, source, text->child, scratch);
print_const(" (");
printf("\\autoref{%s}", &(link->url)[1]);
print_const(")");
+ } else {
+ printf("\\autoref{%s}", &(link->url)[1]);
}
free(temp_char);
}
-link * link_new(const char * source, token * label, char * url, char * title, char * attributes) {
+link * link_new(const char * source, token * label, char * url, char * title, char * attributes, short flags) {
link * l = malloc(sizeof(link));
if (l) {
l->url = clean_string(url, false);
l->title = (title == NULL) ? NULL : my_strdup(title);
l->attributes = (attributes == NULL) ? NULL : parse_attributes(attributes);
+
+ l->flags = flags;
}
return l;
}
-/// Create a link from an explicit link `[foo](bar)`
+/// Create a link from an explicit "inline" link `[foo](bar)`
link * explicit_link(scratch_pad * scratch, token * bracket, token * paren, const char * source) {
char * url_char = NULL;
char * title_char = NULL;
if (attr_char) {
if (!(scratch->extensions & EXT_COMPATIBILITY)) {
- l = link_new(source, NULL, url_char, title_char, attr_char);
+ l = link_new(source, NULL, url_char, title_char, attr_char, LINK_INLINE);
}
} else {
- l = link_new(source, NULL, url_char, title_char, attr_char);
+ l = link_new(source, NULL, url_char, title_char, attr_char, LINK_INLINE);
}
free(url_char);
}
}
- l = link_new(e->dstr->str, label, url_char, title_char, attr_char);
+ l = link_new(e->dstr->str, label, url_char, title_char, attr_char, LINK_REFERENCE);
} else {
// Not valid match
}
} else {
- l = link_new(e->dstr->str, label, url_char, title_char, attr_char);
+ l = link_new(e->dstr->str, label, url_char, title_char, attr_char, LINK_REFERENCE);
}
// Store link for later use
d_string_append(url, label);
- link * l = link_new(e->dstr->str, h, url->str, NULL, NULL);
+ link * l = link_new(e->dstr->str, h, url->str, NULL, NULL, LINK_AUTO);
// Store link for later use
stack_push(e->link_stack, l);
DString * url = d_string_new("#");
d_string_append(url, label);
- link * l = link_new(e->dstr->str, temp_token, url->str, NULL, NULL);
+ link * l = link_new(e->dstr->str, temp_token, url->str, NULL, NULL, LINK_AUTO);
stack_push(e->link_stack, l);