/** * [[include:src/codecs/xmd/README.md]] * * @module codecs/xmd */ import schema from '@stencila/schema'; import * as vfile from '../../util/vfile'; import { Codec, CommonEncodeOptions } from '../types'; export declare class XmdCodec extends Codec implements Codec { readonly extNames: string[]; /** * Decode XMarkdown to a Stencila node. * * This function uses regexes to transform XMarkdown to Commonmark * which is then passed onto the `MdCodec.decode` method. * * @param file The `VFile` to decode */ readonly decode: (file: vfile.VFile) => Promise; /** * Encode a Stencila node to XMarkdown. * * If `strict=true`, this function first transforms the node by converting * any `CodeExpression` nodes to `CodeFragment` nodes and `CodeChunk` nodes * to `CodeBlock` nodes. This is intentionally lossy since any results of * execution (e.g. error or outputs) are not stored in RMarkdown. * * @param node The Stencila node to encode */ readonly encode: (node: schema.Node, options?: CommonEncodeOptions & { strict?: boolean; }) => Promise; } /** * Replace RMarkdown code chunks that are nested inside a Markdown `chunk` * block extension with a plain code block. * * When encoding code chunks we made the nested code block compatible with * RMarkdown by using curly braces around the language e.g. `{r}`. This turns * those into plain code blocks so that they do not get decoded to anther * `chunk` by the `decodeBlockChunk` function below. */ export declare function decodeNestedChunks(xmd: string): string; /** * Replace RMarkdown inline code chunks with Markdown inline code nodes with `type=expr`. * * The inline code nodes produced will subsequently be handled by the * `MdCodec.decodeInlineCode` function. */ export declare function decodeInlineChunk(xmd: string): string; /** * Replace RMarkdown block code chunks with Markdown `chunk` block extensions. * * If the code chunk has a label, then that becomes the label of the chunk. * If the code chunk has a `fig.cap` attribute: * - if `fig.cap` is a "text reference" e.g. fig.cap='(ref:foo)', then searches * for the paragraph with that id. * - otherwise, uses the caption as is. * * @see https://bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html#text-references */ export declare function decodeBlockChunk(xmd: string): string;