MCPcopy
hub / github.com/agentsmd/agents.md / parseMarkdown

Function parseMarkdown

components/CodeExample.tsx:66–101  ·  view source on GitHub ↗

* Very lightly highlight the Markdown without fully parsing it.

(md: string)

Source from the content-addressed store, hash-verified

64 * Very lightly highlight the Markdown without fully parsing it.
65 */
66function parseMarkdown(md: string): React.ReactNode[] {
67 const lines = md.split("\n");
68 const elements: React.ReactNode[] = [];
69
70 for (let i = 0; i < lines.length; i++) {
71 const line = lines[i];
72
73 // Handle headers
74 if (line.startsWith("# ") || line.startsWith("## ") || line.startsWith("### ")) {
75 elements.push(
76 <div key={i} className="font-bold">
77 {line}
78 </div>
79 );
80 } else if (line.startsWith("- ")) {
81 // Handle list items with inline code
82 elements.push(
83 <div key={i}>
84 {renderLineWithInlineCode(line)}
85 </div>
86 );
87 } else if (line.trim() === "") {
88 // Handle empty lines
89 elements.push(<div key={i}>&nbsp;</div>);
90 } else {
91 // Handle regular lines with inline code
92 elements.push(
93 <div key={i}>
94 {renderLineWithInlineCode(line)}
95 </div>
96 );
97 }
98 }
99
100 return elements;
101}
102
103/**
104 * Render a line with inline code highlighting

Callers 1

CodeExampleFunction · 0.85

Calls 1

renderLineWithInlineCodeFunction · 0.85

Tested by

no test coverage detected