@curvenote/schema
Version:
Schema and markdown parser for @curvenote/editor
30 lines • 897 B
JavaScript
import { CaptionKind } from '../nodes/types';
import { nodeNames } from '../types';
function switchKind(node) {
switch (node.type.name) {
case nodeNames.iframe:
case nodeNames.image:
return CaptionKind.fig;
case nodeNames.table:
return CaptionKind.table;
case nodeNames.code_block:
return CaptionKind.code;
case nodeNames.equation:
return CaptionKind.eq;
default:
return null;
}
}
export function determineCaptionKind(node) {
var _a;
if (node.type.name !== nodeNames.figure)
return switchKind(node);
const childrenKinds = [];
node.forEach((n) => {
const kind = switchKind(n);
if (kind)
childrenKinds.push(kind);
});
return (_a = childrenKinds[0]) !== null && _a !== void 0 ? _a : null;
}
//# sourceMappingURL=utils.js.map