( file: MDFile, config: (X: Pluggable) => CompileOptions, )
| 18 | const ignoreProperties = ["start", "end", "position", "loc", "range"] |
| 19 | |
| 20 | export async function compileAST( |
| 21 | file: MDFile, |
| 22 | config: (X: Pluggable) => CompileOptions, |
| 23 | ) { |
| 24 | let ast: any |
| 25 | |
| 26 | const options = config(() => (tree) => { |
| 27 | ast = tree |
| 28 | }) |
| 29 | |
| 30 | await compile(file, options) |
| 31 | |
| 32 | return await prettier.format( |
| 33 | JSON.stringify(ast, (key, value) => |
| 34 | ignoreProperties.includes(key) ? undefined : value, |
| 35 | ), |
| 36 | { |
| 37 | semi: false, |
| 38 | parser: "json", |
| 39 | }, |
| 40 | ) |
| 41 | } |
| 42 | |
| 43 | export async function compileJS(file: MDFile, options: CompileOptions) { |
| 44 | const r = await compile(file, options) |
no outgoing calls
searching dependent graphs…