UNPKG

myst-to-jats

Version:
43 lines (42 loc) 1.52 kB
// function renderMimeToJats(state: IJatsSerializer, node: GenericNode): Element[] { // const { result } = node as InlineExpression; // return Object.entries(result?.data ?? {}).map(([key, value]): Element => { // switch (key) { // case 'text/plain': // return { type: 'text', text: value as string }; // default: // state.error(`Unknown inline render target of type ${key}`, node); // return { type: 'text', text: 'Unknown Inline Expression' }; // } // }); // } export const inlineExpression = (node, state) => { const { identifier, value } = node; state.renderInline(node, 'xref', { 'ref-type': 'custom', 'custom-type': 'expression', rid: identifier, }); const element = { type: 'element', name: 'sec', attributes: { id: identifier, 'sec-type': 'expression' }, elements: [ { type: 'element', name: 'code', attributes: { executable: 'yes' }, elements: [{ type: 'text', text: value }], }, { type: 'element', name: 'sec', attributes: { 'sec-type': 'notebook-output' }, elements: [{ type: 'element', name: 'p', elements: [{ type: 'text', text: value }] }], }, ], }; state.warn('JATS representations of inline expressions is not complete', node); if (element) state.expressions.push(element); };