UNPKG

@curvenote/cli

Version:
28 lines (27 loc) 1.2 kB
import { oxaLink, oxaLinkToId } from '@curvenote/blocks'; import { basekey } from './basekey.js'; export function localizationOptions(session, imageFilenames, references) { return { localizeImageSrc: (src) => imageFilenames[src], localizeId: (maybeOxaLink) => { var _a, _b; const oxa = oxaLinkToId(maybeOxaLink); return (_b = (_a = oxa === null || oxa === void 0 ? void 0 : oxa.id) !== null && _a !== void 0 ? _a : oxa === null || oxa === void 0 ? void 0 : oxa.block.block) !== null && _b !== void 0 ? _b : maybeOxaLink; }, localizeCitation: (key) => { var _a; const label = (_a = references[basekey(key)]) === null || _a === void 0 ? void 0 : _a.label; if (label) return label; session.log.error(`The reference for "${key}" was not loaded.`); // Return something safe for latex and markdown return 'unknownKey'; }, localizeLink: (href) => { const oxa = oxaLinkToId(href); if (!oxa) return href; return oxaLink(session.config.editorUrl, oxa.block, oxa); }, }; }