瀏覽代碼

:art: Add logging https://github.com/siyuan-note/siyuan/issues/12960

Daniel 9 月之前
父節點
當前提交
59bb202b13
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      kernel/util/ocr.go

+ 2 - 2
kernel/util/ocr.go

@@ -231,7 +231,7 @@ func Tesseract(imgAbsPath string) (ret []map[string]interface{}) {
 	logging.LogInfof("tesseract [path=%s] success [%s]", imgAbsPath, tsv)
 	logging.LogInfof("tesseract [path=%s] success [%s]", imgAbsPath, tsv)
 
 
 	// 按行分割 TSV 数据
 	// 按行分割 TSV 数据
-	lines := strings.Split(tsv, "\r\n")
+	lines := strings.Split(tsv, "\n")
 
 
 	// 解析 TSV 数据 跳过标题行,从第二行开始处理
 	// 解析 TSV 数据 跳过标题行,从第二行开始处理
 	for _, line := range lines[1:] {
 	for _, line := range lines[1:] {
@@ -262,7 +262,7 @@ func GetOcrJsonText(jsonData []map[string]interface{}) (ret string) {
 		if text, ok := dataMap["text"]; ok {
 		if text, ok := dataMap["text"]; ok {
 			// 确保 text 是字符串类型
 			// 确保 text 是字符串类型
 			if textStr, ok := text.(string); ok {
 			if textStr, ok := text.(string); ok {
-				ret += " " + textStr
+				ret += " " + strings.ReplaceAll(textStr, "\r", "")
 			}
 			}
 		}
 		}
 	}
 	}