summaryrefslogtreecommitdiff
path: root/journal.c
diff options
context:
space:
mode:
Diffstat (limited to 'journal.c')
-rw-r--r--journal.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/journal.c b/journal.c
index 7507444..4a07261 100644
--- a/journal.c
+++ b/journal.c
@@ -41,11 +41,18 @@ static void print_entry(char *entry) {
strftime(date, sizeof(date), "%Y/%m/%d", localtime(&time));
printf("<div class='entry'><p><span class='date'>%s</span>&emsp;", date);
- for (int p = getc(f), c = getc(f); p != EOF; p = c, c = getc(f)) {
- if (p != '\n')
- putchar(p);
- else if (c != '\n' && c != EOF)
- printf("</p><p>");
+ for (int c = getc(f), nl = 0; c != EOF; c = getc(f)) {
+ if (c == '\n') {
+ ++nl;
+ continue;
+ }
+
+ if (nl > 0) {
+ printf(nl == 1 ? "<br>" : "<p></p>");
+ nl = 0;
+ }
+
+ putchar(c);
}
fclose(f);