commit 2c0e636a7d1312e62aaa523350d996ba4f36af15
parent 835be231c45eb36e19a2c23f6f5fb719424ca1c1
Author: Pavel Renev <an2qzavok@gmail.com>
Date: Sat, 9 Apr 2022 22:40:11 +0000
Gemini: use config.h fonts for code and headers
Diffstat:
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/extra/Gemini.c b/extra/Gemini.c
@@ -4,10 +4,13 @@
#include <libsec.h>
#include <bio.h>
+#include "config.h"
+
#define BSIZE 4096
char *host;
char * gethost(char *uri);
+void printheader(char *line);
void printlink(char *);
void getbody(char *header, Biobuf *bfd);
@@ -127,9 +130,10 @@ getbody(char *header, Biobuf *bfd)
while ((line = Brdstr(bfd, '\n', 1)) != nil) {
long n = Blinelen(bfd);
if (line[n-1] == '\r') line[n-1] = '\0';
- if (strncmp(line, "```", 3) == 0) {
+ if (line[0] == '#') printheader(line);
+ else if (strncmp(line, "```", 3) == 0) {
preform = !preform;
- if (preform == 1) print("f/lib/font/bit/terminus/unicode.12.font\n");
+ if (preform == 1) print("%s", fonts[Fcode]);
else print("f\n");
} else if (strncmp(line, "=>", 2) == 0) {
printlink(line);
@@ -146,6 +150,16 @@ getbody(char *header, Biobuf *bfd)
}
void
+printheader(char *line)
+{
+ int i = 0;
+ while (line[i] == '#') i++;
+ char *font = (i > 3) ? fonts[Fheader6] : fonts[Fheader1 + i - 1];
+ while ((line[i] == ' ') | (line[i] == '\t')) i++;
+ print("f%s\n" ".%s\n" "n\n" "f\n", font, line + i);
+}
+
+void
printlink(char *line)
{
char *p, phost[1024];