[ci] format
This commit is contained in:
parent
80c71c7c56
commit
9502fbf4a9
3 changed files with 6 additions and 10 deletions
|
@ -82,7 +82,7 @@ describe('Astro Markdown', () => {
|
||||||
it.only('Can handle HTML comments in inline code', async () => {
|
it.only('Can handle HTML comments in inline code', async () => {
|
||||||
const html = await fixture.readFile('/comment-with-js/index.html');
|
const html = await fixture.readFile('/comment-with-js/index.html');
|
||||||
const $ = cheerio.load(html);
|
const $ = cheerio.load(html);
|
||||||
|
|
||||||
expect($('p code').text()).to.equal('<!-- HTML comments in code -->');
|
expect($('p code').text()).to.equal('<!-- HTML comments in code -->');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ describe('Astro Markdown', () => {
|
||||||
const html = await fixture.readFile('/comment-with-js/index.html');
|
const html = await fixture.readFile('/comment-with-js/index.html');
|
||||||
const $ = cheerio.load(html);
|
const $ = cheerio.load(html);
|
||||||
|
|
||||||
expect($('body > code').text()).to.equal('<!-- HTML comments in code fence -->')
|
expect($('body > code').text()).to.equal('<!-- HTML comments in code fence -->');
|
||||||
});
|
});
|
||||||
|
|
||||||
// https://github.com/withastro/astro/issues/3254
|
// https://github.com/withastro/astro/issues/3254
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { visit } from 'unist-util-visit';
|
|
||||||
import type { Literal } from 'unist';
|
import type { Literal } from 'unist';
|
||||||
|
import { visit } from 'unist-util-visit';
|
||||||
|
|
||||||
// In code blocks, this removes the JS comment wrapper added to
|
// In code blocks, this removes the JS comment wrapper added to
|
||||||
// HTML comments by vite-plugin-markdown.
|
// HTML comments by vite-plugin-markdown.
|
||||||
|
@ -10,8 +10,6 @@ export default function remarkEscape() {
|
||||||
};
|
};
|
||||||
|
|
||||||
function removeCommentWrapper(node: Literal<string>) {
|
function removeCommentWrapper(node: Literal<string>) {
|
||||||
node.value = node.value
|
node.value = node.value.replace(/{\/\*<!--/gs, '<!--').replace(/-->\*\/}/gs, '-->');
|
||||||
.replace(/{\/\*<!--/gs, '<!--')
|
|
||||||
.replace(/-->\*\/}/gs, '-->');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,9 +81,7 @@ describe('expressions', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should unwrap HTML comments in inline code blocks', async () => {
|
it('should unwrap HTML comments in inline code blocks', async () => {
|
||||||
const { code } = await renderMarkdown(
|
const { code } = await renderMarkdown(`\`{/*<!-- HTML comment -->*/}\``);
|
||||||
`\`{/*<!-- HTML comment -->*/}\``
|
|
||||||
);
|
|
||||||
|
|
||||||
chai.expect(code).to.equal('<p><code is:raw><!-- HTML comment --></code></p>');
|
chai.expect(code).to.equal('<p><code is:raw><!-- HTML comment --></code></p>');
|
||||||
});
|
});
|
||||||
|
@ -97,6 +95,6 @@ describe('expressions', () => {
|
||||||
`
|
`
|
||||||
);
|
);
|
||||||
|
|
||||||
chai.expect(code).to.match(/(?<!{\/\*)<!-- HTML comment -->(?!\*\/})/);
|
chai.expect(code).to.match(/(?<!{\/\*)<!-- HTML comment -->(?!\*\/})/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue