{"record":{"id":"ef28730805ad8f2a","repo":"siyuan-note/siyuan","slug":"conf-language-79","errorCode":null,"errorMessage":"Conf.Language(79)","messagePattern":"Conf\\.Language\\(79\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/import.go","lineNumber":1645,"sourceCode":"\t\t\t\treturn ast.WalkContinue\n\t\t\t})\n\n\t\t\treassignIDUpdated(tree, id, updated)\n\t\t\timportTrees = append(importTrees, tree)\n\n\t\t\thPathsIDs[tree.HPath] = tree.ID\n\t\t\tidPaths[tree.ID] = tree.Path\n\n\t\t\tcount++\n\t\t\tif 0 == count%4 {\n\t\t\t\tutil.PushEndlessProgress(fmt.Sprintf(Conf.language(70), fmt.Sprintf(\"%s\", tree.HPath)))\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\t} else { // 导入单个文件\n\t\tfileName := filepath.Base(localPath)\n\t\tif !strings.HasSuffix(fileName, \".md\") && !strings.HasSuffix(fileName, \".markdown\") {\n\t\t\treturn errors.New(Conf.Language(79))\n\t\t}\n\n\t\ttitle := strings.TrimSuffix(fileName, \".markdown\")\n\t\ttitle = strings.TrimSuffix(title, \".md\")\n\t\ttargetPath := strings.TrimSuffix(toPath, \".sy\")\n\t\tid := ast.NewNodeID()\n\t\ttargetPath = path.Join(targetPath, id+\".sy\")\n\t\tvar data []byte\n\t\tdata, err = os.ReadFile(localPath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\ttree, yfmRootID, yfmTitle, yfmUpdated := parseStdMd(data)\n\t\tif nil == tree {\n\t\t\tmsg := fmt.Sprintf(\"parse tree [%s] failed\", localPath)\n\t\t\tlogging.LogError(msg)\n\t\t\treturn errors.New(msg)\n\t\t}","sourceCodeStart":1627,"sourceCodeEnd":1663,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/import.go#L1627-L1663","documentation":"SiYuan's local Markdown import (`importFromLocalPath`) only accepts files with a `.md` or `.markdown` extension. When a single file import is requested and the base name fails that suffix check, it aborts with the localized message 'Only Markdown documents are supported for import' (Conf.Language(79)). The file is never read or parsed, so nothing is imported.","triggerScenarios":"Calling `ImportFromLocalPath` / `ImportFromLocalPathSkipRoot` with `localPath` pointing to a single non-Markdown file (e.g. `.txt`, `.html`, `.docx`, or even `.MD` uppercase, since the suffix check is case-sensitive via `strings.HasSuffix`).","commonSituations":"Users drag-and-drop a text/HTML/Word file onto the editor expecting conversion; scripts or plugins pass a notebook export path of the wrong type; case-sensitive extension like `.MD` on Linux where the check rejects it.","solutions":["Convert the file to Markdown (`.md` or `.markdown`) and retry the import","Rename the file extension to `.md` if the content is already Markdown (fix casing, e.g. `.MD` -> `.md`)","For non-Markdown formats, use a dedicated converter (e.g. pandoc) to Markdown first","If importing a folder, ensure the path is a directory so the `else` single-file branch is not taken"],"exampleFix":"// before\nlocalPath = \"/notes/meeting.txt\" // rejected: Conf.Language(79)\n// after\nlocalPath = \"/notes/meeting.md\" // converted to Markdown first","handlingStrategy":"validation","validationCode":"const localPath = \"/notes/meeting.md\"\nconst base = localPath.split(/[\\\\/]/).pop()!.toLowerCase()\nif (!base.endsWith(\".md\") && !base.endsWith(\".markdown\")) {\n  throw new Error(\"convert to Markdown before importing\")\n}","typeGuard":null,"tryCatchPattern":"try { await importFromLocalPath(path) } catch (e) { if (e.msg === conf.Language(79)) showToast(\"Only .md/.markdown files are supported\") }","preventionTips":["Always normalize file extensions to lowercase `.md` before calling import","Convert non-Markdown formats (txt/html/docx) with pandoc before import","For directory imports, confirm the path `IsDir()` so the single-file branch is skipped"],"tags":["import","markdown","file-extension"],"backgroundTag":"incompatible-source-type","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}