MCPcopy Index your code
hub / github.com/cli/cli / renderMarkdownWithFormat

Function renderMarkdownWithFormat

pkg/cmd/agent-task/shared/log.go:311–329  ·  view source on GitHub ↗

renderMarkdownWithFormat renders the given markdown string to the given writer. If a formatFunc is provided, the md string is ran through it before rendering. This can be used to add newlines before and after the content.

(md string, w io.Writer, io *iostreams.IOStreams, formatFunc func(string) string)

Source from the content-addressed store, hash-verified

309// If a formatFunc is provided, the md string is ran through it before
310// rendering. This can be used to add newlines before and after the content.
311func renderMarkdownWithFormat(md string, w io.Writer, io *iostreams.IOStreams, formatFunc func(string) string) error {
312 rendered, err := markdown.Render(md,
313 markdown.WithTheme(io.TerminalTheme()),
314 markdown.WithWrap(io.TerminalWidth()),
315 )
316
317 if err != nil {
318 return fmt.Errorf("failed to render markdown: %w", err)
319 }
320
321 rendered = strings.TrimSpace(rendered)
322 if formatFunc != nil {
323 rendered = formatFunc(rendered)
324 }
325
326 fmt.Fprint(w, rendered)
327
328 return nil
329}
330
331// stripDiffFormat implements a primitive conversion from a diff string to a
332// plain text representation by removing diff-specific formatting.

Callers 2

renderRawMarkdownFunction · 0.85

Calls 6

RenderFunction · 0.92
WithThemeFunction · 0.92
WithWrapFunction · 0.92
TerminalThemeMethod · 0.80
TerminalWidthMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected