repo: geminiclient action: commit revision: path_from: revision_from: a79e072594c2984e322c1f120923c90aa46ba816: path_to: revision_to:
commit a79e072594c2984e322c1f120923c90aa46ba816 Author: epochDate: Fri Aug 21 00:30:05 2020 -0500 added support for gemini lists, and disable the forced html header stuff unless you supply an argument to be used as the html title diff --git a/gemini2html.c b/gemini2html.c
--- a/gemini2html.c
+++ b/gemini2html.c
@@ -6,20 +6,30 @@
int main(int argc,char *argv[]) {
char line[65536];//65535+null
char pre=0;
+ char list=0;
char *first;
char *second;
- if(argc < 2) {
- fprintf(stderr,"usage: gemini2html title\n");
- return 1;
+ if(argc >= 2) {//if there's an argument, we output the header too.
+ printf("%s %s",argv[1],LINE_ENDING);
}
- printf("%s %s",argv[1],LINE_ENDING);
while(fgets(line,sizeof(line)-1,stdin)) {
//strip line endings ofc.
if(first=strchr(line,'\r')) *first=0;
if(first=strchr(line,'\n')) *first=0;
+ if(!strncmp(line,"* ",2)) {
+ first=line+2;
+ if(!list) printf("- %s",LINE_ENDING);
+ list=1;
+ printf("
- %s %s",first,LINE_ENDING); + continue; + } + if(list) {//we didn't get a list item, but we're still in a list... close this shit up. + printf("
%s
%s",first,LINE_ENDING); @@ -56,6 +66,7 @@ int main(int argc,char *argv[]) { } printf("%s%s",line,LINE_ENDING); } + if(list) printf("%s",LINE_ENDING); if(pre) printf("%s",LINE_ENDING);//gemini doesn't need it to be balanced, so we'll close it for html's sake. - printf("%s",LINE_ENDING); + if(argc >= 2) printf("%s",LINE_ENDING);//we output the header, let's finish it too. }
-----END OF PAGE-----