Commit ee55d180 authored by Mahmoud Aglan's avatar Mahmoud Aglan

Fix build: add missing extractCodeBlocks export to api.js

parent d710f963
...@@ -21,6 +21,29 @@ async function request(method, path, token, body) { ...@@ -21,6 +21,29 @@ async function request(method, path, token, body) {
return res.json(); return res.json();
} }
// ═══════════════════════════════════════
// Utility: Extract fenced code blocks from markdown
// ═══════════════════════════════════════
export function extractCodeBlocks(markdown) {
if (!markdown) return [];
const blocks = [];
const re = /```([\w.:-]*)[ \t]*\r?\n([\s\S]*?)```/g;
let match;
while ((match = re.exec(markdown)) !== null) {
const raw = match[1] || "";
let lang = raw, filename = null;
const colonIdx = raw.indexOf(":");
if (colonIdx !== -1) {
lang = raw.slice(0, colonIdx);
filename = raw.slice(colonIdx + 1) || null;
}
blocks.push({ language: lang.toLowerCase(), filename, code: match[2] });
}
return blocks;
}
// ═══════════════════════════════════════ // ═══════════════════════════════════════
// Auth // Auth
// ═══════════════════════════════════════ // ═══════════════════════════════════════
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment