Process the standard (non-advanced) types of lines.  A client should now be able to distinguish between them.
M src/main/java/com/ajtjp/geminiclient/GeminiClient.java +28 -4
@@ 5,6 5,8 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.Socket;
 import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.List;
 import javax.net.SocketFactory;
 import javax.net.ssl.HostnameVerifier;
 import javax.net.ssl.HttpsURLConnection;

          
@@ 23,7 25,7 @@ public class GeminiClient {
     static SocketFactory basicSocketFactory = SocketFactory.getDefault();
     static SSLSocketFactory sslSocketFactory = null;
     
-    public static String connect(String url, int port) throws IOException, InterruptedException {
+    public static GeminiDocument connect(String url, int port) throws IOException, InterruptedException {
         trustAllCerts();
         
         GeminiDocument doc = new GeminiDocument(url);

          
@@ 46,10 48,12 @@ public class GeminiClient {
         while (true) {
             int bytesRead = is.read(buffer, 0, 2000);
             if (bytesRead == -1) {
-                return sb.toString();
+                doc.lines = parseLines(sb.toString());
+                return doc;
             }
             sb.append(new String(buffer, 0, bytesRead, "UTF-8"));
         }
+        
     }
     
     private static String parseHeaders(InputStream is) throws IOException {

          
@@ 62,8 66,28 @@ public class GeminiClient {
         return new String(buffer, 0, bytesRead, "UTF-8");
     }
     
-    private void parse(String responseBody) {
-        
+    private static List<GeminiLine> parseLines(String responseBody) {
+        String[] rawLines = responseBody.split("\n");
+        List<GeminiLine> geminiLines = new ArrayList<GeminiLine>();
+        boolean preformatToggle = false;
+        for (String line : rawLines) {
+            if (line.startsWith("=>")) {
+                geminiLines.add(new GeminiLine(LineType.LINK, line.substring(2)));
+            }
+            else if (line.startsWith("```")) {
+                geminiLines.add(new GeminiLine(LineType.PREFORMAT_TOGGLE, ""));
+                preformatToggle = !preformatToggle;
+            }
+            else {
+                if (preformatToggle) {
+                    geminiLines.add(new GeminiLine(LineType.PREFORMATTED, line));
+                }
+                else {
+                    geminiLines.add(new GeminiLine(LineType.TEXT, line));
+                }
+            }
+        }
+        return geminiLines;
     }
     
     static void trustAllCerts() {

          
M src/main/java/com/ajtjp/geminiclient/Main.java +7 -2
@@ 1,6 1,7 @@ 
 package com.ajtjp.geminiclient;
 
 import java.io.IOException;
+import java.util.List;
 
 /**
  * Testing connections while developing the client.

          
@@ 17,8 18,12 @@ public class Main {
 
     public static void main(String[]args) {
         try {
-            String result = GeminiClient.connect(circumlunarSpace, 1965);
-            System.out.println("Result: " + result);
+            GeminiDocument doc = GeminiClient.connect(circumlunarSpace, 1965);
+            for (GeminiLine line : doc.lines) {
+                if (line.type == LineType.LINK) {
+                    System.out.println("Link: " + line.contents);
+                }
+            }
         }
         catch(IOException | InterruptedException ex) {
             System.err.println("error: " + ex.getMessage());