mirror of
https://github.com/Orc/discount.git
synced 2026-09-25 04:10:00 +03:00
add the new runtime flag ALT_AS_TITLE; if an image has no title, use the alt text as the title
This commit is contained in:
@@ -37,6 +37,7 @@ static struct flagnames flagnames[] = {
|
|||||||
{ MKD_URLENCODEDANCHOR, "URLENCODEDANCHOR" },
|
{ MKD_URLENCODEDANCHOR, "URLENCODEDANCHOR" },
|
||||||
{ MKD_LATEX, "LATEX" },
|
{ MKD_LATEX, "LATEX" },
|
||||||
{ MKD_EXPLICITLIST, "EXPLICITLIST" },
|
{ MKD_EXPLICITLIST, "EXPLICITLIST" },
|
||||||
|
{ MKD_ALT_AS_TITLE, "ALT_AS_TITLE" },
|
||||||
};
|
};
|
||||||
#define NR(x) (sizeof x/sizeof x[0])
|
#define NR(x) (sizeof x/sizeof x[0])
|
||||||
|
|
||||||
|
|||||||
+9
-4
@@ -559,7 +559,9 @@ typedef struct linkytype {
|
|||||||
} linkytype;
|
} linkytype;
|
||||||
|
|
||||||
static linkytype imaget = { 0, 0, "<img src=\"", "\"",
|
static linkytype imaget = { 0, 0, "<img src=\"", "\"",
|
||||||
1, " alt=\"", "\" />", { { [MKD_NOIMAGE] = 1, [MKD_TAGTEXT] = 1} }, IS_URL };
|
1, " alt=\"", "\" />", { { [MKD_NOIMAGE] = 1,
|
||||||
|
[MKD_TAGTEXT] = 1,
|
||||||
|
[MKD_ALT_AS_TITLE] = 1 } }, IS_URL };
|
||||||
static linkytype linkt = { 0, 0, "<a href=\"", "\"",
|
static linkytype linkt = { 0, 0, "<a href=\"", "\"",
|
||||||
0, ">", "</a>", { {[MKD_NOLINKS] = 1} }, IS_URL };
|
0, ">", "</a>", { {[MKD_NOLINKS] = 1} }, IS_URL };
|
||||||
|
|
||||||
@@ -652,7 +654,7 @@ extra_linky(MMIOT *f, Cstring text, Footnote *ref)
|
|||||||
if ( ref->fn_flags & REFERENCED )
|
if ( ref->fn_flags & REFERENCED )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if ( is_flag_set(&f->flags,IS_LABEL) )
|
if ( is_flag_set(&f->flags, IS_LABEL) )
|
||||||
___mkd_reparse(T(text), S(text), &(linkt.flags), f, 0);
|
___mkd_reparse(T(text), S(text), &(linkt.flags), f, 0);
|
||||||
else {
|
else {
|
||||||
ref->fn_flags |= REFERENCED;
|
ref->fn_flags |= REFERENCED;
|
||||||
@@ -728,9 +730,12 @@ linkyformat(MMIOT *f, Cstring text, int image, Footnote *ref)
|
|||||||
if ( ref->width ) Qprintf(f, " width=\"%d\"", ref->width);
|
if ( ref->width ) Qprintf(f, " width=\"%d\"", ref->width);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( S(ref->title) ) {
|
if ( S(ref->title) || (is_flag_set(&f->flags, MKD_ALT_AS_TITLE) && is_flag_set(&tag->flags, MKD_ALT_AS_TITLE)) ) {
|
||||||
Qstring(" title=\"", f);
|
Qstring(" title=\"", f);
|
||||||
___mkd_reparse(T(ref->title), S(ref->title), &tagtext, f, 0);
|
if ( S(ref->title) )
|
||||||
|
___mkd_reparse(T(ref->title), S(ref->title), &tagtext, f, 0);
|
||||||
|
else
|
||||||
|
___mkd_reparse(T(text), S(text), &tagtext, f, 0);
|
||||||
Qchar('"', f);
|
Qchar('"', f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ enum { MKD_NOLINKS=0, /* don't do link processing, block <a> tags */
|
|||||||
MKD_GITHUBTAGS, /* allow dash and underscore in element names */
|
MKD_GITHUBTAGS, /* allow dash and underscore in element names */
|
||||||
MKD_URLENCODEDANCHOR, /* urlencode non-identifier chars instead of replacing with dots */
|
MKD_URLENCODEDANCHOR, /* urlencode non-identifier chars instead of replacing with dots */
|
||||||
MKD_LATEX, /* handle embedded LaTeX escapes */
|
MKD_LATEX, /* handle embedded LaTeX escapes */
|
||||||
|
MKD_ALT_AS_TITLE, /* use alt text as the title if no title is listed */
|
||||||
/* end of user flags */
|
/* end of user flags */
|
||||||
IS_LABEL,
|
IS_LABEL,
|
||||||
MKD_NR_FLAGS };
|
MKD_NR_FLAGS };
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ enum { MKD_NOLINKS=0, /* don't do link processing, block <a> tags */
|
|||||||
MKD_GITHUBTAGS, /* allow dash and underscore in element names */
|
MKD_GITHUBTAGS, /* allow dash and underscore in element names */
|
||||||
MKD_URLENCODEDANCHOR, /* urlencode non-identifier chars instead of replacing with dots */
|
MKD_URLENCODEDANCHOR, /* urlencode non-identifier chars instead of replacing with dots */
|
||||||
MKD_LATEX, /* handle embedded LaTeX escapes */
|
MKD_LATEX, /* handle embedded LaTeX escapes */
|
||||||
|
MKD_ALT_AS_TITLE, /* use alt text as the title if no title is listed */
|
||||||
MKD_NR_FLAGS };
|
MKD_NR_FLAGS };
|
||||||
|
|
||||||
/* abstract flag type */
|
/* abstract flag type */
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ static struct _opt {
|
|||||||
{ "regular-listitem","github-style check items", 0, 0, 1, 1, MKD_NORMAL_LISTITEM } ,
|
{ "regular-listitem","github-style check items", 0, 0, 1, 1, MKD_NORMAL_LISTITEM } ,
|
||||||
{ "definitionlist","both discount & markdown extra definition lists", 1 },
|
{ "definitionlist","both discount & markdown extra definition lists", 1 },
|
||||||
{ "dlist", "both discount & markdown extra definition lists", 1, 0, 1 },
|
{ "dlist", "both discount & markdown extra definition lists", 1, 0, 1 },
|
||||||
|
{ "alt_as_title", "use the alt text as a title if there isn't one (images)", 0, 0, 0, 1, MKD_ALT_AS_TITLE },
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
#define NR(x) (sizeof x / sizeof x[0])
|
#define NR(x) (sizeof x / sizeof x[0])
|
||||||
|
|||||||
Reference in New Issue
Block a user