repo: geminiclient
action: commit
revision: 
path_from: 
revision_from: a79e072594c2984e322c1f120923c90aa46ba816:
path_to: 
revision_to: 
git.thebackupbox.net
geminiclient
git clone git://git.thebackupbox.net/geminiclient
commit a79e072594c2984e322c1f120923c90aa46ba816
Author: epoch 
Date:   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
index 64e23a3a595100f31dc450ca800d80df71d6cea4..
index ..11027c8ac12f8942623c0c4f39e3bf864be644d3 100644
--- 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=0;
+    }
     if(!strncmp(line,"# ",2)) {
       first=line+2;
       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-----