Skip to content

Commit

Permalink
test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
dmca-glasgow committed Jun 27, 2022
1 parent f6d070f commit bf88a93
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
27 changes: 27 additions & 0 deletions compiler/src/mdast/__test__/environment.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { testProcessor } from '../../test-utils/test-processor';

describe('environment', () => {
it('should only show mac and cli sections', async () => {
const { md } = await testProcessor(`
::environment
:::mac
I am mac
:::
:::windows
I am windows
:::
:::cli
I am cli
:::
:::github-desktop
I am Github Desktop
:::
`);

console.log(md);
});
});
3 changes: 2 additions & 1 deletion compiler/src/mdast/combined.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { VFile } from 'vfile';

import { Context } from '../context';
import { boxouts } from './boxouts';
import { environment } from './environment';
import { moveAnswersToEnd } from './move-answers-to-end';

export async function combinedMdastPhase(
Expand All @@ -12,7 +13,7 @@ export async function combinedMdastPhase(
file: VFile,
targetPdf?: boolean
) {
const processor = unified().use(boxouts, ctx.refStore);
const processor = unified().use(environment).use(boxouts, ctx.refStore);

if (targetPdf) {
processor.use(moveAnswersToEnd);
Expand Down
15 changes: 15 additions & 0 deletions compiler/src/mdast/environment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ContainerDirective, LeafDirective } from 'mdast-util-directive';
import { Node } from 'unist';
import { visit } from 'unist-util-visit';

export function environment() {
return async (tree: Node) => {
visit(tree, 'leafDirective', (node: LeafDirective) => {
console.log('leaf', node);
});

visit(tree, 'containerDirective', (node: ContainerDirective) => {
console.log('container', node);
});
};
}

0 comments on commit bf88a93

Please sign in to comment.