(runtime *common.RuntimeContext, filePath string)
| 181 | } |
| 182 | |
| 183 | func readMarkdownLocalFile(runtime *common.RuntimeContext, filePath string) (string, error) { |
| 184 | f, err := runtime.FileIO().Open(filePath) |
| 185 | if err != nil { |
| 186 | return "", withMarkdownFileParam(common.WrapInputStatErrorTyped(err), "--file") |
| 187 | } |
| 188 | defer f.Close() |
| 189 | |
| 190 | payload, err := readMarkdownDiffPayload(f, "local Markdown file") |
| 191 | if err != nil { |
| 192 | if _, ok := errs.ProblemOf(err); ok { |
| 193 | return "", withMarkdownFileParam(err, "--file") |
| 194 | } |
| 195 | return "", markdownValidationParamError("--file", "cannot read file: %s", err).WithCause(err) |
| 196 | } |
| 197 | return string(payload), nil |
| 198 | } |
| 199 | |
| 200 | func readMarkdownDiffPayload(r io.Reader, source string) ([]byte, error) { |
| 201 | payload, err := io.ReadAll(io.LimitReader(r, markdownDiffMaxContentBytes+1)) |
no test coverage detected