@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/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
- }
@@ -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
- });
@@ -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
- `&lt;i&gt;This should NOT be italic&lt;/i&gt;`,
9
- mockRenderMarkdownParams
10
- );
11
-
12
- expect(code).to.equal(`<p>&#x3C;i>This should NOT be italic&#x3C;/i></p>`);
13
- });
14
- });
@@ -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
- });
@@ -1,3 +0,0 @@
1
- export const mockRenderMarkdownParams = {
2
- contentDir: new URL('file:///src/content/'),
3
- };
package/tsconfig.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "../../../tsconfig.base.json",
3
- "include": ["src"],
4
- "compilerOptions": {
5
- "allowJs": true,
6
- "target": "ES2021",
7
- "module": "ES2022",
8
- "outDir": "./dist"
9
- }
10
- }