diff options
author | j-james | 2022-10-17 16:52:43 +0000 |
---|---|---|
committer | j-james | 2022-10-17 16:52:43 +0000 |
commit | ae68776b5867c477179291a33549f80beda99f51 (patch) | |
tree | 791fa722429e3abf2fb313e74332d02bbdd447a2 /src/main | |
parent | ec21913201b99edc09eacff300f5424e28fcc4ac (diff) |
Add javatuples credits and loop user input
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/ui/BrowserApp.java | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/main/ui/BrowserApp.java b/src/main/ui/BrowserApp.java index 521a28f..83880f9 100644 --- a/src/main/ui/BrowserApp.java +++ b/src/main/ui/BrowserApp.java @@ -13,6 +13,7 @@ import java.util.*; */ public class BrowserApp { private Scanner input; + private static final String border = "==============================================="; /** * EFFECTS: Renders an arbitrary HTML page and arbitrary HTML input. @@ -21,18 +22,30 @@ public class BrowserApp { println("apus: currently a barebones html/css renderer"); println("please provide a path to a file (examples located in data/*):"); + input = new Scanner(System.in); String pathString = input.next(); Path path = Path.of(pathString); try { String file = Files.readString(path); HtmlParser parser = new HtmlParser(); + println(border); renderHtml(parser.parseHtml(file)); - println("Page rendered. Input raw HTML to add Nodes."); - parser = new HtmlParser(); - String rawHtml = input.next(); - renderHtml(parser.parseHtml(file + rawHtml)); + println(border); + ArrayList<String> rawHtml = new ArrayList<>(); + rawHtml.add(file); + while (true) { + println("Page rendered. Input additional raw HTML if desired."); + rawHtml.add(input.next()); + println(border); + for (String s : rawHtml) { + parser = new HtmlParser(); + renderHtml(parser.parseHtml(s)); + } + println(border); + } } catch (Exception e) { println("Reading from the file failed with " + e.toString()); + println("Please try again."); } } |