From 5bb3583b71732bb46243898fba22ba209e8acd10 Mon Sep 17 00:00:00 2001 From: Gilbert Kwan Date: Mon, 14 Feb 2022 11:15:09 -0500 Subject: [PATCH] update codeSnippet --- src/main/java/Functions.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/Functions.java b/src/main/java/Functions.java index 012701f..38f769b 100644 --- a/src/main/java/Functions.java +++ b/src/main/java/Functions.java @@ -866,21 +866,22 @@ public static ArrayList mains(ArrayList listOfLines, Properties //inserts code snippet (Finds the right code snippet and inserts it into the text public static ArrayList codeSnippet(ArrayList listOfLines, String guideName, String branch, int i, String path, ArrayList hideList) { + String p = path.trim(); try { ArrayList code = new ArrayList(); - URL url = new URL("https://raw.githubusercontent.com/openliberty/" + guideName + "/" + branch + "/" + path); + URL url = new URL("https://raw.githubusercontent.com/openliberty/" + guideName + "/" + branch + "/" + p); Scanner s = new Scanner(url.openStream()); String inputLine = null; code.add("\n"); - if (path.endsWith(".java")) { + if (p.endsWith(".java")) { code.add("```java\n"); - } else if((path.endsWith(".js"))) { + } else if((p.endsWith(".js"))) { code.add("```javascript\n"); - } else if((path.endsWith(".json"))) { + } else if((p.endsWith(".json"))) { code.add("```json\n"); - } else if((path.endsWith(".xml"))) { + } else if((p.endsWith(".xml"))) { code.add("```xml\n"); - } else if((path.endsWith(".yaml"))) { + } else if((p.endsWith(".yaml"))) { code.add("```yaml\n"); } else { code.add("```\n");