This commit is contained in:
2026-08-05 10:28:44 +08:00
commit 0bacf2e0a4
103 changed files with 9415 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
package common
import (
"os"
"strings"
)
type textParser struct{}
// Parse txt / md:直接读全文。md 保留 # 标题行供分块器识别
func (p *textParser) Parse(path string) (string, error) {
b, err := os.ReadFile(path)
if err != nil {
return "", err
}
text := string(b)
text = strings.ReplaceAll(text, "\r\n", "\n")
text = strings.ReplaceAll(text, "\r", "\n")
return text, nil
}