1
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user