fak
This commit is contained in:
parent
3507a9f538
commit
24a0a640f1
45
main.c
45
main.c
|
|
@ -21,6 +21,7 @@ typedef struct {
|
||||||
int italic;
|
int italic;
|
||||||
int hyperlink;
|
int hyperlink;
|
||||||
int code;
|
int code;
|
||||||
|
int blockcode;
|
||||||
int headingone;
|
int headingone;
|
||||||
int headingtwo;
|
int headingtwo;
|
||||||
int headingthree;
|
int headingthree;
|
||||||
|
|
@ -445,13 +446,13 @@ dohyperlink(void) {
|
||||||
void build(void) {
|
void build(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void generate(void) {
|
|
||||||
|
|
||||||
|
void generate(void) {
|
||||||
header = doinsert("./media/header.html");
|
header = doinsert("./media/header.html");
|
||||||
|
|
||||||
fprintf(fpto, "<html>\n<head>\n<meta charset=\"utf-8\"/>\n<title>homepage - %s</title><link rel=\"stylesheet\" href=\"style.css\">\n</head>\n<body>", SUBTITLE);
|
fprintf(fpto, "<html>\n<head>\n<meta charset=\"utf-8\"/>\n<title>homepage - %s</title><link rel=\"stylesheet\" href=\"style.css\">\n</head>\n<body>", SUBTITLE);
|
||||||
|
|
||||||
if( header == NULL ) {
|
if (header == NULL) {
|
||||||
printf("header NULL\n");
|
printf("header NULL\n");
|
||||||
} else {
|
} else {
|
||||||
fprintf(fpto, "%s\n", header);
|
fprintf(fpto, "%s\n", header);
|
||||||
|
|
@ -464,15 +465,15 @@ void generate(void) {
|
||||||
txt[--len] = '\0';
|
txt[--len] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
mdt.headingone = mdt.headingtwo = mdt.headingthree = mdt.quote = 0;
|
mdt.headingone = mdt.headingtwo = mdt.headingthree = mdt.quote = mdt.blockcode = 0;
|
||||||
|
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
fprintf(fpto, "\n");
|
fprintf(fpto, "\n");
|
||||||
} else {
|
} else {
|
||||||
i = 0;
|
i = 0;
|
||||||
judul = 0;
|
judul = 0;
|
||||||
|
|
||||||
if (txt[0] == '#') {
|
if (txt[0] == '#') {
|
||||||
int heading_count = 0;
|
int heading_count = 0;
|
||||||
while (i < len && txt[i] == '#') {
|
while (i < len && txt[i] == '#') {
|
||||||
heading_count++;
|
heading_count++;
|
||||||
|
|
@ -499,13 +500,27 @@ if (txt[0] == '#') {
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (len > 1 && txt[0] == '>' && txt[1] != '\\') {
|
else if (len > 1 && txt[0] == '>' && txt[1] != '\\') {
|
||||||
doblockquote();
|
doblockquote();
|
||||||
while (i < len && (txt[i] == '>' || txt[i] == ' ')) i++;
|
while (i < len && (txt[i] == '>' || txt[i] == ' ')) i++;
|
||||||
|
}
|
||||||
|
else if (len > 2 && txt[0] == '`' && txt[1] == '`' && txt[2] == '`' && (i == 0 || txt[i-1] != '\\')) {
|
||||||
|
if (mdt.blockcode == 0) {
|
||||||
|
fprintf(fpto, "<pre><code>");
|
||||||
|
mdt.blockcode = 1;
|
||||||
|
i += 3;
|
||||||
|
} else {
|
||||||
|
fprintf(fpto, "</code></pre>");
|
||||||
|
mdt.blockcode = 0;
|
||||||
|
i += 3;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
} else if (mdt.blockcode == 1) {
|
||||||
|
fprintf(fpto, "%s\n", txt);
|
||||||
|
continue;
|
||||||
} else {
|
} else {
|
||||||
fprintf(fpto, "<p>");
|
fprintf(fpto, "<p>");
|
||||||
i = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; i < len; i++) {
|
for (; i < len; i++) {
|
||||||
|
|
@ -525,13 +540,13 @@ if (txt[0] == '#') {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mdt.italic) fprintf(fpto, "</i>");
|
if (mdt.italic) fprintf(fpto, "</i>");
|
||||||
else if (mdt.code) fprintf(fpto, "</code>");
|
if (mdt.code) fprintf(fpto, "</code>");
|
||||||
else if (mdt.bold) fprintf(fpto, "</b>");
|
if (mdt.bold) fprintf(fpto, "</b>");
|
||||||
else if (mdt.quote) fprintf(fpto, "</blockquote>\n");
|
if (mdt.quote) fprintf(fpto, "</blockquote>\n");
|
||||||
else if (mdt.headingone) fprintf(fpto, "</h1>\n");
|
if (mdt.headingone) fprintf(fpto, "</h1>\n");
|
||||||
else if (mdt.headingtwo) fprintf(fpto, "</h2>\n");
|
if (mdt.headingtwo) fprintf(fpto, "</h2>\n");
|
||||||
else if (mdt.headingthree) fprintf(fpto, "</h3>\n");
|
if (mdt.headingthree) fprintf(fpto, "</h3>\n");
|
||||||
if (!(mdt.headingone || mdt.headingtwo || mdt.headingthree || mdt.quote)) fprintf(fpto, "</p>\n");
|
if (!(mdt.headingone || mdt.headingtwo || mdt.headingthree || mdt.quote || mdt.blockcode)) fprintf(fpto, "</p>\n");
|
||||||
|
|
||||||
mdt.italic = mdt.bold = mdt.quote = mdt.headingone = mdt.headingtwo = mdt.headingthree = mdt.code = 0;
|
mdt.italic = mdt.bold = mdt.quote = mdt.headingone = mdt.headingtwo = mdt.headingthree = mdt.code = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -539,7 +554,7 @@ if (txt[0] == '#') {
|
||||||
|
|
||||||
footer = doinsert("./media/footer.html");
|
footer = doinsert("./media/footer.html");
|
||||||
|
|
||||||
if(footer == NULL) {
|
if (footer == NULL) {
|
||||||
printf("gak ada footer bro :(\n");
|
printf("gak ada footer bro :(\n");
|
||||||
} else {
|
} else {
|
||||||
fprintf(fpto, "%s", footer);
|
fprintf(fpto, "%s", footer);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user