/** * [[include:src/codecs/mathml/README.md]] * * @module codecs/mathml */ import schema from '@stencila/schema'; import * as vfile from '../../util/vfile'; import { Codec } from '../types'; export declare class MathMLCodec extends Codec implements Codec { /** * The media types that this codec can decode/encode. * * @see https://www.w3.org/Math/mathml-faq.html */ readonly mediaTypes: string[]; /** * The file extension names that this codec will match. */ readonly extNames: string[]; /** * Sniff content to see if it is MathML. * * For speed, rather than parsing the entire content as XML, this * function just uses a regex to checks if the content starts with * a `` node. * * @param content The content to be sniffed */ readonly sniff: (content: string) => Promise; /** * Decode a `VFile` with MathML content to a Stencila `Math` node. * * Parses the XML but currently, does not do any validation to ensure that * it is MathML. * * @param file The `VFile` to decode * @returns A promise that resolves to a Stencila `MathBlock` or `MathFragment` * depending upon the `display` attribute of the top level `` * element. Defaults to `MathFragment` (i.e. `display="inline"`) */ readonly decode: (file: vfile.VFile) => Promise; /** * Encode a Stencila `Math` node to a `VFile` with MathML content. * * Attempts to translate other math languages that the node may * have (e.g TeX) to MathML. * * @param thing The Stencila `Node` to encode * @returns A promise that resolves to a `VFile` */ readonly encode: (node: schema.Node) => Promise; } /** * Normalizes XML before parsing. * * This function operates on raw XML strings. * Some of these transformations could instead be done after parsing, * on the XML tree. But, where it is safe, these regex based replacements * are less onerous to implement and allow reuse elsewhere * e.g. when using XSLT transforms. * * @param xml Unormalized XML */ export declare function normalize(xml: string): string;