Skip to content

Commit

Permalink
Remove all # characters from the page titles
Browse files Browse the repository at this point in the history
  • Loading branch information
kovmir committed Sep 26, 2024
1 parent e8f33a4 commit a897b82
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions swege.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ char *
get_title(FILE * in)
{
char *line = NULL;
int n_hashes;
size_t linecap = 0;
getline(&line, &linecap, in);

Expand All @@ -321,8 +322,11 @@ get_title(FILE * in)
}
}
} else if (strlen(line) >= 3 && line[0] == '#') {
/* Copy line without the # */
strncpy(ret, line + 2, (TITLE_SIZE + 1));
/* Count the amount of '#' characters. */
for (n_hashes = 1; line[n_hashes] == '#'; n_hashes++)
;
/* Copy line without the '#' and ' ' immediately after it. */
strncpy(ret, line + n_hashes + 1, (TITLE_SIZE + 1));
ret[TITLE_SIZE] = '\0'; /* Ensure termination */

rewind(in); /* Leave H1 in place for rendering */
Expand Down

0 comments on commit a897b82

Please sign in to comment.