UNPKG

myst-cli

Version:
72 lines 3.41 kB
import { VFile } from 'vfile'; import type { GenericParent } from 'myst-common'; import { RuleId } from 'myst-common'; import type { PageFrontmatter } from 'myst-frontmatter'; import { SourceFileKind } from 'myst-spec-ext'; import type { ISession } from '../session/types.js'; import type { PreRendererData, RendererData } from '../transforms/types.js'; import type { ValidationOptions } from 'simple-validators'; type LoadFileOptions = { preFrontmatter?: Record<string, any>; keepTitleNode?: boolean; kind?: SourceFileKind; }; export type LoadFileResult = { kind: SourceFileKind; mdast: GenericParent; frontmatter?: PageFrontmatter; identifiers?: string[]; widgets?: Record<string, any>; }; export declare function loadMdFile(session: ISession, content: string, file: string, opts?: LoadFileOptions): LoadFileResult; export declare function loadNotebookFile(session: ISession, content: string, file: string, opts?: LoadFileOptions): Promise<LoadFileResult>; export declare function loadTexFile(session: ISession, content: string, file: string, opts?: LoadFileOptions): LoadFileResult; export declare function mystJSONValidationOpts(vfile: VFile, opts?: { property?: string; ruleId?: RuleId; }): ValidationOptions; export declare function loadMySTJSON(session: ISession, content: string, file: string, opts?: LoadFileOptions): { mdast: GenericParent; kind: SourceFileKind; frontmatter: PageFrontmatter; identifiers: string[]; }; /** * Attempt to load a file into the current session. Unsupported files with * issue a warning * * @param session session with logging * @param file path to file to load * @param projectPath path to project directory * @param extension pre-computed file extension * @param opts loading options * * @param opts.preFrontmatter raw page frontmatter, prioritized over frontmatter * read from the file. Fields defined here will override fields defined * in the file. Unlike project and page frontmatter which are carefully * combined to maintain affiliations, keep all math macros, etc, this * override simply replaces fields prior to any further processing or * validation. */ export declare function loadFile(session: ISession, file: string, projectPath?: string, extension?: '.md' | '.ipynb' | '.tex' | '.bib' | '.myst.json', opts?: LoadFileOptions): Promise<PreRendererData | undefined>; export declare function loadFrontmatterParts(session: ISession, file: string, property: string, frontmatter: PageFrontmatter, projectPath?: string): Promise<{ [k: string]: string[]; }>; /** * Find bibliography files in the given directory, loading them if required * * @param session session with logging * @param dir directory to search * @param load load bib files in addition to locating them */ export declare function bibFilesInDir(session: ISession, dir: string, load?: boolean): Promise<string[]>; /** * Return the cached post-processed MDAST for the given file, or return undefined * * @param session session with logging * @param file path to file */ export declare function selectFile(session: ISession, file: string): RendererData | undefined; export declare function getRawFrontmatterFromFile(session: ISession, file: string, projectPath?: string): Promise<import("myst-config").ProjectConfig | PageFrontmatter | undefined>; export {}; //# sourceMappingURL=file.d.ts.map