From c849aeddaecb3fa761684000c6a66880b8ce0f0d Mon Sep 17 00:00:00 2001 From: fengxxc Date: Tue, 30 Jul 2024 12:38:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D
=E9=87=8C?=
 =?UTF-8?q?=E7=9A=84
=E6=B2=A1=E6=9C=89=E8=A2=AB=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parse/parse.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/parse/parse.go b/parse/parse.go index aed126c..495ae86 100644 --- a/parse/parse.go +++ b/parse/parse.go @@ -100,9 +100,19 @@ func parseHeader(s *goquery.Selection) []Piece { } func parsePre(s *goquery.Selection) []Piece { + // print(s.Html()) var codeRows []string s.Find("code").Each(func(i int, sc *goquery.Selection) { - codeRows = append(codeRows, sc.Text()) + var codeLine string = "" + sc.Contents().Each(func(i int, sc *goquery.Selection) { + if goquery.NodeName(sc) == "br" { + codeRows = append(codeRows, codeLine) + codeLine = "" + } else { + codeLine += sc.Text() + } + }) + codeRows = append(codeRows, codeLine) }) p := Piece{CODE_BLOCK, codeRows, nil} return []Piece{p}