From db7d0c4d6769d65070e6b68056cd035e4e31d339 Mon Sep 17 00:00:00 2001 From: Dominic Ricottone Date: Sat, 17 Sep 2022 23:21:26 -0500 Subject: [PATCH] Adding parcels URLs are now parsed and separated out, into a secondary block of text. --- go.mod | 5 ++++- main.go | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index fa6462e..74bc57a 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,7 @@ module git.dominic-ricottone.com/~dricottone/digestion go 1.19 -require git.dominic-ricottone.com/~dricottone/textwrap v0.0.3 +require ( + git.dominic-ricottone.com/~dricottone/parcels v1.1.1 + git.dominic-ricottone.com/~dricottone/textwrap v0.0.3 +) diff --git a/main.go b/main.go index 844dc7d..bf51887 100644 --- a/main.go +++ b/main.go @@ -10,6 +10,7 @@ import ( "flag" "git.dominic-ricottone.com/~dricottone/digestion/message" + parcels "git.dominic-ricottone.com/~dricottone/parcels/common" ) const LINE_LENGTH = 80 @@ -35,8 +36,15 @@ func first_submatch(r regexp.Regexp, s string) string { } func parse_stream(reader io.Reader, length int) { - // Create scanner from reader - input := bufio.NewScanner(reader) + fmt.Println("ping") + content, urls, err := parcels.ParseFromReader(reader, 0) + if err != nil { + fmt.Printf("internal error - %v\n", err) + os.Exit(1) + } + + // create scanner + input := bufio.NewScanner(strings.NewReader(content)) // Compile regular expressions re_message_break, err := regexp.Compile("^-{5,}$") @@ -99,6 +107,8 @@ func parse_stream(reader io.Reader, length int) { } } + fmt.Printf("%s", urls) + // Check for scanner errors if err = input.Err(); err != nil { fmt.Printf("internal error - %v\n", err) -- 2.45.2