@docusaurus/mdx-loader 2.0.0-beta.13 → 2.0.0-beta.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +11 -5
- package/lib/index.js.map +1 -0
- package/lib/remark/headings/index.d.ts +1 -0
- package/lib/remark/headings/index.d.ts.map +1 -0
- package/lib/remark/headings/index.js +1 -0
- package/lib/remark/headings/index.js.map +1 -0
- package/lib/remark/toc/index.d.ts +1 -0
- package/lib/remark/toc/index.d.ts.map +1 -0
- package/lib/remark/toc/index.js +1 -0
- package/lib/remark/toc/index.js.map +1 -0
- package/lib/remark/toc/search.d.ts +1 -0
- package/lib/remark/toc/search.d.ts.map +1 -0
- package/lib/remark/toc/search.js +4 -4
- package/lib/remark/toc/search.js.map +1 -0
- package/lib/remark/transformImage/index.d.ts +4 -3
- package/lib/remark/transformImage/index.d.ts.map +1 -0
- package/lib/remark/transformImage/index.js +63 -42
- package/lib/remark/transformImage/index.js.map +1 -0
- package/lib/remark/transformLinks/index.d.ts +3 -3
- package/lib/remark/transformLinks/index.d.ts.map +1 -0
- package/lib/remark/transformLinks/index.js +52 -55
- package/lib/remark/transformLinks/index.js.map +1 -0
- package/lib/remark/unwrapMdxCodeBlocks/index.d.ts +1 -0
- package/lib/remark/unwrapMdxCodeBlocks/index.d.ts.map +1 -0
- package/lib/remark/unwrapMdxCodeBlocks/index.js +1 -0
- package/lib/remark/unwrapMdxCodeBlocks/index.js.map +1 -0
- package/lib/remark/utils/index.d.ts +1 -0
- package/lib/remark/utils/index.d.ts.map +1 -0
- package/lib/remark/utils/index.js +1 -0
- package/lib/remark/utils/index.js.map +1 -0
- package/package.json +6 -7
- package/src/index.ts +10 -5
- package/src/remark/headings/index.ts +1 -1
- package/src/remark/toc/index.ts +1 -1
- package/src/remark/toc/search.ts +4 -6
- package/src/remark/transformImage/index.ts +101 -68
- package/src/remark/transformLinks/index.ts +76 -91
- package/lib/.tsbuildinfo +0 -1
- package/src/remark/headings/__tests__/index.test.ts +0 -313
- package/src/remark/toc/__tests__/__snapshots__/index.test.ts.snap +0 -95
- package/src/remark/toc/__tests__/fixtures/empty-headings.md +0 -5
- package/src/remark/toc/__tests__/fixtures/inline-code.md +0 -9
- package/src/remark/toc/__tests__/fixtures/insert-below-imports.md +0 -11
- package/src/remark/toc/__tests__/fixtures/just-content.md +0 -15
- package/src/remark/toc/__tests__/fixtures/name-exist.md +0 -7
- package/src/remark/toc/__tests__/fixtures/non-text-content.md +0 -9
- package/src/remark/toc/__tests__/index.test.ts +0 -226
- package/src/remark/toc/__tests__/search.test.ts +0 -182
- package/src/remark/transformImage/__tests__/__fixtures__/fail.md +0 -1
- package/src/remark/transformImage/__tests__/__fixtures__/img.md +0 -19
- package/src/remark/transformImage/__tests__/__fixtures__/noUrl.md +0 -1
- package/src/remark/transformImage/__tests__/__fixtures__/pathname.md +0 -1
- package/src/remark/transformImage/__tests__/__fixtures__/static/img.png +0 -0
- package/src/remark/transformImage/__tests__/__fixtures__/static2/img2.png +0 -0
- package/src/remark/transformImage/__tests__/__snapshots__/index.test.ts.snap +0 -33
- package/src/remark/transformImage/__tests__/index.test.ts +0 -63
- package/src/remark/transformLinks/__tests__/__fixtures__/asset.md +0 -35
- package/src/remark/transformLinks/__tests__/__fixtures__/asset.pdf +0 -0
- package/src/remark/transformLinks/__tests__/__fixtures__/noUrl.md +0 -1
- package/src/remark/transformLinks/__tests__/__fixtures__/pathname.md +0 -1
- package/src/remark/transformLinks/__tests__/__fixtures__/static/staticAsset.pdf +0 -0
- package/src/remark/transformLinks/__tests__/__fixtures__/static/staticAssetImage.png +0 -0
- package/src/remark/transformLinks/__tests__/__fixtures__/static2/asset2.pdf +0 -0
- package/src/remark/transformLinks/__tests__/__snapshots__/index.test.ts.snap +0 -47
- package/src/remark/transformLinks/__tests__/index.test.ts +0 -55
- package/src/remark/unwrapMdxCodeBlocks/__tests__/__snapshots__/index.test.ts.snap +0 -819
- package/src/remark/unwrapMdxCodeBlocks/__tests__/fixtures/has-mdx-code-blocks.mdx +0 -95
- package/src/remark/unwrapMdxCodeBlocks/__tests__/index.test.ts +0 -38
- package/tsconfig.json +0 -9
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import path from 'path';
|
|
9
|
-
import remark from 'remark';
|
|
10
|
-
import mdx from 'remark-mdx';
|
|
11
|
-
import vfile from 'to-vfile';
|
|
12
|
-
import plugin from '..';
|
|
13
|
-
import transformImage from '../../transformImage';
|
|
14
|
-
import {posixPath} from '@docusaurus/utils';
|
|
15
|
-
|
|
16
|
-
const processFixture = async (name: string, options?) => {
|
|
17
|
-
const filePath = path.join(__dirname, `__fixtures__/${name}.md`);
|
|
18
|
-
const staticDirs = [
|
|
19
|
-
path.join(__dirname, '__fixtures__/static'),
|
|
20
|
-
path.join(__dirname, '__fixtures__/static2'),
|
|
21
|
-
];
|
|
22
|
-
const file = await vfile.read(filePath);
|
|
23
|
-
const result = await remark()
|
|
24
|
-
.use(mdx)
|
|
25
|
-
.use(transformImage, {...options, filePath, staticDirs})
|
|
26
|
-
.use(plugin, {
|
|
27
|
-
...options,
|
|
28
|
-
filePath,
|
|
29
|
-
staticDirs,
|
|
30
|
-
siteDir: path.join(__dirname, '__fixtures__'),
|
|
31
|
-
})
|
|
32
|
-
.process(file);
|
|
33
|
-
|
|
34
|
-
return result
|
|
35
|
-
.toString()
|
|
36
|
-
.replace(new RegExp(posixPath(process.cwd()), 'g'), '[CWD]');
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
describe('transformAsset plugin', () => {
|
|
40
|
-
test('fail if asset url is absent', async () => {
|
|
41
|
-
await expect(
|
|
42
|
-
processFixture('noUrl'),
|
|
43
|
-
).rejects.toThrowErrorMatchingSnapshot();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test('transform md links to <a />', async () => {
|
|
47
|
-
const result = await processFixture('asset');
|
|
48
|
-
expect(result).toMatchSnapshot();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
test('pathname protocol', async () => {
|
|
52
|
-
const result = await processFixture('pathname');
|
|
53
|
-
expect(result).toMatchSnapshot();
|
|
54
|
-
});
|
|
55
|
-
});
|