@astrojs/markdown-remark 2.2.0 → 2.2.1
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/package.json +6 -3
- package/.turbo/turbo-build.log +0 -4
- package/CHANGELOG.md +0 -832
- package/src/frontmatter-injection.ts +0 -41
- package/src/index.ts +0 -170
- package/src/internal.ts +0 -5
- package/src/load-plugins.ts +0 -42
- package/src/rehype-collect-headings.ts +0 -129
- package/src/rehype-images.ts +0 -19
- package/src/remark-collect-images.ts +0 -30
- package/src/remark-prism.ts +0 -32
- package/src/remark-scoped-styles.ts +0 -18
- package/src/remark-shiki.ts +0 -126
- package/src/types.ts +0 -96
- package/test/autolinking.test.js +0 -43
- package/test/entities.test.js +0 -14
- package/test/plugins.test.js +0 -28
- package/test/test-utils.js +0 -3
- package/tsconfig.json +0 -10
package/src/types.ts
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import type * as hast from 'hast';
|
|
2
|
-
import type * as mdast from 'mdast';
|
|
3
|
-
import type {
|
|
4
|
-
all as Handlers,
|
|
5
|
-
one as Handler,
|
|
6
|
-
Options as RemarkRehypeOptions,
|
|
7
|
-
} from 'remark-rehype';
|
|
8
|
-
import type { ILanguageRegistration, IThemeRegistration, Theme } from 'shiki';
|
|
9
|
-
import type * as unified from 'unified';
|
|
10
|
-
import type { VFile } from 'vfile';
|
|
11
|
-
|
|
12
|
-
export type { Node } from 'unist';
|
|
13
|
-
|
|
14
|
-
export type MarkdownAstroData = {
|
|
15
|
-
frontmatter: Record<string, any>;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type RemarkPlugin<PluginParameters extends any[] = any[]> = unified.Plugin<
|
|
19
|
-
PluginParameters,
|
|
20
|
-
mdast.Root
|
|
21
|
-
>;
|
|
22
|
-
|
|
23
|
-
export type RemarkPlugins = (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[];
|
|
24
|
-
|
|
25
|
-
export type RehypePlugin<PluginParameters extends any[] = any[]> = unified.Plugin<
|
|
26
|
-
PluginParameters,
|
|
27
|
-
hast.Root
|
|
28
|
-
>;
|
|
29
|
-
|
|
30
|
-
export type RehypePlugins = (string | [string, any] | RehypePlugin | [RehypePlugin, any])[];
|
|
31
|
-
|
|
32
|
-
export type RemarkRehype = Omit<RemarkRehypeOptions, 'handlers' | 'unknownHandler'> & {
|
|
33
|
-
handlers?: typeof Handlers;
|
|
34
|
-
handler?: typeof Handler;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export interface ShikiConfig {
|
|
38
|
-
langs?: ILanguageRegistration[];
|
|
39
|
-
theme?: Theme | IThemeRegistration;
|
|
40
|
-
wrap?: boolean | null;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface AstroMarkdownOptions {
|
|
44
|
-
drafts?: boolean;
|
|
45
|
-
syntaxHighlight?: 'shiki' | 'prism' | false;
|
|
46
|
-
shikiConfig?: ShikiConfig;
|
|
47
|
-
remarkPlugins?: RemarkPlugins;
|
|
48
|
-
rehypePlugins?: RehypePlugins;
|
|
49
|
-
remarkRehype?: RemarkRehype;
|
|
50
|
-
gfm?: boolean;
|
|
51
|
-
smartypants?: boolean;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface ImageMetadata {
|
|
55
|
-
src: string;
|
|
56
|
-
width: number;
|
|
57
|
-
height: number;
|
|
58
|
-
type: string;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface MarkdownRenderingOptions extends AstroMarkdownOptions {
|
|
62
|
-
/** @internal */
|
|
63
|
-
fileURL?: URL;
|
|
64
|
-
/** @internal */
|
|
65
|
-
$?: {
|
|
66
|
-
scopedClassName: string | null;
|
|
67
|
-
};
|
|
68
|
-
/** Used for frontmatter injection plugins */
|
|
69
|
-
frontmatter?: Record<string, any>;
|
|
70
|
-
experimentalAssets?: boolean;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export interface MarkdownHeading {
|
|
74
|
-
depth: number;
|
|
75
|
-
slug: string;
|
|
76
|
-
text: string;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export interface MarkdownMetadata {
|
|
80
|
-
headings: MarkdownHeading[];
|
|
81
|
-
source: string;
|
|
82
|
-
html: string;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export interface MarkdownVFile extends VFile {
|
|
86
|
-
data: {
|
|
87
|
-
__astroHeadings?: MarkdownHeading[];
|
|
88
|
-
imagePaths?: Set<string>;
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export interface MarkdownRenderingResult {
|
|
93
|
-
metadata: MarkdownMetadata;
|
|
94
|
-
vfile: MarkdownVFile;
|
|
95
|
-
code: string;
|
|
96
|
-
}
|
package/test/autolinking.test.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { renderMarkdown } from '../dist/index.js';
|
|
2
|
-
import chai from 'chai';
|
|
3
|
-
import { mockRenderMarkdownParams } from './test-utils.js';
|
|
4
|
-
|
|
5
|
-
describe('autolinking', () => {
|
|
6
|
-
describe('plain md', () => {
|
|
7
|
-
it('autolinks URLs starting with a protocol in plain text', async () => {
|
|
8
|
-
const { code } = await renderMarkdown(
|
|
9
|
-
`See https://example.com for more.`,
|
|
10
|
-
mockRenderMarkdownParams
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
chai
|
|
14
|
-
.expect(code.replace(/\n/g, ''))
|
|
15
|
-
.to.equal(`<p>See <a href="https://example.com">https://example.com</a> for more.</p>`);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('autolinks URLs starting with "www." in plain text', async () => {
|
|
19
|
-
const { code } = await renderMarkdown(
|
|
20
|
-
`See www.example.com for more.`,
|
|
21
|
-
mockRenderMarkdownParams
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
chai
|
|
25
|
-
.expect(code.trim())
|
|
26
|
-
.to.equal(`<p>See <a href="http://www.example.com">www.example.com</a> for more.</p>`);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('does not autolink URLs in code blocks', async () => {
|
|
30
|
-
const { code } = await renderMarkdown(
|
|
31
|
-
'See `https://example.com` or `www.example.com` for more.',
|
|
32
|
-
mockRenderMarkdownParams
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
chai
|
|
36
|
-
.expect(code.trim())
|
|
37
|
-
.to.equal(
|
|
38
|
-
`<p>See <code>https://example.com</code> or ` +
|
|
39
|
-
`<code>www.example.com</code> for more.</p>`
|
|
40
|
-
);
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
});
|
package/test/entities.test.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { renderMarkdown } from '../dist/index.js';
|
|
2
|
-
import { expect } from 'chai';
|
|
3
|
-
import { mockRenderMarkdownParams } from './test-utils.js';
|
|
4
|
-
|
|
5
|
-
describe('entities', () => {
|
|
6
|
-
it('should not unescape entities in regular Markdown', async () => {
|
|
7
|
-
const { code } = await renderMarkdown(
|
|
8
|
-
`<i>This should NOT be italic</i>`,
|
|
9
|
-
mockRenderMarkdownParams
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
expect(code).to.equal(`<p><i>This should NOT be italic</i></p>`);
|
|
13
|
-
});
|
|
14
|
-
});
|
package/test/plugins.test.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { renderMarkdown } from '../dist/index.js';
|
|
2
|
-
import { mockRenderMarkdownParams } from './test-utils.js';
|
|
3
|
-
import chai from 'chai';
|
|
4
|
-
|
|
5
|
-
import { fileURLToPath } from 'node:url';
|
|
6
|
-
|
|
7
|
-
describe('plugins', () => {
|
|
8
|
-
// https://github.com/withastro/astro/issues/3264
|
|
9
|
-
it('should be able to get file path when passing fileURL', async () => {
|
|
10
|
-
let context;
|
|
11
|
-
await renderMarkdown(`test`, {
|
|
12
|
-
...mockRenderMarkdownParams,
|
|
13
|
-
fileURL: new URL('virtual.md', import.meta.url),
|
|
14
|
-
remarkPlugins: [
|
|
15
|
-
function () {
|
|
16
|
-
const transformer = (tree, file) => {
|
|
17
|
-
context = file;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
return transformer;
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
chai.expect(typeof context).to.equal('object');
|
|
26
|
-
chai.expect(context.path).to.equal(fileURLToPath(new URL('virtual.md', import.meta.url)));
|
|
27
|
-
});
|
|
28
|
-
});
|
package/test/test-utils.js
DELETED