MCPcopy Index your code
hub / github.com/shareAI-lab/learn-claude-code / postProcessHtml

Function postProcessHtml

web/src/components/docs/doc-renderer.tsx:30–63  ·  view source on GitHub ↗
(html: string)

Source from the content-addressed store, hash-verified

28}
29
30function postProcessHtml(html: string): string {
31 // Add language labels to highlighted code blocks
32 html = html.replace(
33 /<pre><code class="hljs language-(\w+)">/g,
34 '<pre class="code-block" data-language="$1"><code class="hljs language-$1">'
35 );
36
37 // Wrap plain pre>code (ASCII art / diagrams) in diagram container
38 html = html.replace(
39 /<pre><code(?! class="hljs)([^>]*)>/g,
40 '<pre class="ascii-diagram"><code$1>'
41 );
42
43 // Keep wide Markdown tables inside the prose column on small screens.
44 html = html.replace(/<table>/g, '<div class="table-scroll"><table>');
45 html = html.replace(/<\/table>/g, '</table></div>');
46
47 // Mark the first blockquote as hero callout
48 html = html.replace(
49 /<blockquote>/,
50 '<blockquote class="hero-callout">'
51 );
52
53 // Remove the h1 (it's redundant with the page header)
54 html = html.replace(/<h1>.*?<\/h1>\n?/, "");
55
56 // Fix ordered list counter for interrupted lists (ol start="N")
57 html = html.replace(
58 /<ol start="(\d+)">/g,
59 (_, start) => `<ol style="counter-reset:step-counter ${parseInt(start) - 1}">`
60 );
61
62 return html;
63}
64
65export function DocRenderer({ version }: DocRendererProps) {
66 const locale = useLocale();

Callers 1

DocRendererFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected