Branding.
This commit is contained in:
+16
-7
@@ -48,7 +48,7 @@ void highlight_code(const char *code) {
|
||||
const char *ptr = code;
|
||||
char buffer[4096];
|
||||
size_t index = 0;
|
||||
buffer[index] = 0;
|
||||
|
||||
while (*ptr) {
|
||||
if ((*ptr >= 'a' && *ptr <= 'z') || (*ptr >= 'A' && *ptr <= 'Z') || (*ptr == '_')) {
|
||||
while ((*ptr >= 'a' && *ptr <= 'z') || (*ptr >= 'A' && *ptr <= 'Z') || (*ptr >= '0' && *ptr <= '9') || (*ptr == '_')) {
|
||||
@@ -102,7 +102,6 @@ void parse_markdown_to_ansi(const char *markdown) {
|
||||
code_buffer[index++] = 0;
|
||||
highlight_code(code_buffer);
|
||||
index = 0;
|
||||
code_buffer[index] = 0;
|
||||
}
|
||||
}
|
||||
code_buffer[index] = 0;
|
||||
@@ -113,29 +112,39 @@ void parse_markdown_to_ansi(const char *markdown) {
|
||||
if (strncmp(ptr, "**", 2) == 0) {
|
||||
printf(BOLD);
|
||||
ptr += 2;
|
||||
while (*ptr && strncmp(ptr, "**", 2) != 0) putchar(*ptr++);
|
||||
while (*ptr && strncmp(ptr, "**", 2) != 0) {
|
||||
putchar(*ptr++);
|
||||
}
|
||||
if (*ptr == '*' && *(ptr + 1) == '*') ptr += 2;
|
||||
printf(RESET);
|
||||
} else if (*ptr == '*' && (ptr == markdown || *(ptr - 1) != '*')) {
|
||||
printf(ITALIC);
|
||||
ptr++;
|
||||
while (*ptr && *ptr != '*') putchar(*ptr++);
|
||||
while (*ptr && *ptr != '*') {
|
||||
putchar(*ptr++);
|
||||
}
|
||||
if (*ptr == '*') ptr++;
|
||||
printf(RESET);
|
||||
} else if (strncmp(ptr, "### ", 4) == 0) {
|
||||
printf(BOLD FG_YELLOW);
|
||||
ptr += 4;
|
||||
while (*ptr && *ptr != '\n') putchar(*ptr++);
|
||||
while (*ptr && *ptr != '\n') {
|
||||
putchar(*ptr++);
|
||||
}
|
||||
printf(RESET "\n");
|
||||
} else if (strncmp(ptr, "## ", 3) == 0) {
|
||||
printf(BOLD FG_YELLOW);
|
||||
ptr += 3;
|
||||
while (*ptr && *ptr != '\n') putchar(*ptr++);
|
||||
while (*ptr && *ptr != '\n') {
|
||||
putchar(*ptr++);
|
||||
}
|
||||
printf(RESET "\n");
|
||||
} else if (strncmp(ptr, "# ", 2) == 0) {
|
||||
printf(BOLD FG_YELLOW);
|
||||
ptr += 2;
|
||||
while (*ptr && *ptr != '\n') putchar(*ptr++);
|
||||
while (*ptr && *ptr != '\n') {
|
||||
putchar(*ptr++);
|
||||
}
|
||||
printf(RESET "\n");
|
||||
} else {
|
||||
putchar(*ptr);
|
||||
|
||||
Reference in New Issue
Block a user