MCPcopy Create free account
hub / github.com/Datakitpage/Datakit / convertMarkdownToHTML

Function convertMarkdownToHTML

frontend/src/utils/notebookExport.ts:160–171  ·  view source on GitHub ↗
(markdown: string)

Source from the content-addressed store, hash-verified

158 * Convert markdown text to HTML for PDF export
159 */
160const convertMarkdownToHTML = (markdown: string): string => {
161 return markdown
162 .replace(/^# (.*$)/gim, '<h1 style="font-size: 18px; font-weight: bold; margin: 10px 0; color: #000;">$1</h1>')
163 .replace(/^## (.*$)/gim, '<h2 style="font-size: 16px; font-weight: bold; margin: 8px 0; color: #000;">$1</h2>')
164 .replace(/^### (.*$)/gim, '<h3 style="font-size: 14px; font-weight: bold; margin: 6px 0; color: #000;">$1</h3>')
165 .replace(/\*\*(.*?)\*\*/g, '<strong style="font-weight: bold;">$1</strong>')
166 .replace(/\*(.*?)\*/g, '<em style="font-style: italic;">$1</em>')
167 .replace(/`(.*?)`/g, '<code style="background-color: #f0f0f0; padding: 2px 4px; border-radius: 3px; font-family: monospace;">$1</code>')
168 .replace(/^- (.*$)/gim, '<li style="margin: 4px 0;">$1</li>')
169 .replace(/(\n|^)([^<\n].*?)(\n|$)/g, '<p style="margin: 8px 0; line-height: 1.4;">$2</p>')
170 .replace(/(<li.*?<\/li>)+/g, '<ul style="margin: 8px 0; padding-left: 20px;">$&</ul>');
171};
172
173/**
174 * Generate HTML content for PDF export from notebook cells

Callers 1

generateNotebookHTMLFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected