HTML command names
This commit is contained in:
parent
3dcf820a24
commit
337061a3f4
180
srohtml.c
180
srohtml.c
|
@ -56,27 +56,26 @@ static void *array_push(array *a);
|
||||||
static char *array_strcat(array *dst, const char *src);
|
static char *array_strcat(array *dst, const char *src);
|
||||||
static char *array_strcat_html(array *dst, const char *src, const html_val_type t);
|
static char *array_strcat_html(array *dst, const char *src, const html_val_type t);
|
||||||
static void cmd(char *line);
|
static void cmd(char *line);
|
||||||
static void cmd_close(void);
|
|
||||||
static void cmd_a(const char *line);
|
static void cmd_a(const char *line);
|
||||||
static void cmd_au_de_ti(char **dst, const char *line);
|
static void cmd_au_de_ti(char **dst, const char *line);
|
||||||
static void cmd_br(void);
|
static void cmd_br(void);
|
||||||
static void cmd_dt(const char *line);
|
static void cmd_close(void);
|
||||||
static void cmd_em(const char *line);
|
static void cmd_em(const char *line);
|
||||||
static void cmd_fi(const char *line);
|
static void cmd_figure(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(const char *line);
|
static void cmd_index(const char *line);
|
||||||
static void cmd_la(const char *line);
|
static void cmd_lang(const char *line);
|
||||||
static void cmd_le(void);
|
static void cmd_license_end(void);
|
||||||
static void cmd_ls(void);
|
static void cmd_license_start(void);
|
||||||
static void cmd_no(const char *line);
|
static void cmd_note(const char *line);
|
||||||
static void cmd_p(void);
|
static void cmd_p(void);
|
||||||
static void cmd_pd(const char *line);
|
static void cmd_publication_date(const char *line);
|
||||||
static void cmd_q(const char *line);
|
static void cmd_q(const char *line);
|
||||||
static void cmd_st(const char *line);
|
static void cmd_strong(const char *line);
|
||||||
static void cmd_tm(const char *line);
|
static void cmd_time(const char *line);
|
||||||
static void cmd_ur(const char *line);
|
static void cmd_url(const char *line);
|
||||||
static void findent(const int ind, FILE *f);
|
static void findent(const int ind, FILE *f);
|
||||||
static void footer(void);
|
static void footer(void);
|
||||||
static void footnotes(void);
|
static void footnotes(void);
|
||||||
|
@ -108,7 +107,7 @@ 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;
|
||||||
char *pub_date = NULL;
|
char *publication_date = NULL;
|
||||||
array sitography;
|
array sitography;
|
||||||
int space = 0;
|
int space = 0;
|
||||||
char tag_closure[CLS_MAX];
|
char tag_closure[CLS_MAX];
|
||||||
|
@ -196,18 +195,18 @@ cmd(char *line)
|
||||||
|
|
||||||
if (!strncmp(line, "A", cmdlen))
|
if (!strncmp(line, "A", cmdlen))
|
||||||
cmd_a(line);
|
cmd_a(line);
|
||||||
else if (!strncmp(line, "AU", cmdlen))
|
else if (!strncmp(line, "AUTHOR", cmdlen))
|
||||||
cmd_au_de_ti(&author, line);
|
cmd_au_de_ti(&author, line);
|
||||||
else if (!strncmp(line, "BR", cmdlen))
|
else if (!strncmp(line, "BR", cmdlen))
|
||||||
cmd_br();
|
cmd_br();
|
||||||
else if (!strncmp(line, "DE", cmdlen))
|
else if (!strncmp(line, "DESCRIPTION", cmdlen))
|
||||||
cmd_au_de_ti(&description, line);
|
cmd_au_de_ti(&description, line);
|
||||||
else if (!strncmp(line, "DT", cmdlen))
|
else if (!strncmp(line, "TIME", cmdlen))
|
||||||
cmd_dt(line);
|
cmd_time(line);
|
||||||
else if (!strncmp(line, "EM", cmdlen))
|
else if (!strncmp(line, "EM", cmdlen))
|
||||||
cmd_em(line);
|
cmd_em(line);
|
||||||
else if (!strncmp(line, "FI", cmdlen))
|
else if (!strncmp(line, "FIGURE", cmdlen))
|
||||||
cmd_fi(line);
|
cmd_figure(line);
|
||||||
else if (!strncmp(line, "H1", cmdlen))
|
else if (!strncmp(line, "H1", cmdlen))
|
||||||
cmd_h(line);
|
cmd_h(line);
|
||||||
else if (!strncmp(line, "H2", cmdlen))
|
else if (!strncmp(line, "H2", cmdlen))
|
||||||
|
@ -224,30 +223,28 @@ cmd(char *line)
|
||||||
cmd_hr();
|
cmd_hr();
|
||||||
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, "INDEX", cmdlen))
|
||||||
cmd_in(line);
|
cmd_index(line);
|
||||||
else if (!strncmp(line, "LA", cmdlen))
|
else if (!strncmp(line, "LANG", cmdlen))
|
||||||
cmd_la(line);
|
cmd_lang(line);
|
||||||
else if (!strncmp(line, "LE", cmdlen))
|
else if (!strncmp(line, "LICENSE_END", cmdlen))
|
||||||
cmd_le();
|
cmd_license_end();
|
||||||
else if (!strncmp(line, "LS", cmdlen))
|
else if (!strncmp(line, "LICENSE_START", cmdlen))
|
||||||
cmd_ls();
|
cmd_license_start();
|
||||||
else if (!strncmp(line, "NO", cmdlen))
|
else if (!strncmp(line, "NOTE", cmdlen))
|
||||||
cmd_no(line);
|
cmd_note(line);
|
||||||
else if (!strncmp(line, "P", cmdlen))
|
else if (!strncmp(line, "P", cmdlen))
|
||||||
cmd_p();
|
cmd_p();
|
||||||
else if (!strncmp(line, "PD", cmdlen))
|
else if (!strncmp(line, "PUBLICATION_DATE", cmdlen))
|
||||||
cmd_pd(line);
|
cmd_publication_date(line);
|
||||||
else if (!strncmp(line, "Q", cmdlen))
|
else if (!strncmp(line, "Q", cmdlen))
|
||||||
cmd_q(line);
|
cmd_q(line);
|
||||||
else if (!strncmp(line, "ST", cmdlen))
|
else if (!strncmp(line, "STRONG", cmdlen))
|
||||||
cmd_st(line);
|
cmd_strong(line);
|
||||||
else if (!strncmp(line, "TI", cmdlen))
|
else if (!strncmp(line, "TITLE", cmdlen))
|
||||||
cmd_au_de_ti(&title, line);
|
cmd_au_de_ti(&title, line);
|
||||||
else if (!strncmp(line, "TM", cmdlen))
|
else if (!strncmp(line, "URL", cmdlen))
|
||||||
cmd_tm(line);
|
cmd_url(line);
|
||||||
else if (!strncmp(line, "UR", cmdlen))
|
|
||||||
cmd_ur(line);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -294,7 +291,11 @@ void
|
||||||
cmd_au_de_ti(char **dst, const char *line)
|
cmd_au_de_ti(char **dst, const char *line)
|
||||||
{
|
{
|
||||||
/* move past command */
|
/* move past command */
|
||||||
line += 2;
|
line = strchr(line, ' ');
|
||||||
|
|
||||||
|
if (line == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
/* move past ' ', if present */
|
/* move past ' ', if present */
|
||||||
if (line[0] == ' ')
|
if (line[0] == ' ')
|
||||||
line++;
|
line++;
|
||||||
|
@ -365,15 +366,15 @@ cmd_close(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_dt(const char *line)
|
cmd_time(const char *line)
|
||||||
{
|
{
|
||||||
char *datetime, *in;
|
char *datetime, *in;
|
||||||
|
|
||||||
datetime = NULL;
|
datetime = NULL;
|
||||||
in = NULL;
|
in = NULL;
|
||||||
|
|
||||||
/* move past "DT" */
|
/* move past "TIME" */
|
||||||
line += 2;
|
line += 4;
|
||||||
/* move past arguments, once found them */
|
/* move past arguments, once found them */
|
||||||
line += stread_param(line, &datetime);
|
line += stread_param(line, &datetime);
|
||||||
line += stread_param(line, &in);
|
line += stread_param(line, &in);
|
||||||
|
@ -410,15 +411,15 @@ cmd_em(const char *line)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_fi(const char *line)
|
cmd_figure(const char *line)
|
||||||
{
|
{
|
||||||
char *ind, *src;
|
char *ind, *src;
|
||||||
|
|
||||||
ind = NULL;
|
ind = NULL;
|
||||||
src = NULL;
|
src = NULL;
|
||||||
|
|
||||||
/* move past "FI" */
|
/* move past "FIGURE" */
|
||||||
line += 2;
|
line += 6;
|
||||||
/* move past argument, once found it */
|
/* move past argument, once found it */
|
||||||
line += stread_param(line, &src);
|
line += stread_param(line, &src);
|
||||||
|
|
||||||
|
@ -497,10 +498,10 @@ cmd_i(const char *line)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_in(const char *line)
|
cmd_index(const char *line)
|
||||||
{
|
{
|
||||||
/* move past "IN" */
|
/* move past "INDEX" */
|
||||||
line += 2;
|
line += 5;
|
||||||
/* move past arguments, once found them */
|
/* move past arguments, once found them */
|
||||||
line += stread_param(line, &index_heading);
|
line += stread_param(line, &index_heading);
|
||||||
line += stread_param(line, &index_heading_id);
|
line += stread_param(line, &index_heading_id);
|
||||||
|
@ -518,10 +519,10 @@ cmd_in(const char *line)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_la(const char *line)
|
cmd_lang(const char *line)
|
||||||
{
|
{
|
||||||
/* move past "LA" */
|
/* move past "LANG" */
|
||||||
line += 2;
|
line += 4;
|
||||||
/* move past ' ', if present */
|
/* move past ' ', if present */
|
||||||
if (line[0] == ' ')
|
if (line[0] == ' ')
|
||||||
line++;
|
line++;
|
||||||
|
@ -538,7 +539,7 @@ cmd_la(const char *line)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_le(void)
|
cmd_license_end(void)
|
||||||
{
|
{
|
||||||
char *ind;
|
char *ind;
|
||||||
|
|
||||||
|
@ -553,7 +554,7 @@ cmd_le(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_ls(void)
|
cmd_license_start(void)
|
||||||
{
|
{
|
||||||
char *ind;
|
char *ind;
|
||||||
|
|
||||||
|
@ -575,7 +576,7 @@ cmd_ls(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_no(const char *line)
|
cmd_note(const char *line)
|
||||||
{
|
{
|
||||||
char *desc, *href, *title;
|
char *desc, *href, *title;
|
||||||
char index[NOTES_MAX_DIGITS + 1];
|
char index[NOTES_MAX_DIGITS + 1];
|
||||||
|
@ -584,8 +585,8 @@ cmd_no(const char *line)
|
||||||
href = NULL;
|
href = NULL;
|
||||||
title = NULL;
|
title = NULL;
|
||||||
|
|
||||||
/* move past "NO" */
|
/* move past "NOTE" */
|
||||||
line += 2;
|
line += 4;
|
||||||
/* move past arguments, once found them */
|
/* move past arguments, once found them */
|
||||||
line += stread_param(line, &href);
|
line += stread_param(line, &href);
|
||||||
line += stread_param(line, &desc);
|
line += stread_param(line, &desc);
|
||||||
|
@ -630,10 +631,10 @@ cmd_p(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_pd(const char *line)
|
cmd_publication_date(const char *line)
|
||||||
{
|
{
|
||||||
/* move past "PD" */
|
/* move past "PUBLICATION_DATE" */
|
||||||
line += 2;
|
line += 16;
|
||||||
/* move past ' ', if present */
|
/* move past ' ', if present */
|
||||||
if (line[0] == ' ')
|
if (line[0] == ' ')
|
||||||
line++;
|
line++;
|
||||||
|
@ -641,12 +642,12 @@ cmd_pd(const char *line)
|
||||||
if (strlen(line) != DATE_LEN)
|
if (strlen(line) != DATE_LEN)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (pub_date == NULL) {
|
if (publication_date == NULL) {
|
||||||
pub_date = safe_malloc(sizeof(char) * (DATE_LEN + 1));
|
publication_date = safe_malloc(sizeof(char) * (DATE_LEN + 1));
|
||||||
pub_date[DATE_LEN] = '\0';
|
publication_date[DATE_LEN] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(pub_date, line, DATE_LEN);
|
strncpy(publication_date, line, DATE_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -678,14 +679,14 @@ cmd_q(const char *line)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_st(const char *line)
|
cmd_strong(const char *line)
|
||||||
{
|
{
|
||||||
char *bodystr;
|
char *bodystr;
|
||||||
|
|
||||||
bodystr = body.data;
|
bodystr = body.data;
|
||||||
|
|
||||||
/* move past "ST" */
|
/* move past "STRONG" */
|
||||||
line += 2;
|
line += 6;
|
||||||
/* move past space, if present */
|
/* move past space, if present */
|
||||||
if (line[0] == ' ')
|
if (line[0] == ' ')
|
||||||
line++;
|
line++;
|
||||||
|
@ -698,39 +699,10 @@ cmd_st(const char *line)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_tm(const char *line)
|
cmd_url(const char *line)
|
||||||
{
|
{
|
||||||
char *date, *hours, *in;
|
/* move past "URL" */
|
||||||
|
line += 3;
|
||||||
/* move past "TM" */
|
|
||||||
line += 2;
|
|
||||||
/* move past arguments, once found them */
|
|
||||||
line += stread_param(line, &date);
|
|
||||||
line += stread_param(line, &hours);
|
|
||||||
line += stread_param(line, &in);
|
|
||||||
|
|
||||||
if (space)
|
|
||||||
array_strcat(&body, " ");
|
|
||||||
array_strcat(&body, "<time datetime=\"");
|
|
||||||
array_strcat(&body, date);
|
|
||||||
if (strcmp(hours, "")) {
|
|
||||||
array_strcat(&body, "T");
|
|
||||||
array_strcat(&body, hours);
|
|
||||||
}
|
|
||||||
array_strcat(&body, "\">");
|
|
||||||
array_strcat_html(&body, in, tag_content);
|
|
||||||
array_strcat(&body, "</time>");
|
|
||||||
|
|
||||||
free(date);
|
|
||||||
free(hours);
|
|
||||||
free(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cmd_ur(const char *line)
|
|
||||||
{
|
|
||||||
/* move past "UR" */
|
|
||||||
line += 2;
|
|
||||||
/* move past ' ', if present */
|
/* move past ' ', if present */
|
||||||
if (line[0] == ' ')
|
if (line[0] == ' ')
|
||||||
line++;
|
line++;
|
||||||
|
@ -770,12 +742,12 @@ footer(void)
|
||||||
|
|
||||||
array_strcat(&body, "\t\t<footer>\n");
|
array_strcat(&body, "\t\t<footer>\n");
|
||||||
|
|
||||||
if (pub_date != NULL) {
|
if (publication_date != NULL) {
|
||||||
array_strcat(&body, "\t\t\t<p>Pubblicazione: <time datetime=\"");
|
array_strcat(&body, "\t\t\t<p>Pubblicazione: <time datetime=\"");
|
||||||
array_strcat(&body, pub_date);
|
array_strcat(&body, publication_date);
|
||||||
array_strcat(&body, "\">");
|
array_strcat(&body, "\">");
|
||||||
|
|
||||||
sscanf(pub_date, "%4i-%2i-%2i", &tm_year, &tm_mon, &tm_mday);
|
sscanf(publication_date, "%4i-%2i-%2i", &tm_year, &tm_mon, &tm_mday);
|
||||||
tm_pd.tm_mday = tm_mday;
|
tm_pd.tm_mday = tm_mday;
|
||||||
tm_pd.tm_mon = --tm_mon;
|
tm_pd.tm_mon = --tm_mon;
|
||||||
tm_pd.tm_year = tm_year - 1900;
|
tm_pd.tm_year = tm_year - 1900;
|
||||||
|
@ -783,7 +755,7 @@ footer(void)
|
||||||
array_strcat(&body, str);
|
array_strcat(&body, str);
|
||||||
array_strcat(&body, "</time></p>\n");
|
array_strcat(&body, "</time></p>\n");
|
||||||
|
|
||||||
free(pub_date);
|
free(publication_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
s = time(NULL);
|
s = time(NULL);
|
||||||
|
@ -858,7 +830,6 @@ footnotes(void)
|
||||||
free(cur->href);
|
free(cur->href);
|
||||||
cur++;
|
cur++;
|
||||||
}
|
}
|
||||||
free(sitography.data);
|
|
||||||
|
|
||||||
array_strcat(&body, "\t\t</div>\n");
|
array_strcat(&body, "\t\t</div>\n");
|
||||||
}
|
}
|
||||||
|
@ -1049,6 +1020,8 @@ main (int argc, char *argv[])
|
||||||
|
|
||||||
free(head.data);
|
free(head.data);
|
||||||
free(body.data);
|
free(body.data);
|
||||||
|
free(index.data);
|
||||||
|
free(sitography.data);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1145,7 +1118,6 @@ nav_index(FILE *f)
|
||||||
fputs("</nav>\n", f);
|
fputs("</nav>\n", f);
|
||||||
|
|
||||||
free(nav_cls.data);
|
free(nav_cls.data);
|
||||||
free(index.data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue