sek
This commit is contained in:
parent
52d54e50e7
commit
be9b9c0ae6
24
main.c
24
main.c
|
|
@ -1,9 +1,3 @@
|
||||||
/* daisy
|
|
||||||
* alif@radhitya.org
|
|
||||||
*
|
|
||||||
* thank you stackoverflow, geeksforgeeks, grok
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
@ -285,11 +279,11 @@ void generate(void) {
|
||||||
fprintf(fpto, "<link rel=\"stylesheet\" href=\"style.css\">\n");
|
fprintf(fpto, "<link rel=\"stylesheet\" href=\"style.css\">\n");
|
||||||
fprintf(fpto, "</head>\n<body>\n");
|
fprintf(fpto, "</head>\n<body>\n");
|
||||||
|
|
||||||
|
int judul = 0;
|
||||||
|
|
||||||
while (fgets(txt, MAX_LENGTH, fptr) != NULL) {
|
while (fgets(txt, MAX_LENGTH, fptr) != NULL) {
|
||||||
len = strlen(txt);
|
len = strlen(txt);
|
||||||
|
|
||||||
int judul = 0;
|
|
||||||
|
|
||||||
if (len > 0 && txt[len - 1] == '\n') {
|
if (len > 0 && txt[len - 1] == '\n') {
|
||||||
txt[--len] = '\0';
|
txt[--len] = '\0';
|
||||||
}
|
}
|
||||||
|
|
@ -303,12 +297,18 @@ void generate(void) {
|
||||||
|
|
||||||
if (txt[0] == '#') {
|
if (txt[0] == '#') {
|
||||||
int heading_count = 0;
|
int heading_count = 0;
|
||||||
while (i < len && txt[i] == '#') { heading_count++; i++; }
|
|
||||||
|
while (i < len && txt[i] == '#') {
|
||||||
|
heading_count++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
if (i < len && txt[i] == ' ') {
|
if (i < len && txt[i] == ' ') {
|
||||||
i++; // Skip space after #
|
i++;
|
||||||
const char *title_start = txt + i;
|
|
||||||
if (heading_count == 1 && !judul) {
|
char *title_start = txt + i;
|
||||||
|
|
||||||
|
if (heading_count == 1) {
|
||||||
judul = 1;
|
judul = 1;
|
||||||
fseek(fpto, 0, SEEK_SET);
|
fseek(fpto, 0, SEEK_SET);
|
||||||
fprintf(fpto, "<html>\n<head>\n<meta charset=\"utf-8\"/>\n"
|
fprintf(fpto, "<html>\n<head>\n<meta charset=\"utf-8\"/>\n"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user