mirror of
https://github.com/fengxxc/wechatmp2markdown.git
synced 2026-02-28 17:51:06 +08:00
feat: 支持解析表格(简单粗暴的原生html方式)
This commit is contained in:
@@ -64,6 +64,8 @@ func parseSection(s *goquery.Selection, imagePolicy ImagePolicy, lastPieceType P
|
||||
pieces = append(pieces, parseBlockQuote(sc, imagePolicy)...)
|
||||
} else if sc.Is("strong") {
|
||||
pieces = append(pieces, parseStrong(sc)...)
|
||||
} else if sc.Is("table") {
|
||||
pieces = append(pieces, parseTable(sc)...)
|
||||
} else {
|
||||
if sc.Text() != "" {
|
||||
pieces = append(pieces, Piece{NORMAL_TEXT, sc.Text(), nil})
|
||||
@@ -123,6 +125,14 @@ func parseBlockQuote(s *goquery.Selection, imagePolicy ImagePolicy) []Piece {
|
||||
return bq
|
||||
}
|
||||
|
||||
func parseTable(s *goquery.Selection) []Piece {
|
||||
// 先简单粗暴把原生的挪过去
|
||||
var table []Piece
|
||||
html, _ := s.Html()
|
||||
table = append(table, Piece{TABLE, "<table>" + html + "</table>", map[string]string{"type": "native"}})
|
||||
return table
|
||||
}
|
||||
|
||||
func parseStrong(s *goquery.Selection) []Piece {
|
||||
var bt []Piece
|
||||
bt = append(bt, Piece{BOLD_TEXT, strings.TrimSpace(s.Text()), nil})
|
||||
|
||||
Reference in New Issue
Block a user