MCPcopy
hub / github.com/cli/cli / renderMarkdownPreview

Function renderMarkdownPreview

pkg/cmd/skills/preview/preview.go:391–408  ·  view source on GitHub ↗
(io *iostreams.IOStreams, filePath, content string)

Source from the content-addressed store, hash-verified

389}
390
391func renderMarkdownPreview(io *iostreams.IOStreams, filePath, content string) string {
392 if filePath == "SKILL.md" {
393 parsed, err := frontmatter.Parse(content)
394 if err == nil {
395 content = parsed.Body
396 }
397 }
398
399 rendered, err := markdown.Render(content,
400 markdown.WithTheme(io.TerminalTheme()),
401 markdown.WithWrap(io.TerminalWidth()),
402 markdown.WithoutIndentation())
403 if err != nil {
404 return content
405 }
406
407 return rendered
408}
409
410func isMarkdownFile(filePath string) bool {
411 switch strings.ToLower(path.Ext(filePath)) {

Callers 2

NewCmdPreviewFunction · 0.85
renderFileMethod · 0.85

Calls 7

ParseFunction · 0.92
RenderFunction · 0.92
WithThemeFunction · 0.92
WithWrapFunction · 0.92
WithoutIndentationFunction · 0.92
TerminalThemeMethod · 0.80
TerminalWidthMethod · 0.80

Tested by

no test coverage detected