From 6586db782ea6dcb5f2eb191a690ec7e7df51161f Mon Sep 17 00:00:00 2001 From: tjpcc Date: Tue, 17 Jan 2023 16:41:04 -0700 Subject: Updates * update README * move "gemtext" to within "gemini" --- gemtext/parse.go | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 gemtext/parse.go (limited to 'gemtext/parse.go') diff --git a/gemtext/parse.go b/gemtext/parse.go deleted file mode 100644 index 7041fde..0000000 --- a/gemtext/parse.go +++ /dev/null @@ -1,49 +0,0 @@ -package gemtext - -import ( - "bufio" - "io" -) - -// Parse parses the full contents of an io.Reader into a gemtext.Document. -func Parse(input io.Reader) (Document, error) { - rdr := bufio.NewReader(input) - - var lines []Line - inPFT := false - - for { - raw, err := rdr.ReadBytes('\n') - if err != io.EOF && err != nil { - return nil, err - } - - var line Line - - if inPFT && (len(raw) < 3 || raw[0] != '`' || raw[1] != '`' || raw[2] != '`') { - line = PreformattedTextLine{raw: raw} - } else { - line = ParseLine(raw) - } - - if line != nil && line.Type() == LineTypePreformatToggle { - if inPFT { - toggle := line.(PreformatToggleLine) - (&toggle).clearAlt() - line = toggle - } - - inPFT = !inPFT - } - - if line != nil { - lines = append(lines, line) - } - - if err == io.EOF { - break - } - } - - return Document(lines), nil -} -- cgit v1.2.3