Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 0 additions & 62 deletions __tests__/parsers/utils.test.js

This file was deleted.

2 changes: 2 additions & 0 deletions lib/mdx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import remarkStringify from 'remark-stringify';

import compilers from '../processor/compile';
import readmeToMdx from '../processor/transform/readme-to-mdx';
import divTransformer from '../processor/transform';

export const mdx = (tree: any, { hast = false } = {}) => {
const processor = unified()
.use(hast ? rehypeRemark : undefined)
.use(remarkMdx)
.use(remarkGfm)
.use(divTransformer)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not 100% on this placement, whether or not it should be before the hastifying

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine, I don't think there's any hastifing in this function. It's taking either an mdast or a hast and outputting mdx.

.use(readmeToMdx)
.use(remarkStringify)
.use(compilers);
Expand Down
10 changes: 0 additions & 10 deletions processor/compile/break.js

This file was deleted.

8 changes: 7 additions & 1 deletion processor/compile/compatibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { toMarkdown } from 'mdast-util-to-markdown';
import { toXast } from 'hast-util-to-xast';
import { toXml } from 'xast-util-to-xml';
import { NodeTypes } from '../../enums';
import { formatHProps, formatProps } from '../utils';
import { formatProps } from '../utils';

type CompatNodes =
| { type: NodeTypes.glossary; data: { hProperties: { term: string } } }
Expand All @@ -13,6 +13,8 @@ type CompatNodes =
| { type: 'embed'; data: { hProperties: { [key: string]: string } } }
| { type: 'escape'; value: string }
| { type: 'figure'; children: [Image, { type: 'figcaption'; children: [{ type: 'text'; value: string }] }] }
| { type: 'i'; data: { hProperties: { className: string[] } } }
| { type: 'yaml'; value: string }
| Html;

/*
Expand Down Expand Up @@ -80,6 +82,10 @@ const compatibility = (node: CompatNodes) => {
return figureToImageBlock(node);
case 'embed':
return embedToEmbedBlock(node);
case 'i':
return `:${node.data.hProperties.className[1]}:`;
case 'yaml':
return `---\n${node.value}\n---`;
default:
throw new Error('Unhandled node type!');
}
Expand Down
14 changes: 0 additions & 14 deletions processor/compile/div.js

This file was deleted.

8 changes: 0 additions & 8 deletions processor/compile/escape.js

This file was deleted.

40 changes: 0 additions & 40 deletions processor/compile/figure.js

This file was deleted.

6 changes: 0 additions & 6 deletions processor/compile/glossary.js

This file was deleted.

8 changes: 0 additions & 8 deletions processor/compile/i.js

This file was deleted.

2 changes: 2 additions & 0 deletions processor/compile/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ function compilers() {
escape: compatibility,
figure: compatibility,
html: compatibility,
i: compatibility,
yaml: compatibility,
};

toMarkdownExtensions.push({ extensions: [{ handlers }] });
Expand Down
7 changes: 0 additions & 7 deletions processor/compile/magic-block.js

This file was deleted.

8 changes: 0 additions & 8 deletions processor/compile/pin.js

This file was deleted.

11 changes: 0 additions & 11 deletions processor/compile/reusable-content.js

This file was deleted.

7 changes: 0 additions & 7 deletions processor/compile/table-head.js

This file was deleted.

6 changes: 0 additions & 6 deletions processor/compile/var.js

This file was deleted.

34 changes: 0 additions & 34 deletions processor/parse/compact-headings.js

This file was deleted.

46 changes: 0 additions & 46 deletions processor/parse/escape.js

This file was deleted.

Loading