[ci] format
This commit is contained in:
parent
ac03218247
commit
4faee5afed
2 changed files with 12 additions and 11 deletions
|
@ -650,7 +650,7 @@ export interface AstroUserConfig {
|
||||||
* @description
|
* @description
|
||||||
* Pass [remark plugins](https://github.com/remarkjs/remark) to customize how your Markdown is built. You can import and apply the plugin function (recommended), or pass the plugin name as a string.
|
* Pass [remark plugins](https://github.com/remarkjs/remark) to customize how your Markdown is built. You can import and apply the plugin function (recommended), or pass the plugin name as a string.
|
||||||
*
|
*
|
||||||
* :::caution
|
* :::caution
|
||||||
* Providing a list of plugins will **remove** our default plugins. To preserve these defaults, see the `extendDefaultPlugins` flag.
|
* Providing a list of plugins will **remove** our default plugins. To preserve these defaults, see the `extendDefaultPlugins` flag.
|
||||||
* :::
|
* :::
|
||||||
*
|
*
|
||||||
|
@ -671,7 +671,7 @@ export interface AstroUserConfig {
|
||||||
* @description
|
* @description
|
||||||
* Pass [rehype plugins](https://github.com/remarkjs/remark-rehype) to customize how your Markdown's output HTML is processed. You can import and apply the plugin function (recommended), or pass the plugin name as a string.
|
* Pass [rehype plugins](https://github.com/remarkjs/remark-rehype) to customize how your Markdown's output HTML is processed. You can import and apply the plugin function (recommended), or pass the plugin name as a string.
|
||||||
*
|
*
|
||||||
* :::caution
|
* :::caution
|
||||||
* Providing a list of plugins will **remove** our default plugins. To preserve these defaults, see the `extendDefaultPlugins` flag.
|
* Providing a list of plugins will **remove** our default plugins. To preserve these defaults, see the `extendDefaultPlugins` flag.
|
||||||
* :::
|
* :::
|
||||||
*
|
*
|
||||||
|
|
|
@ -14,8 +14,11 @@ async function buildFixture(config) {
|
||||||
|
|
||||||
function remarkExamplePlugin() {
|
function remarkExamplePlugin() {
|
||||||
return (tree) => {
|
return (tree) => {
|
||||||
tree.children.push({ type: 'paragraph', children: [{ type: 'text', value: 'Remark plugin applied!' }] })
|
tree.children.push({
|
||||||
}
|
type: 'paragraph',
|
||||||
|
children: [{ type: 'text', value: 'Remark plugin applied!' }],
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Astro Markdown plugins', () => {
|
describe('Astro Markdown plugins', () => {
|
||||||
|
@ -48,28 +51,26 @@ describe('Astro Markdown plugins', () => {
|
||||||
const fixture = await buildFixture({
|
const fixture = await buildFixture({
|
||||||
markdown: {
|
markdown: {
|
||||||
remarkPlugins: [remarkExamplePlugin],
|
remarkPlugins: [remarkExamplePlugin],
|
||||||
rehypePlugins: [
|
rehypePlugins: [[addClasses, { 'h1,h2,h3': 'title' }]],
|
||||||
[addClasses, { 'h1,h2,h3': 'title' }],
|
|
||||||
],
|
|
||||||
extendDefaultPlugins,
|
extendDefaultPlugins,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const html = await fixture.readFile('/with-gfm/index.html');
|
const html = await fixture.readFile('/with-gfm/index.html');
|
||||||
const $ = cheerio.load(html);
|
const $ = cheerio.load(html);
|
||||||
|
|
||||||
// test 1: GFM autolink applied correctly
|
// test 1: GFM autolink applied correctly
|
||||||
if (extendDefaultPlugins === true) {
|
if (extendDefaultPlugins === true) {
|
||||||
expect($('a[href="https://example.com"]')).to.have.lengthOf(1);
|
expect($('a[href="https://example.com"]')).to.have.lengthOf(1);
|
||||||
} else {
|
} else {
|
||||||
expect($('a[href="https://example.com"]')).to.have.lengthOf(0);
|
expect($('a[href="https://example.com"]')).to.have.lengthOf(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// test 2: (sanity check) remark plugins still applied
|
// test 2: (sanity check) remark plugins still applied
|
||||||
expect(html).to.include('Remark plugin applied!');
|
expect(html).to.include('Remark plugin applied!');
|
||||||
|
|
||||||
// test 3: (sanity check) rehype plugins still applied
|
// test 3: (sanity check) rehype plugins still applied
|
||||||
expect($('#github-flavored-markdown-test')).to.have.lengthOf(1);
|
expect($('#github-flavored-markdown-test')).to.have.lengthOf(1);
|
||||||
expect($('#github-flavored-markdown-test').hasClass('title')).to.equal(true);
|
expect($('#github-flavored-markdown-test').hasClass('title')).to.equal(true);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue