Custom index heading with optional id
This commit is contained in:
parent
f79292d9f3
commit
ca9017342b
38
srohtml.c
38
srohtml.c
|
@ -75,7 +75,7 @@ static void cmd_fi(const char *line);
|
||||||
static void cmd_h(const char *line);
|
static void cmd_h(const char *line);
|
||||||
static void cmd_hr(void);
|
static void cmd_hr(void);
|
||||||
static void cmd_i(const char *line);
|
static void cmd_i(const char *line);
|
||||||
static void cmd_in();
|
static void cmd_in(const char *line);
|
||||||
static void cmd_la(const char *line);
|
static void cmd_la(const char *line);
|
||||||
static void cmd_le(void);
|
static void cmd_le(void);
|
||||||
static void cmd_ls(void);
|
static void cmd_ls(void);
|
||||||
|
@ -115,6 +115,8 @@ string head;
|
||||||
size_t heading_position = 0;
|
size_t heading_position = 0;
|
||||||
int imgs_presence = 0;
|
int imgs_presence = 0;
|
||||||
int indentation = 2;
|
int indentation = 2;
|
||||||
|
char *index_heading = NULL;
|
||||||
|
char *index_heading_id = NULL;
|
||||||
size_t index_position = 0;
|
size_t index_position = 0;
|
||||||
char *language = NULL;
|
char *language = NULL;
|
||||||
int licence_container = 0;
|
int licence_container = 0;
|
||||||
|
@ -225,7 +227,7 @@ cmd(char *line)
|
||||||
else if (!strncmp(line, "I", cmdlen))
|
else if (!strncmp(line, "I", cmdlen))
|
||||||
cmd_i(line);
|
cmd_i(line);
|
||||||
else if (!strncmp(line, "IN", cmdlen))
|
else if (!strncmp(line, "IN", cmdlen))
|
||||||
cmd_in();
|
cmd_in(line);
|
||||||
else if (!strncmp(line, "LA", cmdlen))
|
else if (!strncmp(line, "LA", cmdlen))
|
||||||
cmd_la(line);
|
cmd_la(line);
|
||||||
else if (!strncmp(line, "LE", cmdlen))
|
else if (!strncmp(line, "LE", cmdlen))
|
||||||
|
@ -407,6 +409,7 @@ cmd_fi(const char *line)
|
||||||
string_cat(&body, "\" alt=\"\"></figure>");
|
string_cat(&body, "\" alt=\"\"></figure>");
|
||||||
imgs_presence = 1;
|
imgs_presence = 1;
|
||||||
|
|
||||||
|
free(ind);
|
||||||
free(src);
|
free(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,8 +465,23 @@ cmd_i(const char *line)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_in(void)
|
cmd_in(const char *line)
|
||||||
{
|
{
|
||||||
|
/* move past "IN" */
|
||||||
|
line += 2;
|
||||||
|
/* move past arguments, once found them */
|
||||||
|
line += stread_param(line, &index_heading);
|
||||||
|
line += stread_param(line, &index_heading_id);
|
||||||
|
|
||||||
|
if (!strcmp(index_heading, "")) {
|
||||||
|
free(index_heading);
|
||||||
|
index_heading = NULL;
|
||||||
|
}
|
||||||
|
if (!strcmp(index_heading_id, "")) {
|
||||||
|
free(index_heading_id);
|
||||||
|
index_heading_id = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
index_position = strlen(body.str);
|
index_position = strlen(body.str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1019,8 +1037,20 @@ nav_index(FILE *f)
|
||||||
fputs("<nav>\n", f);
|
fputs("<nav>\n", f);
|
||||||
findent(ind, f);
|
findent(ind, f);
|
||||||
fputs("<hr>\n", f);
|
fputs("<hr>\n", f);
|
||||||
|
if (index_heading != NULL) {
|
||||||
findent(ind, f);
|
findent(ind, f);
|
||||||
fputs("<h3 id=\"indice\">Indice</h3>\n", f);
|
fputs("<h3", f);
|
||||||
|
if (index_heading_id != NULL) {
|
||||||
|
fputs(" id=\"", f);
|
||||||
|
fputs_html(index_heading_id, f, tag_attribute);
|
||||||
|
fputs("\"", f);
|
||||||
|
free(index_heading_id);
|
||||||
|
}
|
||||||
|
fputs(">", f);
|
||||||
|
fputs_html(index_heading, f, tag_content);
|
||||||
|
fputs("</h3>\n", f);
|
||||||
|
free(index_heading);
|
||||||
|
}
|
||||||
for (i = 0; i < page_index.index; i++) {
|
for (i = 0; i < page_index.index; i++) {
|
||||||
title = page_index.titles + i;
|
title = page_index.titles + i;
|
||||||
next_title = i == page_index.index - 1 ? NULL : title + 1;
|
next_title = i == page_index.index - 1 ? NULL : title + 1;
|
||||||
|
|
Loading…
Reference in New Issue