myst-cli
Version:
Command line tools for MyST
48 lines • 1.76 kB
TypeScript
import type { GenericNode, GenericParent } from 'myst-common';
import type { VFile } from 'vfile';
import type { ISession } from '../session/types.js';
/**
* Parse metadata from code block using js-yaml
*
* Metadata is defined at the beginning of code cells as:
*
* ```python
* #| key: value
* #| flag: true
*
* print('hello world')
* ```
*
* New lines around metadata will be ignored, but once a non-metadata line
* is encountered, metadata parsing is stopped (i.e. you cannot define
* metadata in the middle of other code).
*/
export declare function metadataFromCode(session: ISession, file: VFile, value: string, opts?: {
remove?: boolean;
}): {
value: string;
metadata?: Record<string, any>;
};
/**
* Traverse mdast, remove code cell metadata, and add it to parent block
*/
export declare function liftCodeMetadataToBlock(session: ISession, file: VFile, mdast: GenericParent): void;
/**
* Check duplicated meta tags and conflict meta tags.
* Separate the meta tags from tag if filter is true, otherwise just go through and process.
*/
export declare function checkMetaTags(vfile: VFile, node: GenericNode, tags: string[], filter: boolean): string[];
/**
* Traverse mdast, propagate block metadata and tags to code and output
*/
export declare function propagateBlockDataToCode(session: ISession, vfile: VFile, mdast: GenericParent): void;
/**
* Because jupytext style notebooks can introduce code-cells in blocks
* after explicit thematic breaks, we need to lift them up to the parent
* to ensure that all executable code blocks are at the top level of
* the document.
*
* @param mdast
*/
export declare function transformLiftCodeBlocksInJupytext(mdast: GenericParent): void;
//# sourceMappingURL=code.d.ts.map